use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.
the class MultiThreadPeakFinderMainTask method createResultsPeakList.
private PeakList createResultsPeakList() {
SimplePeakList processedPeakList = new SimplePeakList(peakList + " " + suffix, peakList.getRawDataFiles());
// Fill new feature list with empty rows
for (int row = 0; row < peakList.getNumberOfRows(); row++) {
PeakListRow sourceRow = peakList.getRow(row);
PeakListRow newRow = new SimplePeakListRow(sourceRow.getID());
newRow.setComment(sourceRow.getComment());
for (PeakIdentity ident : sourceRow.getPeakIdentities()) {
newRow.addPeakIdentity(ident, false);
}
if (sourceRow.getPreferredPeakIdentity() != null) {
newRow.setPreferredPeakIdentity(sourceRow.getPreferredPeakIdentity());
}
processedPeakList.addRow(newRow);
}
return processedPeakList;
}
use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.
the class PeakListBlankSubtractionMasterTask method run.
@Override
public void run() {
if (!checkBlankSelection(alignedFeatureList, blankRaws)) {
setErrorMessage("Peak list " + alignedFeatureList.getName() + " does no contain all selected blank raw data files.");
setStatus(TaskStatus.ERROR);
return;
}
setStatus(TaskStatus.PROCESSING);
// PeakListRow[] rowsInBlanks =
// getFeatureRowsContainedBlanks(alignedFeatureList, blankRaws, minBlankDetections);
PeakListRow[] rows = PeakUtils.copyPeakRows(alignedFeatureList.getRows());
rows = PeakUtils.sortRowsMzAsc(rows);
for (RawDataFile raw : alignedFeatureList.getRawDataFiles()) {
// only create a task for every file that is not a blank
if (Arrays.asList(blankRaws).contains(raw))
continue;
// these tasks will access the passed array and remove the features that appear in their raw
// data file and the blanks from these rows
AbstractTask task = new PeakListBlankSubtractionSingleTask(parameters, raw, rows);
MZmineCore.getTaskController().addTask(task);
subTasks.add(task);
if (getStatus() == TaskStatus.CANCELED)
return;
}
// wait for tasks to finish
boolean allTasksFinished = false;
while (!allTasksFinished) {
allTasksFinished = true;
for (AbstractTask task : subTasks) {
if (task.getStatus() != TaskStatus.FINISHED)
allTasksFinished = false;
}
try {
TimeUnit.MILLISECONDS.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
setErrorMessage(e.getMessage());
setStatus(TaskStatus.ERROR);
return;
}
if (getStatus() == TaskStatus.CANCELED)
return;
}
// remove rows that only contain blankRaws
List<RawDataFile> blankRawsList = Arrays.asList(blankRaws);
int onlyBlankRows = 0;
for (int i = 0; i < rows.length; i++) {
PeakListRow row = rows[i];
if (blankRawsList.containsAll(Arrays.asList(row.getRawDataFiles()))) {
onlyBlankRows++;
rows[i] = null;
}
if (getStatus() == TaskStatus.CANCELED)
return;
}
logger.finest("Removed " + onlyBlankRows + " rows that only existed in blankfiles.");
PeakList result = new SimplePeakList(alignedFeatureList.getName() + " sbtrctd", alignedFeatureList.getRawDataFiles());
for (PeakListRow row : rows) {
if (row != null) {
result.addRow(row);
}
}
PeakListUtils.copyPeakListAppliedMethods(alignedFeatureList, result);
result.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod(PeakListBlankSubtractionModule.MODULE_NAME, parameters));
project.addPeakList(result);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.
the class GNPSResultsImportTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Importing GNPS results for " + peakList);
// remove zero ids from edges to prevent exception
removeZeroIDFromEdge(file);
Graph graph = new DefaultGraph("GNPS");
if (importGraphData(graph, file)) {
// import library matches from nodes
importLibraryMatches(graph);
// Add task description to peakList
((SimplePeakList) peakList).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Identification of complexes", parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
logger.info("Finished import of GNPS results for " + peakList);
}
}
use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.
the class LipidSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Starting lipid search in " + peakList);
PeakListRow[] rows = peakList.getRows();
// Check if lipids should be modified
if (searchForModifications == true) {
lipidModificationMasses = getLipidModificationMasses(lipidModification);
}
// Calculate how many possible lipids we will try
totalSteps = ((maxChainLength - minChainLength + 1) * (maxDoubleBonds - minDoubleBonds + 1)) * selectedLipids.length;
// Try all combinations of fatty acid lengths and double bonds
for (int i = 0; i < selectedLipids.length; i++) {
int numberOfAcylChains = selectedLipids[i].getNumberOfAcylChains();
int numberOfAlkylChains = selectedLipids[i].getNumberofAlkyChains();
for (int chainLength = minChainLength; chainLength <= maxChainLength; chainLength++) {
for (int chainDoubleBonds = minDoubleBonds; chainDoubleBonds <= maxDoubleBonds; chainDoubleBonds++) {
// Task canceled?
if (isCanceled())
return;
// than minimal length, skip this lipid
if (((chainLength > 0) && (chainLength < minChainLength))) {
finishedSteps++;
continue;
}
// doesn't make sense, so let's skip such lipids
if (((chainDoubleBonds > 0) && (chainDoubleBonds > chainLength - 1))) {
finishedSteps++;
continue;
}
// Prepare a lipid instance
LipidIdentity lipidChain = new LipidIdentity(selectedLipids[i], chainLength, chainDoubleBonds, numberOfAcylChains, numberOfAlkylChains);
// Find all rows that match this lipid
findPossibleLipid(lipidChain, rows);
finishedSteps++;
}
}
}
// Add task description to peakList
((SimplePeakList) peakList).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Lipid search", parameters));
// Repaint the window to reflect the change in the peak list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
logger.info("Finished lipid search task in " + peakList);
}
use of net.sf.mzmine.datamodel.impl.SimplePeakList 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