Search in sources :

Example 1 with MSMSLipidTools

use of net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipididentificationtools.MSMSLipidTools in project mzmine2 by mzmine.

the class LipidSearchTask method searchMsmsFragments.

/**
 * This method searches for MS/MS fragments. A mass list for MS2 scans will be used if present. If
 * no mass list is present for MS2 scans it will create one using centroid or exact mass detection
 * algorithm
 */
private void searchMsmsFragments(PeakListRow row, double lipidIonMass, LipidIdentity lipid) {
    MassDetector massDetector = null;
    // Check if selected feature has MSMS spectra
    if (row.getAllMS2Fragmentations() != null) {
        Scan[] msmsScans = row.getAllMS2Fragmentations();
        for (Scan msmsScan : msmsScans) {
            DataPoint[] massList = null;
            // check if MS/MS scan already has a mass list
            if (msmsScan.getMassLists().length != 0) {
                massList = msmsScan.getMassLists()[0].getDataPoints();
            } else {
                // Create a new mass list for MS/MS scan. Check if sprectrum is profile or centroid mode
                if (msmsScan.getSpectrumType() == MassSpectrumType.CENTROIDED) {
                    massDetector = new CentroidMassDetector();
                    CentroidMassDetectorParameters parametersMSMS = new CentroidMassDetectorParameters();
                    CentroidMassDetectorParameters.noiseLevel.setValue(noiseLevelMSMS);
                    massList = massDetector.getMassValues(msmsScan, parametersMSMS);
                } else {
                    massDetector = new ExactMassDetector();
                    ExactMassDetectorParameters parametersMSMS = new ExactMassDetectorParameters();
                    ExactMassDetectorParameters.noiseLevel.setValue(noiseLevelMSMS);
                    massList = massDetector.getMassValues(msmsScan, parametersMSMS);
                }
            }
            MSMSLipidTools msmsLipidTools = new MSMSLipidTools();
            // check for negative polarity
            if (msmsScan.getPolarity() == PolarityType.NEGATIVE) {
                // check if lipid class has set negative fragments
                String[] fragments = lipid.getLipidClass().getMsmsFragmentsNegativeIonization();
                if (fragments.length > 0) {
                    ArrayList<String> listOfAnnotatedNegativeFragments = new ArrayList<String>();
                    for (int i = 0; i < massList.length; i++) {
                        Range<Double> mzTolRangeMSMS = mzToleranceMS2.getToleranceRange(massList[i].getMZ());
                        String annotatedNegativeFragment = msmsLipidTools.checkForNegativeClassSpecificFragment(mzTolRangeMSMS, row.getPreferredPeakIdentity(), lipidIonMass, fragments);
                        if (annotatedNegativeFragment.equals("") == false && row.getComment().contains(annotatedNegativeFragment) == false) {
                            listOfAnnotatedNegativeFragments.add(annotatedNegativeFragment);
                        }
                    }
                    if (listOfAnnotatedNegativeFragments.isEmpty() == false) {
                        // predict lipid fatty acid composition if possible
                        ArrayList<String> listOfPossibleFattyAcidCompositions = msmsLipidTools.predictFattyAcidComposition(listOfAnnotatedNegativeFragments, row.getPreferredPeakIdentity(), lipid.getLipidClass().getNumberOfAcylChains());
                        for (int i = 0; i < listOfPossibleFattyAcidCompositions.size(); i++) {
                            // Add possible composition to comment
                            if (row.getComment().equals(null)) {
                                row.setComment(" " + listOfPossibleFattyAcidCompositions.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                            } else {
                                row.setComment(row.getComment() + ";" + " " + listOfPossibleFattyAcidCompositions.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                            }
                        }
                        // add class specific fragments
                        for (int i = 0; i < listOfAnnotatedNegativeFragments.size(); i++) {
                            if (listOfAnnotatedNegativeFragments.get(i).contains("C") || listOfAnnotatedNegativeFragments.get(i).contains("H") || listOfAnnotatedNegativeFragments.get(i).contains("O")) {
                                // Add fragment to comment
                                if (row.getComment().equals(null)) {
                                    row.setComment(" " + listOfAnnotatedNegativeFragments.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                                } else {
                                    row.setComment(row.getComment() + ";" + " " + listOfAnnotatedNegativeFragments.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                                }
                            }
                        }
                    }
                }
            }
            // check if lipid class has positive fragments
            if (msmsScan.getPolarity() == PolarityType.POSITIVE) {
                // check if lipid class has set postiev fragments
                String[] fragments = lipid.getLipidClass().getMsmsFragmentsPositiveIonization();
                if (fragments.length > 0) {
                    ArrayList<String> listOfAnnotatedPositiveFragments = new ArrayList<String>();
                    for (int i = 0; i < massList.length; i++) {
                        Range<Double> mzTolRangeMSMS = mzToleranceMS2.getToleranceRange(massList[i].getMZ());
                        String annotatedPositiveFragment = msmsLipidTools.checkForPositiveClassSpecificFragment(mzTolRangeMSMS, row.getPreferredPeakIdentity(), lipidIonMass, fragments);
                        if (annotatedPositiveFragment.equals("") == false && row.getComment().contains(annotatedPositiveFragment) == false) {
                            listOfAnnotatedPositiveFragments.add(annotatedPositiveFragment);
                        }
                    }
                    // predict lipid fatty acid composition if possible
                    ArrayList<String> listOfPossibleFattyAcidCompositions = msmsLipidTools.predictFattyAcidComposition(listOfAnnotatedPositiveFragments, row.getPreferredPeakIdentity(), lipid.getLipidClass().getNumberOfAcylChains());
                    for (int i = 0; i < listOfPossibleFattyAcidCompositions.size(); i++) {
                        // Add possible composition to comment
                        if (row.getComment().equals(null)) {
                            row.setComment(" " + listOfPossibleFattyAcidCompositions.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                        } else {
                            row.setComment(row.getComment() + ";" + " " + listOfPossibleFattyAcidCompositions.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                        }
                    }
                    // add class specific fragments
                    for (int i = 0; i < listOfAnnotatedPositiveFragments.size(); i++) {
                        if (listOfAnnotatedPositiveFragments.get(i).contains("C")) {
                            // Add fragment to comment
                            if (row.getComment().equals(null)) {
                                row.setComment(" " + listOfAnnotatedPositiveFragments.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                            } else {
                                row.setComment(row.getComment() + ";" + " " + listOfAnnotatedPositiveFragments.get(i) + " MS/MS scan " + msmsScan.getScanNumber() + ", RT " + MZmineCore.getConfiguration().getRTFormat().format(msmsScan.getRetentionTime()));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : CentroidMassDetectorParameters(net.sf.mzmine.modules.rawdatamethods.peakpicking.massdetection.centroid.CentroidMassDetectorParameters) 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) MSMSLipidTools(net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipididentificationtools.MSMSLipidTools) Scan(net.sf.mzmine.datamodel.Scan) 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)

Aggregations

ArrayList (java.util.ArrayList)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 Scan (net.sf.mzmine.datamodel.Scan)1 MSMSLipidTools (net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipididentificationtools.MSMSLipidTools)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