Search in sources :

Example 11 with SimplePeakListAppliedMethod

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

the class PeakExtenderTask method run.

/**
 * @see Runnable#run()
 */
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Running peak extender on " + peakList);
    // We assume source peakList contains one datafile
    RawDataFile dataFile = peakList.getRawDataFile(0);
    // Create a new deisotoped peakList
    extendedPeakList = new SimplePeakList(peakList + " " + suffix, peakList.getRawDataFiles());
    // Sort peaks by descending height
    Feature[] sortedPeaks = peakList.getPeaks(dataFile);
    Arrays.sort(sortedPeaks, new PeakSorter(SortingProperty.Height, SortingDirection.Descending));
    // Loop through all peaks
    totalPeaks = sortedPeaks.length;
    Feature oldPeak;
    for (int ind = 0; ind < totalPeaks; ind++) {
        if (isCanceled())
            return;
        oldPeak = sortedPeaks[ind];
        if (oldPeak.getHeight() >= minimumHeight) {
            Feature newPeak = this.getExtendedPeak(oldPeak);
            // Get previous pekaListRow
            PeakListRow oldRow = peakList.getPeakRow(oldPeak);
            // keep old ID
            int oldID = oldRow.getID();
            SimplePeakListRow newRow = new SimplePeakListRow(oldID);
            PeakUtils.copyPeakListRowProperties(oldRow, newRow);
            newRow.addPeak(dataFile, newPeak);
            extendedPeakList.addRow(newRow);
        }
        // Update completion rate
        processedPeaks++;
    }
    // Add new peakList to the project
    project.addPeakList(extendedPeakList);
    // Add quality parameters to peaks
    QualityParameters.calculateQualityParameters(extendedPeakList);
    // Load previous applied methods
    for (PeakListAppliedMethod proc : peakList.getAppliedMethods()) {
        extendedPeakList.addDescriptionOfAppliedTask(proc);
    }
    // Add task description to peakList
    extendedPeakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak extender", parameters));
    // Remove the original peakList if requested
    if (removeOriginal)
        project.removePeakList(peakList);
    logger.info("Finished peak extender on " + peakList);
    setStatus(TaskStatus.FINISHED);
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) PeakListAppliedMethod(net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod) PeakSorter(net.sf.mzmine.util.PeakSorter) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) Feature(net.sf.mzmine.datamodel.Feature) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 12 with SimplePeakListAppliedMethod

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

the class SubTaskFinishListener method accept.

@Override
public synchronized void accept(PeakList processedPeakList) {
    finished++;
    if (finished == tasks) {
        logger.info("All sub tasks of multithreaded gap-filling have finished. Finalising results.");
        // add pkl to project
        // Append processed feature list to the project
        project.addPeakList(processedPeakList);
        // Add quality parameters to peaks
        QualityParameters.calculateQualityParameters(processedPeakList);
        // Add task description to peakList
        processedPeakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Gap filling ", parameters));
        // Remove the original peaklist if requested
        if (removeOriginal)
            project.removePeakList(peakList);
        logger.info("Completed: Multithreaded gap-filling successfull");
    }
}
Also used : SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)

Example 13 with SimplePeakListAppliedMethod

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

the class CustomDBSearchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    try {
        // read database contents in memory
        FileReader dbFileReader = new FileReader(dataBaseFile);
        databaseValues = CSVParser.parse(dbFileReader, fieldSeparator.charAt(0));
        if (ignoreFirstLine)
            finishedLines++;
        for (; finishedLines < databaseValues.length; finishedLines++) {
            if (isCanceled()) {
                dbFileReader.close();
                return;
            }
            try {
                processOneLine(databaseValues[finishedLines]);
            } catch (Exception e) {
            // ignore incorrect lines
            }
        }
        dbFileReader.close();
    } catch (Exception e) {
        logger.log(Level.WARNING, "Could not read file " + dataBaseFile, e);
        setStatus(TaskStatus.ERROR);
        setErrorMessage(e.toString());
        return;
    }
    // Add task description to peakList
    peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak identification using database " + dataBaseFile, parameters));
    // Repaint the window to reflect the change in the feature list
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
    setStatus(TaskStatus.FINISHED);
}
Also used : HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) FileReader(java.io.FileReader) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 14 with SimplePeakListAppliedMethod

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

the class SameRangeTask method run.

public void run() {
    logger.info("Started gap-filling " + peakList);
    setStatus(TaskStatus.PROCESSING);
    // Get total number of rows
    totalRows = peakList.getNumberOfRows();
    // Get feature list columns
    RawDataFile[] columns = peakList.getRawDataFiles();
    // Create new feature list
    processedPeakList = new SimplePeakList(peakList + " " + suffix, columns);
    /**
     ***********************************************************
     * Creating a stream to process the data in parallel
     */
    processedRowsAtomic = new AtomicInteger(0);
    List<PeakListRow> outputList = Collections.synchronizedList(new ArrayList<>());
    peakList.parallelStream().forEach(sourceRow -> {
        // Canceled?
        if (isCanceled())
            return;
        PeakListRow newRow = new SimplePeakListRow(sourceRow.getID());
        // Copy comment
        newRow.setComment(sourceRow.getComment());
        // Copy identities
        for (PeakIdentity ident : sourceRow.getPeakIdentities()) newRow.addPeakIdentity(ident, false);
        if (sourceRow.getPreferredPeakIdentity() != null)
            newRow.setPreferredPeakIdentity(sourceRow.getPreferredPeakIdentity());
        // Copy each peaks and fill gaps
        for (RawDataFile column : columns) {
            // Canceled?
            if (isCanceled())
                return;
            // Get current peak
            Feature currentPeak = sourceRow.getPeak(column);
            // If there is a gap, try to fill it
            if (currentPeak == null)
                currentPeak = fillGap(sourceRow, column);
            // If a peak was found or created, add it
            if (currentPeak != null)
                newRow.addPeak(column, currentPeak);
        }
        outputList.add(newRow);
        processedRowsAtomic.getAndAdd(1);
    });
    outputList.stream().forEach(newRow -> {
        processedPeakList.addRow((PeakListRow) newRow);
    });
    // Canceled?
    if (isCanceled())
        return;
    // Append processed feature list to the project
    project.addPeakList(processedPeakList);
    // Add quality parameters to peaks
    QualityParameters.calculateQualityParameters(processedPeakList);
    // Add task description to peakList
    processedPeakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Gap filling using RT and m/z range", parameters));
    // Remove the original peaklist if requested
    if (removeOriginal)
        project.removePeakList(peakList);
    setStatus(TaskStatus.FINISHED);
    logger.info("Finished gap-filling " + peakList);
}
Also used : PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) Feature(net.sf.mzmine.datamodel.Feature)

Example 15 with SimplePeakListAppliedMethod

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

the class NeutralLossFilterTask method addResultToProject.

/**
 * Add feature list to project, delete old if requested, add description to result
 */
public void addResultToProject() {
    // Add new peakList to the project
    project.addPeakList(resultPeakList);
    // Load previous applied methods
    for (PeakListAppliedMethod proc : peakList.getAppliedMethods()) {
        resultPeakList.addDescriptionOfAppliedTask(proc);
    }
    // Add task description to peakList
    resultPeakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("NeutralLossFilter", parameters));
}
Also used : SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) PeakListAppliedMethod(net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)

Aggregations

SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)42 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)29 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)26 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)20 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)19 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)18 Feature (net.sf.mzmine.datamodel.Feature)16 DataPoint (net.sf.mzmine.datamodel.DataPoint)15 PeakList (net.sf.mzmine.datamodel.PeakList)11 Desktop (net.sf.mzmine.desktop.Desktop)10 HeadLessDesktop (net.sf.mzmine.desktop.impl.HeadLessDesktop)10 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)9 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)8 ArrayList (java.util.ArrayList)7 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)6 Vector (java.util.Vector)4 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)4 Scan (net.sf.mzmine.datamodel.Scan)4 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)4 IOException (java.io.IOException)3