Search in sources :

Example 16 with PeakListRowSorter

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));
        }
    }
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) PeakListRowSorter(net.sf.mzmine.util.PeakListRowSorter)

Example 17 with PeakListRowSorter

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;
}
Also used : PeakListRowSorter(net.sf.mzmine.util.PeakListRowSorter) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) XYPlot(org.jfree.chart.plot.XYPlot) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) PeakList(net.sf.mzmine.datamodel.PeakList) Vector(java.util.Vector)

Example 18 with PeakListRowSorter

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;
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) PeakList(net.sf.mzmine.datamodel.PeakList) Vector(java.util.Vector) PeakListRowSorter(net.sf.mzmine.util.PeakListRowSorter)

Aggregations

PeakListRowSorter (net.sf.mzmine.util.PeakListRowSorter)18 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)16 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)10 PeakList (net.sf.mzmine.datamodel.PeakList)6 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)5 Feature (net.sf.mzmine.datamodel.Feature)3 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)3 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)3 ArrayList (java.util.ArrayList)2 Vector (java.util.Vector)2 DataPoint (net.sf.mzmine.datamodel.DataPoint)2 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)2 Desktop (net.sf.mzmine.desktop.Desktop)2 HeadLessDesktop (net.sf.mzmine.desktop.impl.HeadLessDesktop)2 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)1 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)1 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)1 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)1 Candidates (net.sf.mzmine.modules.peaklistmethods.isotopes.isotopepeakscanner.Candidates)1