Search in sources :

Example 6 with MolecularFormulaRange

use of org.openscience.cdk.formula.MolecularFormulaRange in project mzmine2 by mzmine.

the class DPPSumFormulaPredictionTask method run.

@Override
public void run() {
    if (!checkParameterSet() || !checkValues()) {
        setStatus(TaskStatus.ERROR);
        return;
    }
    if (getDataPoints().length == 0) {
        logger.info("Data point/Spectra processing: 0 data points were passed to " + getTaskDescription() + " Please check the parameters.");
        setStatus(TaskStatus.CANCELED);
        return;
    }
    if (!(getDataPoints() instanceof ProcessedDataPoint[])) {
        logger.info("Data point/Spectra processing: The array of data points passed to " + getTaskDescription() + " is not an instance of ProcessedDataPoint. Make sure to run mass detection first.");
        setStatus(TaskStatus.CANCELED);
        return;
    }
    setStatus(TaskStatus.PROCESSING);
    List<ProcessedDataPoint> resultList = new ArrayList<>();
    IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
    for (int i = 0; i < dataPoints.length; i++) {
        if (isCanceled())
            return;
        if (dataPoints[i].getIntensity() < noiseLevel)
            continue;
        massRange = mzTolerance.getToleranceRange((dataPoints[i].getMZ() - ionType.getAddedMass()) / charge);
        MolecularFormulaRange elCounts = DynamicParameterUtils.buildFormulaRangeOnIsotopePatternResults((ProcessedDataPoint) dataPoints[i], elementCounts);
        generator = new MolecularFormulaGenerator(builder, massRange.lowerEndpoint(), massRange.upperEndpoint(), elCounts);
        List<PredResult> formulas = generateFormulas((ProcessedDataPoint) dataPoints[i], massRange, charge, generator);
        DPPSumFormulaResult[] results = genereateResults(formulas, numResults);
        ((ProcessedDataPoint) dataPoints[i]).addAllResults(results);
        resultList.add((ProcessedDataPoint) dataPoints[i]);
        currentIndex++;
    }
    // setResults((ProcessedDataPoint[]) dataPoints);
    setResults(resultList.toArray(new ProcessedDataPoint[0]));
    setStatus(TaskStatus.FINISHED);
}
Also used : MolecularFormulaGenerator(org.openscience.cdk.formula.MolecularFormulaGenerator) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) MolecularFormulaRange(org.openscience.cdk.formula.MolecularFormulaRange) DPPSumFormulaResult(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPSumFormulaResult) ArrayList(java.util.ArrayList) IChemObjectBuilder(org.openscience.cdk.interfaces.IChemObjectBuilder) DataPoint(net.sf.mzmine.datamodel.DataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)

Aggregations

MolecularFormulaRange (org.openscience.cdk.formula.MolecularFormulaRange)6 IIsotope (org.openscience.cdk.interfaces.IIsotope)3 IOException (java.io.IOException)2 DataPoint (net.sf.mzmine.datamodel.DataPoint)2 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)2 IsotopeFactory (org.openscience.cdk.config.IsotopeFactory)2 MolecularFormulaGenerator (org.openscience.cdk.formula.MolecularFormulaGenerator)2 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)2 IMolecularFormula (org.openscience.cdk.interfaces.IMolecularFormula)2 Range (com.google.common.collect.Range)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 MassList (net.sf.mzmine.datamodel.MassList)1 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)1 DPPIsotopePatternResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPIsotopePatternResult)1 DPPSumFormulaResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPSumFormulaResult)1 MZTolerance (net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance)1