Search in sources :

Example 11 with Feature

use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.

the class SimplePeakList method getPeaksInsideScanAndMZRange.

/**
 * @see net.sf.mzmine.datamodel.PeakList#getPeaksInsideScanAndMZRange(double, double, double,
 *      double)
 */
@Override
public Feature[] getPeaksInsideScanAndMZRange(RawDataFile file, Range<Double> rtRange, Range<Double> mzRange) {
    Vector<Feature> peaksInside = new Vector<Feature>();
    Feature[] peaks = getPeaks(file);
    for (Feature p : peaks) {
        if (rtRange.contains(p.getRT()) && mzRange.contains(p.getMZ()))
            peaksInside.add(p);
    }
    return peaksInside.toArray(new Feature[0]);
}
Also used : Feature(net.sf.mzmine.datamodel.Feature) Vector(java.util.Vector)

Example 12 with Feature

use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.

the class SimplePeakListRow method calculateAverageValues.

private synchronized void calculateAverageValues() {
    double rtSum = 0, mzSum = 0, heightSum = 0, areaSum = 0;
    int charge = 0;
    HashSet<Integer> chargeArr = new HashSet<Integer>();
    Enumeration<Feature> peakEnum = peaks.elements();
    while (peakEnum.hasMoreElements()) {
        Feature p = peakEnum.nextElement();
        rtSum += p.getRT();
        mzSum += p.getMZ();
        heightSum += p.getHeight();
        areaSum += p.getArea();
        if (p.getCharge() > 0) {
            chargeArr.add(p.getCharge());
            charge = p.getCharge();
        }
    }
    averageRT = rtSum / peaks.size();
    averageMZ = mzSum / peaks.size();
    averageHeight = heightSum / peaks.size();
    averageArea = areaSum / peaks.size();
    if (chargeArr.size() < 2) {
        rowCharge = charge;
    } else {
        rowCharge = 0;
    }
}
Also used : Feature(net.sf.mzmine.datamodel.Feature) HashSet(java.util.HashSet)

Example 13 with Feature

use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.

the class SimplePeakListRow method getBestIsotopePattern.

/**
 * Returns the highest isotope pattern of a peak in this row
 */
@Override
public IsotopePattern getBestIsotopePattern() {
    Feature[] peaks = getPeaks();
    Arrays.sort(peaks, new PeakSorter(SortingProperty.Height, SortingDirection.Descending));
    for (Feature peak : peaks) {
        IsotopePattern ip = peak.getIsotopePattern();
        if (ip != null)
            return ip;
    }
    return null;
}
Also used : PeakSorter(net.sf.mzmine.util.PeakSorter) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) Feature(net.sf.mzmine.datamodel.Feature)

Example 14 with Feature

use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.

the class SimplePeakListRow method getBestPeak.

/**
 * Returns the highest peak in this row
 */
@Override
public Feature getBestPeak() {
    Feature[] peaks = getPeaks();
    Arrays.sort(peaks, new PeakSorter(SortingProperty.Height, SortingDirection.Descending));
    if (peaks.length == 0)
        return null;
    return peaks[0];
}
Also used : PeakSorter(net.sf.mzmine.util.PeakSorter) Feature(net.sf.mzmine.datamodel.Feature)

Example 15 with Feature

use of net.sf.mzmine.datamodel.Feature in project mzmine2 by mzmine.

the class ADAP3DecompositionV1_5Task method getPeaks.

/**
 * Convert MZmine PeakList to a list of ADAP Peaks
 *
 * @param peakList MZmine PeakList object
 * @param edgeToHeightThreshold edge-to-height threshold to determine peaks that can be merged
 * @param deltaToHeightThreshold delta-to-height threshold to determine peaks that can be merged
 * @return list of ADAP Peaks
 */
@Nonnull
public static List<Peak> getPeaks(final PeakList peakList, final double edgeToHeightThreshold, final double deltaToHeightThreshold) {
    RawDataFile dataFile = peakList.getRawDataFile(0);
    List<Peak> peaks = new ArrayList<>();
    for (PeakListRow row : peakList.getRows()) {
        Feature peak = row.getBestPeak();
        int[] scanNumbers = peak.getScanNumbers();
        // Build chromatogram
        NavigableMap<Double, Double> chromatogram = new TreeMap<>();
        for (int scanNumber : scanNumbers) {
            DataPoint dataPoint = peak.getDataPoint(scanNumber);
            if (dataPoint != null)
                chromatogram.put(dataFile.getScan(scanNumber).getRetentionTime(), dataPoint.getIntensity());
        }
        if (chromatogram.size() <= 1)
            continue;
        // Fill out PeakInfo
        PeakInfo info = new PeakInfo();
        try {
            // Note: info.peakID is the index of PeakListRow in PeakList.peakListRows (starts from 0)
            // row.getID is row.myID (starts from 1)
            info.peakID = row.getID() - 1;
            double height = -Double.MIN_VALUE;
            for (int scan : scanNumbers) {
                double intensity = peak.getDataPoint(scan).getIntensity();
                if (intensity > height) {
                    height = intensity;
                    info.peakIndex = scan;
                }
            }
            info.leftApexIndex = scanNumbers[0];
            info.rightApexIndex = scanNumbers[scanNumbers.length - 1];
            info.retTime = peak.getRT();
            info.mzValue = peak.getMZ();
            info.intensity = peak.getHeight();
            info.leftPeakIndex = info.leftApexIndex;
            info.rightPeakIndex = info.rightApexIndex;
        } catch (Exception e) {
            LOG.info("Skipping " + row + ": " + e.getMessage());
            continue;
        }
        peaks.add(new Peak(chromatogram, info));
    }
    FeatureTools.correctPeakBoundaries(peaks, edgeToHeightThreshold, deltaToHeightThreshold);
    return peaks;
}
Also used : ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Feature(net.sf.mzmine.datamodel.Feature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) PeakInfo(dulab.adap.datamodel.PeakInfo) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) IOException(java.io.IOException) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) Peak(dulab.adap.datamodel.Peak) Nonnull(javax.annotation.Nonnull)

Aggregations

Feature (net.sf.mzmine.datamodel.Feature)115 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)70 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)60 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)41 DataPoint (net.sf.mzmine.datamodel.DataPoint)35 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)35 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)25 Scan (net.sf.mzmine.datamodel.Scan)22 PeakList (net.sf.mzmine.datamodel.PeakList)20 ArrayList (java.util.ArrayList)17 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)16 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)15 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)15 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)13 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)10 MassList (net.sf.mzmine.datamodel.MassList)9 HashMap (java.util.HashMap)8 Vector (java.util.Vector)8 ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)7 TreeMap (java.util.TreeMap)6