Search in sources :

Example 1 with LipidIdentity

use of net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipidutils.LipidIdentity in project mzmine2 by mzmine.

the class SpectraIdentificationLipidSearchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    // create mass list for scan
    DataPoint[] massList = null;
    ArrayList<DataPoint> massListAnnotated = new ArrayList<>();
    MassDetector massDetector = null;
    ArrayList<String> allCompoundIDs = new ArrayList<>();
    // Create a new mass list for MS/MS scan. Check if sprectrum is profile or centroid mode
    if (currentScan.getSpectrumType() == MassSpectrumType.CENTROIDED) {
        massDetector = new CentroidMassDetector();
        CentroidMassDetectorParameters parameters = new CentroidMassDetectorParameters();
        CentroidMassDetectorParameters.noiseLevel.setValue(noiseLevel);
        massList = massDetector.getMassValues(currentScan.getDataPoints(), parameters);
    } else {
        massDetector = new ExactMassDetector();
        ExactMassDetectorParameters parameters = new ExactMassDetectorParameters();
        ExactMassDetectorParameters.noiseLevel.setValue(noiseLevel);
        massList = massDetector.getMassValues(currentScan.getDataPoints(), parameters);
    }
    totalSteps = massList.length;
    // loop through every peak in mass list
    if (getStatus() != TaskStatus.PROCESSING) {
        return;
    }
    // Check if lipids should be modified
    if (searchForModifications == true) {
        lipidModificationMasses = getLipidModificationMasses(lipidModification);
    }
    // Calculate how many possible lipids we will try
    totalSteps = (((maxChainLength - minChainLength + 1) * (maxDoubleBonds - minDoubleBonds + 1)) * selectedLipids.length);
    // Combine Strings
    String annotation = "";
    // Try all combinations of fatty acid lengths and double bonds
    for (int j = 0; j < selectedLipids.length; j++) {
        int numberOfAcylChains = selectedLipids[j].getNumberOfAcylChains();
        int numberOfAlkylChains = selectedLipids[j].getNumberofAlkyChains();
        for (int chainLength = minChainLength; chainLength <= maxChainLength; chainLength++) {
            for (int chainDoubleBonds = minDoubleBonds; chainDoubleBonds <= maxDoubleBonds; chainDoubleBonds++) {
                for (int i = 0; i < massList.length; i++) {
                    searchedMass = massList[i].getMZ();
                    // Task canceled?
                    if (isCanceled())
                        return;
                    // than minimal length, skip this lipid
                    if (((chainLength > 0) && (chainLength < minChainLength))) {
                        continue;
                    }
                    // doesn't make sense, so let's skip such lipids
                    if (((chainDoubleBonds > 0) && (chainDoubleBonds > chainLength - 1))) {
                        continue;
                    }
                    // Prepare a lipid instance
                    LipidIdentity lipidChain = new LipidIdentity(selectedLipids[j], chainLength, chainDoubleBonds, numberOfAcylChains, numberOfAlkylChains);
                    annotation = findPossibleLipid(lipidChain, searchedMass);
                    if (annotation != "") {
                        allCompoundIDs.add(annotation);
                        massListAnnotated.add(massList[i]);
                    }
                    annotation = findPossibleLipidModification(lipidChain, searchedMass);
                    if (annotation != "") {
                        allCompoundIDs.add(annotation);
                        massListAnnotated.add(massList[i]);
                    }
                }
                finishedSteps++;
            }
        }
    }
    // new mass list
    DataPoint[] annotatedMassList = new DataPoint[massListAnnotated.size()];
    massListAnnotated.toArray(annotatedMassList);
    String[] annotations = new String[annotatedMassList.length];
    allCompoundIDs.toArray(annotations);
    DataPointsDataSet detectedCompoundsDataset = new DataPointsDataSet("Detected compounds", annotatedMassList);
    // Add label generator for the dataset
    SpectraDatabaseSearchLabelGenerator labelGenerator = new SpectraDatabaseSearchLabelGenerator(annotations, spectraPlot);
    spectraPlot.addDataSet(detectedCompoundsDataset, Color.orange, true, labelGenerator);
    spectraPlot.getXYPlot().getRenderer().setSeriesItemLabelGenerator(spectraPlot.getXYPlot().getSeriesCount(), labelGenerator);
    spectraPlot.getXYPlot().getRenderer().setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_CENTER, 0.0), true);
    setStatus(TaskStatus.FINISHED);
}
Also used : CentroidMassDetectorParameters(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.centroid.CentroidMassDetectorParameters) LipidIdentity(net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipidutils.LipidIdentity) ArrayList(java.util.ArrayList) ExactMassDetector(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.exactmass.ExactMassDetector) DataPoint(net.sf.mzmine.datamodel.DataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) CentroidMassDetector(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.centroid.CentroidMassDetector) CentroidMassDetector(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.centroid.CentroidMassDetector) ExactMassDetector(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.exactmass.ExactMassDetector) MassDetector(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.MassDetector) ExactMassDetectorParameters(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.exactmass.ExactMassDetectorParameters) DataPointsDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet) SpectraDatabaseSearchLabelGenerator(net.sf.mzmine.modules.visualization.spectra.simplespectra.spectraidentification.SpectraDatabaseSearchLabelGenerator)

Example 2 with LipidIdentity

use of net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipidutils.LipidIdentity in project mzmine2 by mzmine.

the class LipidSearchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Starting lipid search in " + peakList);
    PeakListRow[] rows = peakList.getRows();
    // Check if lipids should be modified
    if (searchForModifications == true) {
        lipidModificationMasses = getLipidModificationMasses(lipidModification);
    }
    // Calculate how many possible lipids we will try
    totalSteps = ((maxChainLength - minChainLength + 1) * (maxDoubleBonds - minDoubleBonds + 1)) * selectedLipids.length;
    // Try all combinations of fatty acid lengths and double bonds
    for (int i = 0; i < selectedLipids.length; i++) {
        int numberOfAcylChains = selectedLipids[i].getNumberOfAcylChains();
        int numberOfAlkylChains = selectedLipids[i].getNumberofAlkyChains();
        for (int chainLength = minChainLength; chainLength <= maxChainLength; chainLength++) {
            for (int chainDoubleBonds = minDoubleBonds; chainDoubleBonds <= maxDoubleBonds; chainDoubleBonds++) {
                // Task canceled?
                if (isCanceled())
                    return;
                // than minimal length, skip this lipid
                if (((chainLength > 0) && (chainLength < minChainLength))) {
                    finishedSteps++;
                    continue;
                }
                // doesn't make sense, so let's skip such lipids
                if (((chainDoubleBonds > 0) && (chainDoubleBonds > chainLength - 1))) {
                    finishedSteps++;
                    continue;
                }
                // Prepare a lipid instance
                LipidIdentity lipidChain = new LipidIdentity(selectedLipids[i], chainLength, chainDoubleBonds, numberOfAcylChains, numberOfAlkylChains);
                // Find all rows that match this lipid
                findPossibleLipid(lipidChain, rows);
                finishedSteps++;
            }
        }
    }
    // Add task description to peakList
    ((SimplePeakList) peakList).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Lipid search", parameters));
    // Repaint the window to reflect the change in the peak list
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
    setStatus(TaskStatus.FINISHED);
    logger.info("Finished lipid search task in " + peakList);
}
Also used : LipidIdentity(net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipidutils.LipidIdentity) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) DataPoint(net.sf.mzmine.datamodel.DataPoint) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)2 LipidIdentity (net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipidutils.LipidIdentity)2 ArrayList (java.util.ArrayList)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)1 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)1 Desktop (net.sf.mzmine.desktop.Desktop)1 HeadLessDesktop (net.sf.mzmine.desktop.impl.HeadLessDesktop)1 MassDetector (net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.MassDetector)1 CentroidMassDetector (net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.centroid.CentroidMassDetector)1 CentroidMassDetectorParameters (net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.centroid.CentroidMassDetectorParameters)1 ExactMassDetector (net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.exactmass.ExactMassDetector)1 ExactMassDetectorParameters (net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.exactmass.ExactMassDetectorParameters)1 DataPointsDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet)1 SpectraDatabaseSearchLabelGenerator (net.sf.mzmine.modules.visualization.spectra.simplespectra.spectraidentification.SpectraDatabaseSearchLabelGenerator)1 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)1