Search in sources :

Example 11 with MZmineProject

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

the class DeconvolutionModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull final ParameterSet parameters, @Nonnull final Collection<Task> tasks) {
    PeakList[] peakLists = parameters.getParameter(DeconvolutionParameters.PEAK_LISTS).getValue().getMatchingPeakLists();
    // function to calculate center mz
    CenterFunction mzCenterFunction = parameters.getParameter(DeconvolutionParameters.MZ_CENTER_FUNCTION).getValue();
    // use a LOG weighted, noise corrected, maximum weight capped function
    if (mzCenterFunction.getMeasure().equals(CenterMeasure.AUTO)) {
        // data point with lowest intensity
        // weight = LOG(value) - LOG(noise) (maxed to maxWeight)
        double noise = Arrays.stream(peakLists).flatMap(pkl -> Arrays.stream(pkl.getRows())).map(r -> r.getPeaks()[0]).mapToDouble(peak -> peak.getRawDataPointsIntensityRange().lowerEndpoint()).filter(v -> v != 0).min().orElse(0);
        // maxWeight 4 corresponds to a linear range of 4 orders of magnitude
        // everything higher than this will be capped to this weight
        // do not overestimate influence of very high data points on mass accuracy
        double maxWeight = 4;
        // use a LOG weighted, noise corrected, maximum weight capped function
        mzCenterFunction = new CenterFunction(CenterMeasure.AVG, Weighting.LOG10, noise, maxWeight);
    }
    for (final PeakList peakList : peakLists) {
        tasks.add(new DeconvolutionTask(project, peakList, parameters, mzCenterFunction));
    }
    return ExitCode.OK;
}
Also used : Arrays(java.util.Arrays) Collection(java.util.Collection) CenterFunction(net.sf.mzmine.util.maths.CenterFunction) MZmineModuleCategory(net.sf.mzmine.modules.MZmineModuleCategory) PeakList(net.sf.mzmine.datamodel.PeakList) CenterMeasure(net.sf.mzmine.util.maths.CenterMeasure) Task(net.sf.mzmine.taskcontrol.Task) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule) ParameterSet(net.sf.mzmine.parameters.ParameterSet) Weighting(net.sf.mzmine.util.maths.Weighting) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) ExitCode(net.sf.mzmine.util.ExitCode) Nonnull(javax.annotation.Nonnull) PeakList(net.sf.mzmine.datamodel.PeakList) CenterFunction(net.sf.mzmine.util.maths.CenterFunction) Nonnull(javax.annotation.Nonnull)

Aggregations

MZmineProject (net.sf.mzmine.datamodel.MZmineProject)11 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)8 PeakList (net.sf.mzmine.datamodel.PeakList)5 UserParameter (net.sf.mzmine.parameters.UserParameter)4 ArrayList (java.util.ArrayList)3 ParameterSet (net.sf.mzmine.parameters.ParameterSet)3 Task (net.sf.mzmine.taskcontrol.Task)3 ExitCode (net.sf.mzmine.util.ExitCode)3 Nonnull (javax.annotation.Nonnull)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 TreePath (javax.swing.tree.TreePath)2 MassList (net.sf.mzmine.datamodel.MassList)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 Scan (net.sf.mzmine.datamodel.Scan)2 File (java.io.File)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 JFileChooser (javax.swing.JFileChooser)1