Search in sources :

Example 11 with SimpleFeature

use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.

the class PeakLearnerTask method copyPeakRow.

/**
 * Create a copy of a feature list row.
 *
 * @param row the row to copy.
 * @return the newly created copy.
 */
private static PeakListRow copyPeakRow(final PeakListRow row) {
    // Copy the feature list row.
    final PeakListRow newRow = new SimplePeakListRow(row.getID());
    PeakUtils.copyPeakListRowProperties(row, newRow);
    // Copy the peaks.
    for (final Feature peak : row.getPeaks()) {
        final Feature newPeak = new SimpleFeature(peak);
        PeakUtils.copyPeakProperties(peak, newPeak);
        newRow.addPeak(peak.getDataFile(), newPeak);
    }
    return newRow;
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) Feature(net.sf.mzmine.datamodel.Feature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature)

Example 12 with SimpleFeature

use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.

the class NeutralLossFilterTask method copyPeakRow.

/**
 * Create a copy of a feature list row.
 *
 * @param row the row to copy.
 * @return the newly created copy.
 */
private static PeakListRow copyPeakRow(final PeakListRow row) {
    // Copy the feature list row.
    final PeakListRow newRow = new SimplePeakListRow(row.getID());
    PeakUtils.copyPeakListRowProperties(row, newRow);
    // Copy the peaks.
    for (final Feature peak : row.getPeaks()) {
        final Feature newPeak = new SimpleFeature(peak);
        PeakUtils.copyPeakProperties(peak, newPeak);
        newRow.addPeak(peak.getDataFile(), newPeak);
    }
    return newRow;
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) Feature(net.sf.mzmine.datamodel.Feature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature)

Example 13 with SimpleFeature

use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.

the class PeakFilterTask method copyPeakRow.

/**
 * Create a copy of a feature list row.
 */
private static PeakListRow copyPeakRow(final PeakListRow row, final boolean[] keepPeak) {
    // Copy the feature list row.
    final PeakListRow newRow = new SimplePeakListRow(row.getID());
    PeakUtils.copyPeakListRowProperties(row, newRow);
    // Copy the peaks.
    int i = 0;
    for (final Feature peak : row.getPeaks()) {
        // Only keep peak if it fulfills the filter criteria
        if (keepPeak[i]) {
            final Feature newPeak = new SimpleFeature(peak);
            PeakUtils.copyPeakProperties(peak, newPeak);
            newRow.addPeak(peak.getDataFile(), newPeak);
        }
        i++;
    }
    return newRow;
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) Feature(net.sf.mzmine.datamodel.Feature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature)

Example 14 with SimpleFeature

use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.

the class RowsFilterTask method copyPeakRow.

/**
 * Create a copy of a feature list row.
 *
 * @param row the row to copy.
 * @return the newly created copy.
 */
private static PeakListRow copyPeakRow(final PeakListRow row) {
    // Copy the feature list row.
    final PeakListRow newRow = new SimplePeakListRow(row.getID());
    PeakUtils.copyPeakListRowProperties(row, newRow);
    // Copy the peaks.
    for (final Feature peak : row.getPeaks()) {
        final Feature newPeak = new SimpleFeature(peak);
        PeakUtils.copyPeakProperties(peak, newPeak);
        newRow.addPeak(peak.getDataFile(), newPeak);
    }
    // Add PeakInformation
    if (row.getPeakInformation() != null) {
        SimplePeakInformation information = new SimplePeakInformation(new HashMap<>(row.getPeakInformation().getAllProperties()));
        newRow.setPeakInformation(information);
    }
    return newRow;
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) Feature(net.sf.mzmine.datamodel.Feature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) SimplePeakInformation(net.sf.mzmine.datamodel.impl.SimplePeakInformation)

Example 15 with SimpleFeature

use of net.sf.mzmine.datamodel.impl.SimpleFeature in project mzmine2 by mzmine.

the class Gap method noMoreOffers.

/**
 * Finalizes the gap, adds a peak
 *
 * @param lock A lock for multi threading purpose. null if single threaded
 */
public void noMoreOffers() {
    // Check peak that was last constructed
    if (currentPeakDataPoints != null) {
        checkCurrentPeak();
        currentPeakDataPoints = null;
    }
    // If we have best peak candidate, construct a SimpleChromatographicPeak
    if (bestPeakDataPoints != null) {
        double area = 0, height = 0, mz = 0, rt = 0;
        int[] scanNumbers = new int[bestPeakDataPoints.size()];
        DataPoint[] finalDataPoint = new DataPoint[bestPeakDataPoints.size()];
        Range<Double> finalRTRange = null, finalMZRange = null, finalIntensityRange = null;
        int representativeScan = 0;
        // Process all datapoints
        for (int i = 0; i < bestPeakDataPoints.size(); i++) {
            GapDataPoint dp = bestPeakDataPoints.get(i);
            if (i == 0) {
                finalRTRange = Range.singleton(dp.getRT());
                finalMZRange = Range.singleton(dp.getMZ());
                finalIntensityRange = Range.singleton(dp.getIntensity());
            } else {
                assert finalRTRange != null && finalMZRange != null && finalIntensityRange != null;
                finalRTRange = finalRTRange.span(Range.singleton(dp.getRT()));
                finalMZRange = finalMZRange.span(Range.singleton(dp.getMZ()));
                finalIntensityRange = finalIntensityRange.span(Range.singleton(dp.getIntensity()));
            }
            scanNumbers[i] = bestPeakDataPoints.get(i).getScanNumber();
            finalDataPoint[i] = new SimpleDataPoint(dp.getMZ(), dp.getIntensity());
            mz += bestPeakDataPoints.get(i).getMZ();
            // Check height
            if (bestPeakDataPoints.get(i).getIntensity() > height) {
                height = bestPeakDataPoints.get(i).getIntensity();
                rt = bestPeakDataPoints.get(i).getRT();
                representativeScan = bestPeakDataPoints.get(i).getScanNumber();
            }
            // Skip last data point
            if (i == bestPeakDataPoints.size() - 1)
                break;
            // X axis interval length
            double rtDifference = (bestPeakDataPoints.get(i + 1).getRT() - bestPeakDataPoints.get(i).getRT()) * 60d;
            // intensity at the beginning and end of the interval
            double intensityStart = bestPeakDataPoints.get(i).getIntensity();
            double intensityEnd = bestPeakDataPoints.get(i + 1).getIntensity();
            // calculate area of the interval
            area += (rtDifference * (intensityStart + intensityEnd) / 2);
        }
        // Calculate average m/z value
        mz /= bestPeakDataPoints.size();
        // Find the best fragmentation scan, if available
        int fragmentScan = ScanUtils.findBestFragmentScan(rawDataFile, finalRTRange, finalMZRange);
        // Find all MS2 level scans
        int[] allMS2FragmentScanNumbers = ScanUtils.findAllMS2FragmentScans(rawDataFile, finalRTRange, finalMZRange);
        SimpleFeature newPeak = new SimpleFeature(rawDataFile, mz, rt, height, area, scanNumbers, finalDataPoint, FeatureStatus.ESTIMATED, representativeScan, fragmentScan, allMS2FragmentScanNumbers, finalRTRange, finalMZRange, finalIntensityRange);
        // Fill the gap
        peakListRow.addPeak(rawDataFile, newPeak);
    }
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature)

Aggregations

SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)28 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)21 Feature (net.sf.mzmine.datamodel.Feature)20 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)20 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)12 DataPoint (net.sf.mzmine.datamodel.DataPoint)11 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)10 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)7 Scan (net.sf.mzmine.datamodel.Scan)6 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)6 FeatureStatus (net.sf.mzmine.datamodel.Feature.FeatureStatus)5 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)5 IOException (java.io.IOException)4 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)4 SimplePeakIdentity (net.sf.mzmine.datamodel.impl.SimplePeakIdentity)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 DataInputStream (java.io.DataInputStream)3 ArrayList (java.util.ArrayList)3 SimplePeakInformation (net.sf.mzmine.datamodel.impl.SimplePeakInformation)3 SAXException (org.xml.sax.SAXException)3