Search in sources :

Example 1 with MergeMode

use of net.sf.mzmine.modules.tools.msmsspectramerge.MergeMode in project mzmine2 by mzmine.

the class SiriusExportTask method exportPeakListRow.

private void exportPeakListRow(PeakListRow row, BufferedWriter writer) throws IOException {
    // get row charge and polarity
    char polarity = 0;
    for (Feature f : row.getPeaks()) {
        char pol = f.getDataFile().getScan(f.getRepresentativeScanNumber()).getPolarity().asSingleChar().charAt(0);
        if (pol != polarity && polarity != 0) {
            setErrorMessage("Joined features have different polarity. This is most likely a bug. If not, please separate them as individual features and/or write a feature request on github.");
            setStatus(TaskStatus.ERROR);
            return;
        } else {
            polarity = pol;
        }
    }
    if (mergeEnabled) {
        MergeMode mergeMode = mergeParameters.getParameter(MsMsSpectraMergeParameters.MERGE_MODE).getValue();
        MsMsSpectraMergeModule merger = MZmineCore.getModuleInstance(MsMsSpectraMergeModule.class);
        if (mergeMode != MergeMode.ACROSS_SAMPLES) {
            for (Feature f : row.getPeaks()) {
                if (f.getFeatureStatus() == Feature.FeatureStatus.DETECTED && f.getMostIntenseFragmentScanNumber() >= 0) {
                    // write correlation spectrum
                    writeHeader(writer, row, f.getDataFile(), polarity, MsType.CORRELATED, -1);
                    writeCorrelationSpectrum(writer, f);
                    if (mergeMode == MergeMode.CONSECUTIVE_SCANS) {
                        // merge MS/MS
                        List<MergedSpectrum> spectra = merger.mergeConsecutiveScans(mergeParameters, f, massListName);
                        for (MergedSpectrum spectrum : spectra) {
                            writeHeader(writer, row, f.getDataFile(), polarity, MsType.MSMS, spectrum.filterByRelativeNumberOfScans(mergeParameters.getParameter(MsMsSpectraMergeParameters.PEAK_COUNT_PARAMETER).getValue()));
                            writeSpectrum(writer, spectrum.data);
                        }
                    } else {
                        MergedSpectrum spectrum = merger.mergeFromSameSample(mergeParameters, f, massListName).filterByRelativeNumberOfScans(mergeParameters.getParameter(MsMsSpectraMergeParameters.PEAK_COUNT_PARAMETER).getValue());
                        if (spectrum.data.length > 0) {
                            writeHeader(writer, row, f.getDataFile(), polarity, MsType.MSMS, spectrum);
                            writeSpectrum(writer, spectrum.data);
                        }
                    }
                }
            }
        } else {
            // write correlation spectrum
            writeHeader(writer, row, row.getBestPeak().getDataFile(), polarity, MsType.CORRELATED, -1);
            writeCorrelationSpectrum(writer, row.getBestPeak());
            // merge everything into one
            MergedSpectrum spectrum = merger.mergeAcrossSamples(mergeParameters, row, massListName).filterByRelativeNumberOfScans(mergeParameters.getParameter(MsMsSpectraMergeParameters.PEAK_COUNT_PARAMETER).getValue());
            if (spectrum.data.length > 0) {
                writeHeader(writer, row, row.getBestPeak().getDataFile(), polarity, MsType.MSMS, spectrum);
                writeSpectrum(writer, spectrum.data);
            }
        }
    } else {
        // No merging
        Feature bestPeak = row.getBestPeak();
        MassList ms1MassList = bestPeak.getRepresentativeScan().getMassList(massListName);
        if (ms1MassList != null) {
            writeHeader(writer, row, bestPeak.getDataFile(), polarity, MsType.MS, bestPeak.getRepresentativeScanNumber());
            writeSpectrum(writer, ms1MassList.getDataPoints());
        }
        for (Feature f : row.getPeaks()) {
            for (int ms2scan : f.getAllMS2FragmentScanNumbers()) {
                writeHeader(writer, row, f.getDataFile(), polarity, MsType.MSMS, ms2scan);
                MassList ms2MassList = f.getDataFile().getScan(ms2scan).getMassList(massListName);
                if (ms2MassList == null)
                    continue;
                writeSpectrum(writer, ms2MassList.getDataPoints());
            }
        }
    }
}
Also used : MergeMode(net.sf.mzmine.modules.tools.msmsspectramerge.MergeMode) MsMsSpectraMergeModule(net.sf.mzmine.modules.tools.msmsspectramerge.MsMsSpectraMergeModule) MergedSpectrum(net.sf.mzmine.modules.tools.msmsspectramerge.MergedSpectrum) Feature(net.sf.mzmine.datamodel.Feature) MassList(net.sf.mzmine.datamodel.MassList) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)1 Feature (net.sf.mzmine.datamodel.Feature)1 MassList (net.sf.mzmine.datamodel.MassList)1 MergeMode (net.sf.mzmine.modules.tools.msmsspectramerge.MergeMode)1 MergedSpectrum (net.sf.mzmine.modules.tools.msmsspectramerge.MergedSpectrum)1 MsMsSpectraMergeModule (net.sf.mzmine.modules.tools.msmsspectramerge.MsMsSpectraMergeModule)1