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);
}
Aggregations