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);
// 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 (int index = 0; !isCanceled() && index < numItems; ) {
try {
semaphore.acquire();
logger.debug("Semaphore ACQUIRED");
Thread th = new Thread(new SiriusThread(rows[index++], parameters, semaphore, latch, this));
th.setDaemon(true);
th.start();
} catch (InterruptedException e) {
logger.error("The thread was interrupted");
}
}
if (isCanceled())
return;
// Wait till all rows are processed
latch.await();
if (!isCanceled()) {
setStatus(TaskStatus.FINISHED);
}
} catch (Throwable t) {
final String msg = "Could not search ";
logger.warn(msg, t);
setStatus(TaskStatus.ERROR);
setErrorMessage(msg + ": " + ExceptionUtils.exceptionToString(t));
}
}
}
use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class MsMsBottomPanel method getTopThresholdPeakList.
/**
* Returns a feature list with the top peaks defined by the parameter "threshold"
*/
PeakList getTopThresholdPeakList(int threshold) {
PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem();
if (selectedPeakList == null)
return null;
SimplePeakList newList = new SimplePeakList(selectedPeakList.getName(), selectedPeakList.getRawDataFiles());
Vector<PeakListRow> peakRows = new Vector<PeakListRow>();
Range<Double> mzRange = selectedPeakList.getRowsMZRange();
Range<Double> rtRange = selectedPeakList.getRowsRTRange();
PeakThresholdMode selectedPeakOption = (PeakThresholdMode) thresholdCombo.getSelectedItem();
if (selectedPeakOption == PeakThresholdMode.TOP_PEAKS_AREA) {
XYPlot xyPlot = masterFrame.getPlot().getXYPlot();
org.jfree.data.Range yAxis = xyPlot.getRangeAxis().getRange();
org.jfree.data.Range xAxis = xyPlot.getDomainAxis().getRange();
rtRange = Range.closed(xAxis.getLowerBound(), xAxis.getUpperBound());
mzRange = Range.closed(yAxis.getLowerBound(), yAxis.getUpperBound());
}
for (PeakListRow peakRow : selectedPeakList.getRows()) {
if (mzRange.contains(peakRow.getAverageMZ()) && rtRange.contains(peakRow.getAverageRT())) {
peakRows.add(peakRow);
}
}
Collections.sort(peakRows, new PeakListRowSorter(SortingProperty.Intensity, SortingDirection.Descending));
if (threshold > peakRows.size())
threshold = peakRows.size();
for (int i = 0; i < threshold; i++) {
newList.addRow(peakRows.elementAt(i));
}
return newList;
}
use of net.sf.mzmine.util.PeakListRowSorter in project mzmine2 by mzmine.
the class TwoDBottomPanel method getTopThresholdPeakList.
/**
* Returns a feature list with the top peaks defined by the parameter "threshold"
*/
PeakList getTopThresholdPeakList(int threshold) {
PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem();
if (selectedPeakList == null)
return null;
SimplePeakList newList = new SimplePeakList(selectedPeakList.getName(), selectedPeakList.getRawDataFiles());
Vector<PeakListRow> peakRows = new Vector<PeakListRow>();
Range<Double> mzRange = selectedPeakList.getRowsMZRange();
Range<Double> rtRange = selectedPeakList.getRowsRTRange();
PeakThresholdMode selectedPeakOption = (PeakThresholdMode) thresholdCombo.getSelectedItem();
if (selectedPeakOption == PeakThresholdMode.TOP_PEAKS_AREA) {
mzRange = masterFrame.getPlot().getXYPlot().getAxisRange();
rtRange = masterFrame.getPlot().getXYPlot().getDomainRange();
}
for (PeakListRow peakRow : selectedPeakList.getRows()) {
if (mzRange.contains(peakRow.getAverageMZ()) && rtRange.contains(peakRow.getAverageRT())) {
peakRows.add(peakRow);
}
}
Collections.sort(peakRows, new PeakListRowSorter(SortingProperty.Intensity, SortingDirection.Descending));
if (threshold > peakRows.size())
threshold = peakRows.size();
for (int i = 0; i < threshold; i++) {
newList.addRow(peakRows.elementAt(i));
}
return newList;
}
Aggregations