use of uk.ac.ebi.pride.jmztab.utils.MZTabFileParser in project mzmine2 by mzmine.
the class MzTabImportTask method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
try {
// Prevent MZTabFileParser from writing to console
OutputStream logStream = ByteStreams.nullOutputStream();
// Load mzTab file
MZTabFileParser mzTabFileParser = new MZTabFileParser(inputFile, logStream);
if (!mzTabFileParser.getErrorList().getErrorList().isEmpty()) {
setStatus(TaskStatus.ERROR);
setErrorMessage("Error processing " + inputFile + ":\n" + mzTabFileParser.getErrorList().toString());
return;
}
MZTabFile mzTabFile = mzTabFileParser.getMZTabFile();
// Let's say the initial parsing took 10% of the time
finishedPercentage = 0.1;
// Import raw data files
SortedMap<Integer, RawDataFile> rawDataFiles = importRawDataFiles(mzTabFile);
// Check if not canceled
if (isCanceled())
return;
// Create a new feature list
String peakListName = inputFile.getName().replace(".mzTab", "");
RawDataFile[] rawDataArray = rawDataFiles.values().toArray(new RawDataFile[0]);
PeakList newPeakList = new SimplePeakList(peakListName, rawDataArray);
// Check if not canceled
if (isCanceled())
return;
// Import variables
importVariables(mzTabFile, rawDataFiles);
// Check if not canceled
if (isCanceled())
return;
// import small molecules (=feature list rows)
importSmallMolecules(newPeakList, mzTabFile, rawDataFiles);
// Check if not canceled
if (isCanceled())
return;
// Add the new feature list to the project
project.addPeakList(newPeakList);
// Finish
setStatus(TaskStatus.FINISHED);
finishedPercentage = 1.0;
} catch (Exception e) {
e.printStackTrace();
setStatus(TaskStatus.ERROR);
setErrorMessage("Could not import data from " + inputFile + ": " + e.getMessage());
return;
}
}
Aggregations