ExportFormat exportFormat, SearchParameters searchParameters) throws IOException, MzMLUnmarshallerException {
String spectrumKey = spectrumMatch.getKey();
SpectrumFactory spectrumFactory = SpectrumFactory.getInstance();
Precursor precursor = spectrumFactory.getPrecursor(spectrumKey);
switch (exportFormat) {
case Thermo:
int index = (int) (0.25 * retentionTimes.size());
double rtMin = retentionTimes.get(index) / 60;
index = (int) (0.75 * retentionTimes.size());
double rtMax = retentionTimes.get(index) / 60;
if (rtMax - rtMin < rtWindow / 60) {
index = (int) (0.5 * retentionTimes.size());
rtMin = (retentionTimes.get(index) - rtWindow / 2) / 60;
rtMax = (retentionTimes.get(index) + rtWindow / 2) / 60;
}
return precursor.getMz() + "\t" + rtMin + "\t" + rtMax;
case ABI:
index = (int) (0.5 * retentionTimes.size());
double rtInMin = retentionTimes.get(index) / 60;
return rtInMin + "\t" + precursor.getMz();
case Bruker:
index = (int) 0.5 * retentionTimes.size();
double rt = retentionTimes.get(index);
int index25 = (int) (0.25 * retentionTimes.size());
int index75 = (int) (0.75 * retentionTimes.size());
double range = retentionTimes.get(index75) - retentionTimes.get(index25);
if (range < rtWindow) {
range = rtWindow;
}
if (searchParameters.getPrecursorAccuracyType() == SearchParameters.MassAccuracyType.PPM) {
double deltaMZ = searchParameters.getPrecursorAccuracy() / 1000000 * precursor.getMz();
double mzMin = precursor.getMz() - deltaMZ;
double mzMax = precursor.getMz() + deltaMZ;
return rt + "," + range + "," + mzMin + "," + mzMax;
} else { // Dalton
double deltaMZ = searchParameters.getPrecursorAccuracy() / spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value;
double mzMin = precursor.getMz() - deltaMZ;
double mzMax = precursor.getMz() + deltaMZ;
return rt + "," + range + "," + mzMin + "," + mzMax;
}
case MassLynx:
index = (int) (0.5 * retentionTimes.size());
rt = retentionTimes.get(index);
return precursor.getMz() + "," + rt;
default:
return "";
}
}