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