Search in sources :

Example 36 with SimplePeakListRow

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

the class PeakListOpenHandler_2_3 method startElement.

/**
 * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String,
 *      java.lang.String, org.xml.sax.Attributes)
 */
@Override
public void startElement(String namespaceURI, String lName, String qName, Attributes attrs) throws SAXException {
    if (canceled)
        throw new SAXException("Parsing canceled");
    // This will remove any remaining characters from previous elements
    getTextOfElement();
    // <ROW>
    if (qName.equals(PeakListElementName_2_3.ROW.getElementName())) {
        if (buildingPeakList == null) {
            initializePeakList();
        }
        int rowID = Integer.parseInt(attrs.getValue(PeakListElementName_2_3.ID.getElementName()));
        buildingRow = new SimplePeakListRow(rowID);
        String comment = attrs.getValue(PeakListElementName_2_3.COMMENT.getElementName());
        buildingRow.setComment(comment);
    }
    // <PEAK_IDENTITY>
    if (qName.equals(PeakListElementName_2_3.PEAK_IDENTITY.getElementName())) {
        identityProperties = new Hashtable<String, String>();
        preferred = Boolean.parseBoolean(attrs.getValue(PeakListElementName_2_3.PREFERRED.getElementName()));
    }
    // <IDENTITY_PROPERTY>
    if (qName.equals(PeakListElementName_2_3.IDPROPERTY.getElementName())) {
        identityPropertyName = attrs.getValue(PeakListElementName_2_3.NAME.getElementName());
    }
    // <PEAK>
    if (qName.equals(PeakListElementName_2_3.PEAK.getElementName())) {
        peakColumnID = attrs.getValue(PeakListElementName_2_3.COLUMN.getElementName());
        mass = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.MZ.getElementName()));
        // Before MZmine 2.6 retention time was saved in seconds, but now we
        // use minutes, so we need to divide by 60
        rt = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.RT.getElementName())) / 60d;
        height = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.HEIGHT.getElementName()));
        area = Double.parseDouble(attrs.getValue(PeakListElementName_2_3.AREA.getElementName()));
        peakStatus = attrs.getValue(PeakListElementName_2_3.STATUS.getElementName());
        String chargeString = attrs.getValue(PeakListElementName_2_3.CHARGE.getElementName());
        if (chargeString != null)
            currentPeakCharge = Integer.valueOf(chargeString);
        else
            currentPeakCharge = 0;
    }
    // <MZPEAK>
    if (qName.equals(PeakListElementName_2_3.MZPEAKS.getElementName())) {
        numOfMZpeaks = Integer.parseInt(attrs.getValue(PeakListElementName_2_3.QUANTITY.getElementName()));
    }
    // <ISOTOPE_PATTERN>
    if (qName.equals(PeakListElementName_2_3.ISOTOPE_PATTERN.getElementName())) {
        currentIsotopes.clear();
        currentIsotopePatternStatus = IsotopePatternStatus.valueOf(attrs.getValue(PeakListElementName_2_3.STATUS.getElementName()));
        currentIsotopePatternDescription = attrs.getValue(PeakListElementName_2_3.DESCRIPTION.getElementName());
    }
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) SAXException(org.xml.sax.SAXException)

Example 37 with SimplePeakListRow

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

the class DeconvolutionTask method resolvePeaks.

/**
 * Deconvolve a chromatogram into separate peaks.
 *
 * @param peakList holds the chromatogram to deconvolve.
 * @param mzCenterFunction2
 * @return a new feature list holding the resolved peaks.
 * @throws RSessionWrapperException
 */
private PeakList resolvePeaks(final PeakList peakList, RSessionWrapper rSession) throws RSessionWrapperException {
    // Get data file information.
    final RawDataFile dataFile = peakList.getRawDataFile(0);
    // Peak resolver.
    final MZmineProcessingStep<PeakResolver> resolver = parameters.getParameter(PEAK_RESOLVER).getValue();
    // set msms pairing range
    this.setMSMSRange = parameters.getParameter(mzRangeMSMS).getValue();
    if (setMSMSRange)
        this.msmsRange = parameters.getParameter(mzRangeMSMS).getEmbeddedParameter().getValue();
    else
        this.msmsRange = 0;
    this.setMSMSRT = parameters.getParameter(RetentionTimeMSMS).getValue();
    if (setMSMSRT)
        this.RTRangeMSMS = parameters.getParameter(RetentionTimeMSMS).getEmbeddedParameter().getValue();
    else
        this.RTRangeMSMS = 0;
    // Create new feature list.
    final PeakList resolvedPeaks = new SimplePeakList(peakList + " " + parameters.getParameter(SUFFIX).getValue(), dataFile);
    // Load previous applied methods.
    for (final PeakListAppliedMethod method : peakList.getAppliedMethods()) {
        resolvedPeaks.addDescriptionOfAppliedTask(method);
    }
    // Add task description to feature list.
    resolvedPeaks.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak deconvolution by " + resolver, resolver.getParameterSet()));
    // Initialise counters.
    processedRows = 0;
    totalRows = peakList.getNumberOfRows();
    int peakId = 1;
    // Process each chromatogram.
    final PeakListRow[] peakListRows = peakList.getRows();
    final int chromatogramCount = peakListRows.length;
    for (int index = 0; !isCanceled() && index < chromatogramCount; index++) {
        final PeakListRow currentRow = peakListRows[index];
        final Feature chromatogram = currentRow.getPeak(dataFile);
        // Resolve peaks.
        final PeakResolver resolverModule = resolver.getModule();
        final ParameterSet resolverParams = resolver.getParameterSet();
        final ResolvedPeak[] peaks = resolverModule.resolvePeaks(chromatogram, resolverParams, rSession, mzCenterFunction, msmsRange, RTRangeMSMS);
        // Add peaks to the new feature list.
        for (final ResolvedPeak peak : peaks) {
            peak.setParentChromatogramRowID(currentRow.getID());
            final PeakListRow newRow = new SimplePeakListRow(peakId++);
            newRow.addPeak(dataFile, peak);
            newRow.setPeakInformation(peak.getPeakInformation());
            resolvedPeaks.addRow(newRow);
        }
        processedRows++;
    }
    return resolvedPeaks;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) PeakListAppliedMethod(net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) Feature(net.sf.mzmine.datamodel.Feature) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 38 with SimplePeakListRow

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

the class MsMsPeakPickingTask method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    final Scan[] scans = scanSelection.getMatchingScans(dataFile);
    totalScans = scans.length;
    for (Scan scan : scans) {
        if (isCanceled())
            return;
        // Get the MS Scan
        Scan bestScan = null;
        Range<Double> rtWindow = Range.closed(scan.getRetentionTime() - (binTime / 2.0), scan.getRetentionTime() + (binTime / 2.0));
        Range<Double> mzWindow = Range.closed(scan.getPrecursorMZ() - (binSize / 2.0), scan.getPrecursorMZ() + (binSize / 2.0));
        DataPoint point;
        DataPoint maxPoint = null;
        int[] regionScanNumbers = dataFile.getScanNumbers(1, rtWindow);
        for (int regionScanNumber : regionScanNumbers) {
            Scan regionScan = dataFile.getScan(regionScanNumber);
            point = ScanUtils.findBasePeak(regionScan, mzWindow);
            // no datapoint found
            if (point == null) {
                continue;
            }
            if (maxPoint == null) {
                maxPoint = point;
            }
            int result = Double.compare(maxPoint.getIntensity(), point.getIntensity());
            if (result <= 0) {
                maxPoint = point;
                bestScan = regionScan;
            }
        }
        // if no representative dataPoint
        if (bestScan == null) {
            continue;
        }
        assert maxPoint != null;
        SimpleFeature c = new SimpleFeature(dataFile, scan.getPrecursorMZ(), bestScan.getRetentionTime(), maxPoint.getIntensity(), maxPoint.getIntensity(), new int[] { bestScan.getScanNumber() }, new DataPoint[] { maxPoint }, FeatureStatus.DETECTED, bestScan.getScanNumber(), scan.getScanNumber(), new int[] {}, Range.singleton(bestScan.getRetentionTime()), Range.singleton(scan.getPrecursorMZ()), Range.singleton(maxPoint.getIntensity()));
        PeakListRow entry = new SimplePeakListRow(scan.getScanNumber());
        entry.addPeak(dataFile, c);
        newPeakList.addRow(entry);
        processedScans++;
    }
    project.addPeakList(newPeakList);
    // Add quality parameters to peaks
    QualityParameters.calculateQualityParameters(newPeakList);
    logger.info("Finished MS/MS peak builder on " + dataFile + ", " + processedScans + " scans processed");
    setStatus(TaskStatus.FINISHED);
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) DataPoint(net.sf.mzmine.datamodel.DataPoint) Scan(net.sf.mzmine.datamodel.Scan) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature)

Aggregations

SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)38 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)31 Feature (net.sf.mzmine.datamodel.Feature)29 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)22 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)19 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)17 DataPoint (net.sf.mzmine.datamodel.DataPoint)15 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)14 Scan (net.sf.mzmine.datamodel.Scan)9 ArrayList (java.util.ArrayList)8 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)8 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)7 PeakList (net.sf.mzmine.datamodel.PeakList)6 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)5 Hashtable (java.util.Hashtable)3 List (java.util.List)3 Vector (java.util.Vector)3 ParameterSet (net.sf.mzmine.parameters.ParameterSet)3 PeakSorter (net.sf.mzmine.util.PeakSorter)3 SAXException (org.xml.sax.SAXException)3