use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class StreamPeakListRowLearnerTask method run.
/**
* @see Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Running learner task on " + peakList);
// Create a new results peakList which is added at the end
resultPeakList = new SimplePeakList(peakList + " " + suffix, peakList.getRawDataFiles());
/**
* - A PeakList is a list of Features (peak in retention time dimension with accurate m/z)<br>
* ---- contains one or multiple RawDataFiles <br>
* ---- access mean retention time, mean m/z, maximum intensity, ...<br>
*/
// use streams to filter, sort and create list
List<PeakListRow> rowList = Arrays.stream(peakList.getRows()).filter(r -> r.getAverageHeight() > 5000).sorted(new PeakListRowSorter(SortingProperty.MZ, SortingDirection.Ascending)).collect(Collectors.toList());
totalRows = rowList.size();
// ###########################################################
// OPTION 1: Streams
// either use stream to process all rows
rowList.stream().forEachOrdered(row -> {
// check for cancelled state and stop
if (isCanceled())
return;
// access details
double mz = row.getAverageMZ();
double intensity = row.getAverageHeight();
double rt = row.getAverageRT();
Feature peak = row.getBestPeak();
// do stuff
// ...
// add row to peaklist result
PeakListRow copy = copyPeakRow(row);
resultPeakList.addRow(copy);
// Update completion rate
processedPeaks++;
});
// OPTION 2: For loop
for (PeakListRow row : rowList) {
// check for cancelled state and stop
if (isCanceled())
return;
// access details
double mz = row.getAverageMZ();
double intensity = row.getAverageHeight();
double rt = row.getAverageRT();
Feature peak = row.getBestPeak();
// do stuff
// ...
// add row to peaklist result
PeakListRow copy = copyPeakRow(row);
resultPeakList.addRow(copy);
// Update completion rate
processedPeaks++;
}
// add to project
addResultToProject();
logger.info("Finished on " + peakList);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class ComplexSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Starting complex search in " + peakList);
PeakListRow[] rows = peakList.getRows();
totalRows = rows.length;
// Sort the array by m/z so we start with biggest peak (possible
// complex)
Arrays.sort(rows, new PeakListRowSorter(SortingProperty.MZ, SortingDirection.Descending));
// Compare each three rows against each other
for (int i = 0; i < totalRows; i++) {
Range<Double> testRTRange = rtTolerance.getToleranceRange(rows[i].getAverageRT());
PeakListRow[] testRows = peakList.getRowsInsideScanRange(testRTRange);
for (int j = 0; j < testRows.length; j++) {
for (int k = j; k < testRows.length; k++) {
// Task canceled?
if (isCanceled())
return;
// very small m/z peak
if ((rows[i] == testRows[j]) || (rows[i] == testRows[k]))
continue;
if (checkComplex(rows[i], testRows[j], testRows[k]))
addComplexInfo(rows[i], testRows[j], testRows[k]);
}
}
finishedRows++;
}
// 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 complexes search in " + peakList);
}
use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class PeakListIdentificationTask method run.
@Override
public void run() {
if (!isCanceled()) {
try {
setStatus(TaskStatus.PROCESSING);
// Create database gateway.
gateway = db.getModule().getGatewayClass().newInstance();
// Identify the feature list rows starting from the biggest peaks.
final PeakListRow[] rows = peakList.getRows();
Arrays.sort(rows, new PeakListRowSorter(SortingProperty.Area, SortingDirection.Descending));
// Initialize counters.
numItems = rows.length;
// Process rows.
for (finishedItems = 0; !isCanceled() && finishedItems < numItems; finishedItems++) {
// Retrieve results for each row.
retrieveIdentification(rows[finishedItems]);
}
if (!isCanceled()) {
setStatus(TaskStatus.FINISHED);
}
} catch (Throwable t) {
final String msg = "Could not search " + db;
LOG.log(Level.WARNING, msg, t);
setStatus(TaskStatus.ERROR);
setErrorMessage(msg + ": " + ExceptionUtils.exceptionToString(t));
}
}
}
use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class IntensityPlotParameters method showSetupDialog.
@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
PeakList[] selectedPeakLists = getParameter(peakList).getValue().getMatchingPeakLists();
if (selectedPeakLists.length > 0) {
RawDataFile[] plDataFiles = selectedPeakLists[0].getRawDataFiles();
PeakListRow[] plRows = selectedPeakLists[0].getRows();
Arrays.sort(plRows, new PeakListRowSorter(SortingProperty.MZ, SortingDirection.Ascending));
getParameter(dataFiles).setChoices(plDataFiles);
getParameter(dataFiles).setValue(plDataFiles);
}
return super.showSetupDialog(parent, valueCheckRequired);
}
use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class KendrickMassPlotParameters method showSetupDialog.
@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
PeakList[] selectedPeakLists = getParameter(peakList).getValue().getMatchingPeakLists();
if (selectedPeakLists.length > 0) {
PeakListRow[] plRows = selectedPeakLists[0].getRows();
Arrays.sort(plRows, new PeakListRowSorter(SortingProperty.MZ, SortingDirection.Ascending));
}
return super.showSetupDialog(parent, valueCheckRequired);
}
Aggregations