Search in sources :

Example 1 with Gap

use of net.sf.mzmine.modules.peaklistmethods.gapfilling.peakfinder.Gap in project mzmine2 by mzmine.

the class MultiThreadPeakFinderTask method run.

public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Running multithreaded gap filler " + taskIndex + " on raw files " + (start + 1) + "-" + endexcl + " of pkl:" + peakList);
    // Calculate total number of scans in all files
    for (int i = start; i < endexcl; i++) {
        RawDataFile dataFile = peakList.getRawDataFile(i);
        totalScans += dataFile.getNumOfScans(1);
    }
    // Process all raw data files
    for (int i = start; i < endexcl; i++) {
        RawDataFile dataFile = peakList.getRawDataFile(i);
        // Canceled?
        if (isCanceled()) {
            return;
        }
        List<Gap> gaps = new ArrayList<Gap>();
        // if necessary
        for (int row = 0; row < peakList.getNumberOfRows(); row++) {
            PeakListRow sourceRow = peakList.getRow(row);
            PeakListRow newRow = processedPeakList.getRow(row);
            Feature sourcePeak = sourceRow.getPeak(dataFile);
            if (sourcePeak == null) {
                // Create a new gap
                Range<Double> mzRange = mzTolerance.getToleranceRange(sourceRow.getAverageMZ());
                Range<Double> rtRange = rtTolerance.getToleranceRange(sourceRow.getAverageRT());
                Gap newGap = new Gap(newRow, dataFile, mzRange, rtRange, intTolerance);
                gaps.add(newGap);
            } else {
                newRow.addPeak(dataFile, sourcePeak);
            }
        }
        // Stop processing this file if there are no gaps
        if (gaps.isEmpty()) {
            processedScans += dataFile.getNumOfScans();
            continue;
        }
        // Get all scans of this data file
        int[] scanNumbers = dataFile.getScanNumbers(1);
        // Process each scan
        for (int scanNumber : scanNumbers) {
            // Canceled?
            if (isCanceled()) {
                return;
            }
            // Get the scan
            Scan scan = dataFile.getScan(scanNumber);
            // Feed this scan to all gaps
            for (Gap gap : gaps) {
                gap.offerNextScan(scan);
            }
            processedScans++;
        }
        // Finalize gaps
        for (Gap gap : gaps) {
            gap.noMoreOffers();
        }
    }
    // first notify listener
    listener.accept(processedPeakList);
    logger.info("Finished sub task: Multithreaded gap filler " + taskIndex + " on raw files " + (start + 1) + "-" + endexcl + " of pkl:" + peakList);
    setStatus(TaskStatus.FINISHED);
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Gap(net.sf.mzmine.modules.peaklistmethods.gapfilling.peakfinder.Gap) ArrayList(java.util.ArrayList) Scan(net.sf.mzmine.datamodel.Scan) Feature(net.sf.mzmine.datamodel.Feature)

Aggregations

ArrayList (java.util.ArrayList)1 Feature (net.sf.mzmine.datamodel.Feature)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 Scan (net.sf.mzmine.datamodel.Scan)1 Gap (net.sf.mzmine.modules.peaklistmethods.gapfilling.peakfinder.Gap)1