Search in sources :

Example 61 with DataPoint

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

the class MsMsDataSet method highlightSpectra.

/**
 * Highlights all MS/MS spots for which a peak is found in the MS/MS spectrum with the m/z value
 *
 * @param mz m/z.
 * @param ppm ppm value.
 * @param neutralLoss true or false.
 * @param c color.
 */
public void highlightSpectra(double mz, MZTolerance searchMZTolerance, double minIntensity, boolean neutralLoss, Color c) {
    // mzRange
    searchMZTolerance.getToleranceRange(mz);
    Range<Double> precursorMZRange = searchMZTolerance.getToleranceRange(mz);
    // Loop through all scans
    for (int row = 0; row < scanNumbers.length; row++) {
        Scan msscan = rawDataFile.getScan(scanNumbers[row]);
        // Get total intensity of all peaks in MS/MS scan
        if (scanNumbers[row] > 0) {
            DataPoint[] scanDataPoints = msscan.getDataPoints();
            double[] selectedIons = new double[scanDataPoints.length];
            int ions = 0;
            boolean colorSpectra = false;
            // Search for neutral loss in ms/ms spectrum
            if (neutralLoss) {
                for (int x = 0; x < scanDataPoints.length; x++) {
                    if (scanDataPoints[x].getIntensity() > minIntensity) {
                        selectedIons[ions] = scanDataPoints[x].getMZ();
                        ions++;
                    }
                }
                if (ions > 1) {
                    double[][] ionDiff = new double[ions][ions];
                    for (int x = 0; x < ions; x++) {
                        for (int y = 0; y < ions; y++) {
                            ionDiff[x][y] = Math.abs(selectedIons[x] - selectedIons[y]);
                        }
                    }
                    for (int x = 0; x < ions; x++) {
                        for (int y = 0; y < ions; y++) {
                            if (precursorMZRange.contains(ionDiff[x][y])) {
                                colorSpectra = true;
                                break;
                            }
                        }
                    }
                }
            } else // Search for specific ion in ms/ms spectrum
            {
                for (int x = 0; x < scanDataPoints.length; x++) {
                    if (precursorMZRange.contains(scanDataPoints[x].getMZ()) && scanDataPoints[x].getIntensity() > minIntensity) {
                        colorSpectra = true;
                        break;
                    }
                }
            }
            if (colorSpectra) {
                // If color is red green or blue then use toning from
                // current color
                int rgb = getColor(0, row).getRed();
                if (c == Color.red) {
                    setColor(0, row, new Color(255, rgb, rgb));
                } else if (c == Color.green) {
                    setColor(0, row, new Color(rgb, 255, rgb));
                } else if (c == Color.blue) {
                    setColor(0, row, new Color(rgb, rgb, 255));
                } else {
                    setColor(0, row, c);
                }
            }
        }
    }
    fireDatasetChanged();
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) Color(java.awt.Color) Scan(net.sf.mzmine.datamodel.Scan) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 62 with DataPoint

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

the class MsMsDataSet method run.

@Override
public void run() {
    status = TaskStatus.PROCESSING;
    double totalScanIntensity, maxPeakIntensity;
    for (int index = 0; index < totalScans; index++) {
        // Cancel?
        if (status == TaskStatus.CANCELED)
            return;
        Scan scan = rawDataFile.getScan(allScanNumbers[index]);
        if (scan.getMSLevel() == 1) {
            // Store info about MS spectra for MS/MS to allow extraction of
            // intensity of precursor ion in MS scan.
            lastMSIndex = index;
        } else {
            // Precursor m/z
            Double precursorMZ = scan.getPrecursorMZ();
            // value
            // Scan RT
            Double scanRT = scan.getRetentionTime();
            // Calculate total intensity
            totalScanIntensity = 0;
            if (intensityType == IntensityType.MS) {
                // Get intensity of precursor ion from MS scan
                Scan msscan = rawDataFile.getScan(allScanNumbers[lastMSIndex]);
                Double mzTolerance = precursorMZ * 10 / 1000000;
                Range<Double> precursorMZRange = Range.closed(precursorMZ - mzTolerance, precursorMZ + mzTolerance);
                DataPoint[] scanDataPoints = msscan.getDataPointsByMass(precursorMZRange);
                for (int x = 0; x < scanDataPoints.length; x++) {
                    totalScanIntensity = totalScanIntensity + scanDataPoints[x].getIntensity();
                }
            } else if (intensityType == IntensityType.MSMS) {
                // Get total intensity of all peaks in MS/MS scan
                DataPoint[] scanDataPoints = scan.getDataPoints();
                for (int x = 0; x < scanDataPoints.length; x++) {
                    totalScanIntensity = totalScanIntensity + scanDataPoints[x].getIntensity();
                }
            }
            maxPeakIntensity = 0;
            DataPoint[] scanDataPoints = scan.getDataPoints();
            for (int x = 0; x < scanDataPoints.length; x++) {
                if (maxPeakIntensity < scanDataPoints[x].getIntensity()) {
                    maxPeakIntensity = scanDataPoints[x].getIntensity();
                }
            }
            if (totalRTRange.contains(scanRT) && totalMZRange.contains(precursorMZ) && maxPeakIntensity > minPeakInt) {
                // Add values to arrays
                rtValues[processedScans] = scanRT;
                mzValues[processedScans] = precursorMZ;
                intensityValues[processedScans] = totalScanIntensity;
                // +1 because loop
                scanNumbers[processedScans] = index + 1;
                // runs from 0 not
                // 1
                processedScans++;
            }
        }
        allProcessedScans++;
    }
    // Update max Z values
    for (int row = 0; row < totalmsmsScans; row++) {
        if (maxIntensity < intensityValues[row]) {
            maxIntensity = intensityValues[row];
        }
    }
    // Update color table for all spots
    totalEntries = processedScans - 1;
    for (int index = 0; index < processedScans - 1; index++) {
        // Cancel?
        if (status == TaskStatus.CANCELED)
            return;
        double maxIntensityVal = 1;
        if (normalizationType == NormalizationType.all) {
            // Normalize based on all m/z values
            maxIntensityVal = maxIntensity;
        } else if (normalizationType == NormalizationType.similar) {
            // Normalize based on similar m/z values
            double precursorMZ = mzValues[index];
            Double mzTolerance = precursorMZ * 10 / 1000000;
            Range<Double> precursorMZRange = Range.closed(precursorMZ - mzTolerance, precursorMZ + mzTolerance);
            maxIntensityVal = (double) getMaxZ(precursorMZRange);
        }
        // Calculate normalized intensity
        double normIntensity = intensityValues[index] / maxIntensityVal;
        if (normIntensity > 1) {
            normIntensity = 1;
        }
        // Convert normIntensity into gray color tone
        // RGB tones go from 0 to 255 - we limit it to 220 to not include
        // too light colors
        int rgbVal = (int) Math.round(220 - normIntensity * 220);
        // Update color table
        colorValues[index] = new Color(rgbVal, rgbVal, rgbVal);
        processedColors++;
    }
    fireDatasetChanged();
    status = TaskStatus.FINISHED;
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) Color(java.awt.Color) Scan(net.sf.mzmine.datamodel.Scan) Range(com.google.common.collect.Range) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 63 with DataPoint

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

the class IsotopePatternUtils method checkOverlappingIsotopes.

public static IsotopePattern checkOverlappingIsotopes(IsotopePattern pattern, IIsotope[] isotopes, double mergeWidth, double minAbundance) {
    DataPoint[] dp = pattern.getDataPoints();
    double basemz = dp[0].getMZ();
    List<DataPoint> newPeaks = new ArrayList<DataPoint>();
    double isotopeBaseMass = 0d;
    for (IIsotope isotope : isotopes) {
        if (isotope.getNaturalAbundance() > minAbundance) {
            isotopeBaseMass = isotope.getExactMass();
            logger.info("isotopeBaseMass of " + isotope.getSymbol() + " = " + isotopeBaseMass);
            break;
        }
    }
    // loop all new isotopes
    for (IIsotope isotope : isotopes) {
        if (isotope.getNaturalAbundance() < minAbundance)
            continue;
        // the difference added by the heavier isotope peak
        double possiblemzdiff = isotope.getExactMass() - isotopeBaseMass;
        if (possiblemzdiff < 0.000001)
            continue;
        boolean add = true;
        for (DataPoint patternDataPoint : dp) {
            // here check for every peak in the pattern, if a new peak would overlap
            // if it overlaps good, we dont need to add a new peak
            int i = 1;
            do {
                if (Math.abs(patternDataPoint.getMZ() * i - possiblemzdiff) <= mergeWidth) {
                    // TODO: maybe we should do a average of the masses? i can'T say if it makes sense,
                    // since
                    // we're just looking for isotope mass differences and dont look at the total
                    // composition,
                    // so we dont know the intensity ratios
                    logger.info("possible overlap found: " + i + " * pattern dp = " + patternDataPoint.getMZ() + "\toverlaps with " + isotope.getMassNumber() + isotope.getSymbol() + " (" + (isotopeBaseMass - isotope.getExactMass()) + ")\tdiff: " + Math.abs(patternDataPoint.getMZ() * i - possiblemzdiff));
                    add = false;
                }
                i++;
            // logger.info("do");
            } while (patternDataPoint.getMZ() * i <= possiblemzdiff + mergeWidth && patternDataPoint.getMZ() != 0.0);
        }
        if (add)
            newPeaks.add(new SimpleDataPoint(possiblemzdiff, 1));
    }
    // DataPoint[] newDataPoints = new SimpleDataPoint[dp.length + newPeaks.size()];
    for (DataPoint p : dp) {
        newPeaks.add(p);
    }
    newPeaks.sort((o1, o2) -> {
        return Double.compare(o1.getMZ(), o2.getMZ());
    });
    return new SimpleIsotopePattern(newPeaks.toArray(new DataPoint[0]), IsotopePatternStatus.PREDICTED, "");
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) ArrayList(java.util.ArrayList) SimpleIsotopePattern(net.sf.mzmine.datamodel.impl.SimpleIsotopePattern) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)

Example 64 with DataPoint

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

the class PeptideUtils method getIonCoverage.

/**
 * Returns the coverage of the ion series.
 *
 * @param dataPoints
 * @param peptide
 * @param ionType
 * @param intensityThreshold
 * @return
 */
public static double getIonCoverage(DataPoint[] dataPoints, Peptide peptide, SerieIonType ionType, double intensityThreshold) {
    PeptideFragmentation fragmentation = peptide.getFragmentation();
    FragmentIon[] fragmentIons = fragmentation.getFragmentIons(ionType);
    PeptideIdentityDataFile peptideDataFile = peptide.getScan().getPeptideDataFile();
    double fragmentIonMassErrorTol = peptideDataFile.getFragmentIonMassErrorTolerance();
    DataPoint[] matchedDataPoints = getMatchedIons(dataPoints, fragmentIons, fragmentIonMassErrorTol, intensityThreshold);
    double ionCoverage = calculateSerieCoverage(matchedDataPoints, fragmentIons);
    return ionCoverage;
}
Also used : FragmentIon(net.sf.mzmine.modules.peaklistmethods.identification.mascot.data.FragmentIon) PeptideIdentityDataFile(net.sf.mzmine.modules.peaklistmethods.identification.mascot.data.PeptideIdentityDataFile) DataPoint(net.sf.mzmine.datamodel.DataPoint) PeptideFragmentation(net.sf.mzmine.modules.peaklistmethods.identification.mascot.data.PeptideFragmentation)

Example 65 with DataPoint

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

the class Gap method offerNextScan.

public void offerNextScan(Scan scan) {
    double scanRT = scan.getRetentionTime();
    // If not yet inside the RT range
    if (scanRT < rtRange.lowerEndpoint())
        return;
    // If we have passed the RT range and finished processing last peak
    if ((scanRT > rtRange.upperEndpoint()) && (currentPeakDataPoints == null))
        return;
    // Find top m/z peak in our range
    DataPoint basePeak = ScanUtils.findBasePeak(scan, mzRange);
    GapDataPoint currentDataPoint;
    if (basePeak != null) {
        currentDataPoint = new GapDataPoint(scan.getScanNumber(), basePeak.getMZ(), scanRT, basePeak.getIntensity());
    } else {
        currentDataPoint = new GapDataPoint(scan.getScanNumber(), RangeUtils.rangeCenter(mzRange), scanRT, 0);
    }
    // If we have not yet started, just create a new peak
    if (currentPeakDataPoints == null) {
        currentPeakDataPoints = new Vector<GapDataPoint>();
        currentPeakDataPoints.add(currentDataPoint);
        return;
    }
    // Check if this continues previous peak?
    if (checkRTShape(currentDataPoint)) {
        // Yes, continue this peak.
        currentPeakDataPoints.add(currentDataPoint);
    } else {
        // Check peak formed so far
        if (currentPeakDataPoints != null) {
            checkCurrentPeak();
            currentPeakDataPoints = null;
        }
    }
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)214 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)98 Scan (net.sf.mzmine.datamodel.Scan)64 ArrayList (java.util.ArrayList)50 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)44 Feature (net.sf.mzmine.datamodel.Feature)27 MassList (net.sf.mzmine.datamodel.MassList)24 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)22 IOException (java.io.IOException)20 SimpleScan (net.sf.mzmine.datamodel.impl.SimpleScan)18 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)17 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)16 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)15 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)15 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)12 DataPointSorter (net.sf.mzmine.util.DataPointSorter)12 HashMap (java.util.HashMap)10 Vector (java.util.Vector)10 Range (com.google.common.collect.Range)8 TreeMap (java.util.TreeMap)8