Search in sources :

Example 1 with ProcessedDataPoint

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.

the class DPPResultsLabelGenerator method generateLabel.

/**
 * @see org.jfree.chart.labels.XYItemLabelGenerator#generateLabel(org.jfree.data.xy.XYDataset,
 *      int, int)
 */
public String generateLabel(XYDataset dataset, int series, int item) {
    // X and Y values of current data point
    double originalX = dataset.getX(series, item).doubleValue();
    double originalY = dataset.getY(series, item).doubleValue();
    // Calculate data size of 1 screen pixel
    double xLength = (double) plot.getXYPlot().getDomainAxis().getRange().getLength();
    double pixelX = xLength / plot.getWidth();
    // Size of data set
    int itemCount = dataset.getItemCount(series);
    // Search for data points higher than this one in the interval
    // from limitLeft to limitRight
    double limitLeft = originalX - ((POINTS_RESERVE_X / 2) * pixelX);
    double limitRight = originalX + ((POINTS_RESERVE_X / 2) * pixelX);
    // Iterate data points to the left and right
    for (int i = 1; (item - i > 0) || (item + i < itemCount); i++) {
        // If we get out of the limit we can stop searching
        if ((item - i > 0) && (dataset.getXValue(series, item - i) < limitLeft) && ((item + i >= itemCount) || (dataset.getXValue(series, item + i) > limitRight)))
            break;
        if ((item + i < itemCount) && (dataset.getXValue(series, item + i) > limitRight) && ((item - i <= 0) || (dataset.getXValue(series, item - i) < limitLeft)))
            break;
        // If we find higher data point, bail out
        if ((item - i > 0) && (originalY <= dataset.getYValue(series, item - i)))
            return null;
        if ((item + i < itemCount) && (originalY <= dataset.getYValue(series, item + i)))
            return null;
    }
    // Create label
    String label = null;
    if (dataset instanceof ScanDataSet) {
        label = ((ScanDataSet) dataset).getAnnotation(item);
    } else if (dataset instanceof DPPResultsDataSet) {
        DataPoint[] dps = ((DPPResultsDataSet) dataset).getDataPoints();
        if (dps[item] instanceof ProcessedDataPoint) {
            ProcessedDataPoint p = (ProcessedDataPoint) dps[item];
            label = createLabel(p);
        }
    }
    if (label == null || label.equals("")) {
        double mzValue = dataset.getXValue(series, item);
        label = mzFormat.format(mzValue);
    }
    return label;
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 2 with ProcessedDataPoint

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.

the class DynamicParameterUtils method buildFormulaRangeOnIsotopePatternResults.

/**
 * Creates an ElementParameter based on the previous processing results. If no results were
 * detected, the default value is returned. Upper and lower boundaries are chosen according to
 * lowerElementBoundaryPercentage and upperElementBoundaryPercentage values of this utility class.
 * These values can be set via {@link #setLowerElementBoundaryPercentage} and
 * {@link #setUpperElementBoundaryPercentage}. The elements contained in
 *
 * @param dp The data point to build a parameter for.
 * @param def The default set of parameters.
 * @return The built ElementsParameter
 */
public static MolecularFormulaRange buildFormulaRangeOnIsotopePatternResults(ProcessedDataPoint dp, MolecularFormulaRange def) {
    DPPIsotopePatternResult result = (DPPIsotopePatternResult) dp.getFirstResultByType(ResultType.ISOTOPEPATTERN);
    if (result == null)
        return def;
    if (!(result.getValue() instanceof ExtendedIsotopePattern))
        return def;
    ExtendedIsotopePattern pattern = (ExtendedIsotopePattern) result.getValue();
    String form = IsotopePatternUtils.makePatternSuggestion(pattern.getIsotopeCompositions());
    MolecularFormulaRange range = new MolecularFormulaRange();
    IMolecularFormula formula = FormulaUtils.createMajorIsotopeMolFormula(form);
    if (formula == null) {
        logger.finest("could not generate formula for m/z " + dp.getMZ() + " " + form);
        return def;
    }
    for (IIsotope isotope : def.isotopes()) range.addIsotope(isotope, def.getIsotopeCountMin(isotope), def.getIsotopeCountMax(isotope));
    for (IIsotope isotope : formula.isotopes()) {
        if (range.contains(isotope))
            continue;
        int count = formula.getIsotopeCount(isotope);
        range.addIsotope(isotope, (int) (count * lowerElementBoundaryPercentage), (int) (count * upperElementBoundaryPercentage));
    }
    for (IIsotope isotope : range.isotopes()) {
        int min = range.getIsotopeCountMin(isotope);
        int max = range.getIsotopeCountMax(isotope);
    // logger.info("m/z = " + dp.getMZ() + " " + isotope.getSymbol() + " " + min + " - " + max);
    }
    return range;
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) MolecularFormulaRange(org.openscience.cdk.formula.MolecularFormulaRange) DPPIsotopePatternResult(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPIsotopePatternResult) IMolecularFormula(org.openscience.cdk.interfaces.IMolecularFormula) ExtendedIsotopePattern(net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)

Example 3 with ProcessedDataPoint

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.

the class DPPMassDetectionTask method run.

@Override
public void run() {
    if (!checkParameterSet() || !checkValues()) {
        setStatus(TaskStatus.ERROR);
        return;
    }
    if (getStatus() == TaskStatus.CANCELED) {
        return;
    }
    setStatus(TaskStatus.PROCESSING);
    MassDetector detector = massDetector.getModule();
    DataPoint[] masses = detector.getMassValues(getDataPoints(), massDetector.getParameterSet());
    if (masses == null || masses.length <= 0) {
        Logger.info("Data point/Spectra processing: No masses were detected with the given parameters.");
        setStatus(TaskStatus.CANCELED);
        return;
    }
    ProcessedDataPoint[] dp = ProcessedDataPoint.convert(masses);
    currentIndex = dataPoints.length;
    setResults(dp);
    setStatus(TaskStatus.FINISHED);
}
Also used : ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) MassDetector(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.MassDetector)

Example 4 with ProcessedDataPoint

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.

the class DPPIsotopeGrouperTask method compressIsotopeDataSets.

/**
 * This method generates a single IsotopesDataSet from all detected isotope patterns in the
 * results.
 *
 * @param dataPoints
 * @return
 */
private IsotopesDataSet compressIsotopeDataSets(ProcessedDataPoint[] dataPoints) {
    List<IsotopePattern> list = new ArrayList<>();
    for (ProcessedDataPoint dp : dataPoints) {
        if (dp.resultTypeExists(ResultType.ISOTOPEPATTERN)) {
            list.add(((DPPIsotopePatternResult) dp.getFirstResultByType(ResultType.ISOTOPEPATTERN)).getValue());
        }
    }
    if (list.isEmpty())
        return null;
    List<DataPoint> dpList = new ArrayList<>();
    for (IsotopePattern pattern : list) {
        for (DataPoint dp : pattern.getDataPoints()) dpList.add(dp);
    }
    if (dpList.isEmpty())
        return null;
    IsotopePattern full = new SimpleIsotopePattern(dpList.toArray(new DataPoint[0]), IsotopePatternStatus.DETECTED, "Isotope patterns");
    return new IsotopesDataSet(full);
}
Also used : ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) ArrayList(java.util.ArrayList) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) SimpleIsotopePattern(net.sf.mzmine.datamodel.impl.SimpleIsotopePattern) SimpleIsotopePattern(net.sf.mzmine.datamodel.impl.SimpleIsotopePattern) IsotopesDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.IsotopesDataSet)

Example 5 with ProcessedDataPoint

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint in project mzmine2 by mzmine.

the class IsotopePatternUtils method sortAndRemoveDuplicateIsotopicPeakResult.

/**
 * Sorts DPPIsotopicPeakResults by m/z and removes duplicates
 *
 * @param dp
 */
public static void sortAndRemoveDuplicateIsotopicPeakResult(ProcessedDataPoint dp) {
    List<DPPIsotopicPeakResult> results = getIsotopicPeakResults(dp);
    Collections.sort(results, (o1, o2) -> {
        return Double.compare(o1.getValue().getMZ(), o2.getValue().getMZ());
    });
    for (int i = 0; i < results.size() - 1; i++) {
        DPPIsotopicPeakResult a = results.get(i);
        DPPIsotopicPeakResult b = results.get(i + 1);
        if (a.getValue() == b.getValue()) {
            // logger.info("removed duplicates at positions " + i + ", " + j);
            results.remove(a);
        }
    }
    dp.removeAllResultsByType(ResultType.ISOTOPICPEAK);
    for (DPPIsotopicPeakResult r : results) dp.addResult(r);
}
Also used : DPPIsotopicPeakResult(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPIsotopicPeakResult) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)

Aggregations

ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)17 DataPoint (net.sf.mzmine.datamodel.DataPoint)14 ArrayList (java.util.ArrayList)9 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)7 DPPIsotopePatternResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPIsotopePatternResult)6 DPPIsotopicPeakResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPIsotopicPeakResult)5 DPPResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPResult)4 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)3 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)3 Nonnull (javax.annotation.Nonnull)2 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)2 IsotopesDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.IsotopesDataSet)2 MolecularFormulaRange (org.openscience.cdk.formula.MolecularFormulaRange)2 Color (java.awt.Color)1 Vector (java.util.Vector)1 MassDetector (net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.MassDetector)1 DPPIsotopeCompositionResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPIsotopeCompositionResult)1 DPPSumFormulaResult (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPSumFormulaResult)1 ScanDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet)1 MolecularFormulaGenerator (org.openscience.cdk.formula.MolecularFormulaGenerator)1