Search in sources :

Example 1 with DPPSumFormulaResult

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPSumFormulaResult 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

ArrayList (java.util.ArrayList)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)1 DPPSumFormulaResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPSumFormulaResult)1 MolecularFormulaGenerator (org.openscience.cdk.formula.MolecularFormulaGenerator)1 MolecularFormulaRange (org.openscience.cdk.formula.MolecularFormulaRange)1 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)1