tabCounter++;
// the search type
br.write(getCurrentTabSpace() + "<SearchType>" + System.getProperty("line.separator"));
tabCounter++;
writeCvTerm(new CvTerm("PSI-MS", "MS:1001083", "ms-ms search", null));
tabCounter--;
br.write(getCurrentTabSpace() + "</SearchType>" + System.getProperty("line.separator"));
// the search parameters
br.write(getCurrentTabSpace() + "<AdditionalSearchParams>" + System.getProperty("line.separator"));
tabCounter++;
writeCvTerm(new CvTerm("PSI-MS", "MS:1001211", "parent mass type mono", null));
writeCvTerm(new CvTerm("PSI-MS", "MS:1001256", "fragment mass type mono", null));
if (mzidVersion1_2) {
writeCvTerm(new CvTerm("PSI-MS", "MS:100XXX", "peptide-level scoring performed", null)); // @TODO: add correct cv term!
writeCvTerm(new CvTerm("PSI-MS", "MS:1002497", "Group PSMs by distinct peptide sequence with taking modifications into account", null));
writeCvTerm(new CvTerm("PSI-MS", "MS:1002489", "Modification localization scoring performed", null));
if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {
writeCvTerm(new CvTerm("PSI-MS", "MS:100XXX", ptmScoringPreferences.getSelectedProbabilisticScore().getName(), null)); // @TODO: add correct cv term!
}
writeCvTerm(new CvTerm("PSI-MS", "MS:100XXX", "D-score", null)); // @TODO: add correct cv term!
}
// @TODO: list all search parameters from the search engines used?
tabCounter--;
br.write(getCurrentTabSpace() + "</AdditionalSearchParams>" + System.getProperty("line.separator"));
// the modifications
br.write(getCurrentTabSpace() + "<ModificationParams>" + System.getProperty("line.separator"));
tabCounter++;
// iterate and add the ptms
for (String ptm : searchParameters.getModificationProfile().getAllModifications()) {
PTM currentPtm = ptmFactory.getPTM(ptm);
String aminoAcidsAtTarget = "";
if (currentPtm.getType() == PTM.MODN
|| currentPtm.getType() == PTM.MODNP
|| currentPtm.getType() == PTM.MODC
|| currentPtm.getType() == PTM.MODCP) {
aminoAcidsAtTarget = ".";
} else {
for (Character aa : currentPtm.getPattern().getAminoAcidsAtTarget()) {
aminoAcidsAtTarget += aa;
}
}
br.write(getCurrentTabSpace() + "<SearchModification residues=\"" + aminoAcidsAtTarget + "\" massDelta=\"" + currentPtm.getMass()
+ "\" fixedMod= \"" + searchParameters.getModificationProfile().getFixedModifications().contains(ptm) + "\" >" + System.getProperty("line.separator"));
tabCounter++;
CvTerm cvTerm = ptmToPrideMap.getCVTerm(ptm);
if (cvTerm != null) {
writeCvTerm(cvTerm);
} else {
writeCvTerm(new CvTerm("PSI-MS", "MS:1001460", "unknown modification", null));
}
// add modification specificity
if (currentPtm.getType() == PTM.MODN
|| currentPtm.getType() == PTM.MODNAA) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1002057", "modification specificity protein N-term", null));
} else if (currentPtm.getType() == PTM.MODNP
|| currentPtm.getType() == PTM.MODNPAA) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1001189", "modification specificity peptide N-term", null));
} else if (currentPtm.getType() == PTM.MODC
|| currentPtm.getType() == PTM.MODCAA) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1002058", "modification specificity protein C-term", null));
} else if (currentPtm.getType() == PTM.MODCP
|| currentPtm.getType() == PTM.MODCPAA) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1001190", "modification specificity peptide C-term", null));
}
tabCounter--;
br.write(getCurrentTabSpace() + "</SearchModification>" + System.getProperty("line.separator"));
}
tabCounter--;
br.write(getCurrentTabSpace() + "</ModificationParams>" + System.getProperty("line.separator"));
// enzyme
br.write(getCurrentTabSpace() + "<Enzymes independent=\"false\">" + System.getProperty("line.separator"));
// note: if multiple enzymes are specified, independent is set to true if cleavage with different enzymes is performed independently
tabCounter++;
Enzyme enzyme = searchParameters.getEnzyme();
br.write(getCurrentTabSpace() + "<Enzyme "
+ "missedCleavages=\"" + searchParameters.getnMissedCleavages() + "\" "
+ "semiSpecific=\"" + enzyme.isSemiSpecific() + "\" "
//+ "cTermGain=\"OH\" " // Element formula gained at CTerm
//+ "nTermGain=\"H\" " // Element formula gained at NTerm
+ "id=\"Enz1\" "
+ "name=\"" + enzyme.getName() + "\">"
+ System.getProperty("line.separator"));
tabCounter++;
br.write(getCurrentTabSpace() + "<EnzymeName>" + System.getProperty("line.separator"));
tabCounter++;
CvTerm enzymeCvTerm = EnzymeFactory.getEnzymeCvTerm(enzyme);
if (enzymeCvTerm != null) {
writeCvTerm(enzymeCvTerm);
} else {
writeUserParam(enzyme.getName());
}
tabCounter--;
br.write(getCurrentTabSpace() + "</EnzymeName>" + System.getProperty("line.separator"));
tabCounter--;
br.write(getCurrentTabSpace() + "</Enzyme>" + System.getProperty("line.separator"));
tabCounter--;
br.write(getCurrentTabSpace() + "</Enzymes>" + System.getProperty("line.separator"));
// fragment tolerance
br.write(getCurrentTabSpace() + "<FragmentTolerance>" + System.getProperty("line.separator"));
tabCounter++;
br.write(getCurrentTabSpace() + "<cvParam "
+ "accession=\"MS:1001412\" "
+ "cvRef=\"PSI-MS\" "
+ "unitCvRef=\"UO\" "
+ "unitName=\"dalton\" "
+ "unitAccession=\"UO:0000221\" "
+ "value=\"" + searchParameters.getFragmentIonAccuracy() + "\" "
+ "name=\"search tolerance plus value\" />"
+ System.getProperty("line.separator"));
br.write(getCurrentTabSpace() + "<cvParam "
+ "accession=\"MS:1001413\" "
+ "cvRef=\"PSI-MS\" "
+ "unitCvRef=\"UO\" "
+ "unitName=\"dalton\" "
+ "unitAccession=\"UO:0000221\" "
+ "value=\"" + searchParameters.getFragmentIonAccuracy() + "\" "
+ "name=\"search tolerance minus value\" />"
+ System.getProperty("line.separator"));
tabCounter--;
br.write(getCurrentTabSpace() + "</FragmentTolerance>" + System.getProperty("line.separator"));
// precursor tolerance
br.write(getCurrentTabSpace() + "<ParentTolerance>" + System.getProperty("line.separator"));
tabCounter++;
if (searchParameters.isPrecursorAccuracyTypePpm()) {
br.write(getCurrentTabSpace() + "<cvParam "
+ "accession=\"MS:1001412\" "
+ "cvRef=\"PSI-MS\" "
+ "unitCvRef=\"UO\" "
+ "unitName=\"parts per million\" "
+ "unitAccession=\"UO:0000169\" "
+ "value=\"" + searchParameters.getPrecursorAccuracy() + "\" "
+ "name=\"search tolerance plus value\" />"
+ System.getProperty("line.separator"));
br.write(getCurrentTabSpace() + "<cvParam "
+ "accession=\"MS:1001413\" "
+ "cvRef=\"PSI-MS\" "
+ "unitCvRef=\"UO\" "
+ "unitName=\"parts per million\" "
+ "unitAccession=\"UO:0000169\" "
+ "value=\"" + searchParameters.getPrecursorAccuracy() + "\" "
+ "name=\"search tolerance minus value\" />"
+ System.getProperty("line.separator"));
} else {
br.write(getCurrentTabSpace() + "<cvParam "
+ "accession=\"MS:1001412\" "
+ "cvRef=\"PSI-MS\" "
+ "unitCvRef=\"UO\" "
+ "unitName=\"dalton\" "
+ "unitAccession=\"UO:0000221\" "
+ "value=\"" + searchParameters.getPrecursorAccuracy() + "\" "
+ "name=\"search tolerance plus value\" />"
+ System.getProperty("line.separator"));
br.write(getCurrentTabSpace() + "<cvParam "
+ "accession=\"MS:1001413\" "
+ "cvRef=\"PSI-MS\" "
+ "unitCvRef=\"UO\" "
+ "unitName=\"dalton\" "
+ "unitAccession=\"UO:0000221\" "
+ "value=\"" + searchParameters.getPrecursorAccuracy() + "\" "
+ "name=\"search tolerance minus value\" />"
+ System.getProperty("line.separator"));
}
tabCounter--;
br.write(getCurrentTabSpace() + "</ParentTolerance>" + System.getProperty("line.separator"));
// thresholds
br.write(getCurrentTabSpace() + "<Threshold>" + System.getProperty("line.separator"));
tabCounter++;
boolean targetDecoy = sequenceFactory.concatenatedTargetDecoy();
if (!targetDecoy) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1001494", "no threshold", null));
} else {
// Initial global thresholds
writeCvTerm(new CvTerm("PSI-MS", "MS:1001364", "distinct peptide-level global FDR", Double.toString(Util.roundDouble(processingPreferences.getPeptideFDR(), CONFIDENCE_DECIMALS))));
writeCvTerm(new CvTerm("PSI-MS", "MS:1002350", "PSM-level global FDR", Double.toString(Util.roundDouble(processingPreferences.getPsmFDR(), CONFIDENCE_DECIMALS))));
if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1002350", ptmScoringPreferences.getSelectedProbabilisticScore().getName() + " threshold", ptmScoringPreferences.getProbabilisticScoreThreshold() + ""));
}
writeCvTerm(new CvTerm("PSI-MS", "MS:1002350", "D-score threshold", "95")); //@TODO: avoid this hard coded value
// // peptideshaker maps
// PSMaps psMaps = new PSMaps();
// psMaps = (PSMaps) identification.getUrParam(psMaps);
//
// // peptide level threshold
// PeptideSpecificMap peptideSpecificMap = psMaps.getPeptideSpecificMap();
// ArrayList<String> peptideGroupsKeys = peptideSpecificMap.getKeys();
//
// for (String key : peptideGroupsKeys) { // @TODO: find a way of annotating all thresholds..?
// TargetDecoyMap targetDecoyMap = peptideSpecificMap.getTargetDecoyMap(key);
// TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
// double threshold = targetDecoyResults.getUserInput() / 100;
// int thresholdType = targetDecoyResults.getInputType();
// if (peptideGroupsKeys.size() > 1) {
// String peptideClass = PeptideSpecificMap.getKeyName(searchParameters.getModificationProfile(), key);
// // @TODO: somehow indicate the class of peptide thresholded?
// }
// if (thresholdType == 0) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002463", "distinct peptide-level global confidence", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // confidence
// } else if (targetDecoyResults.getInputType() == 1) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1001364", "distinct peptide-level global FDR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FDR
// } else if (targetDecoyResults.getInputType() == 2) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002462", "distinct peptide-level global FNR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FNR
// }
// }
//
// // psm level threshold
// ArrayList<Integer> chargesWithFileSpecificity = new ArrayList<Integer>();
// PsmSpecificMap psmSpecificMap = psMaps.getPsmSpecificMap();
//
// for (Integer charge : psmSpecificMap.getPossibleCharges()) {
// for (String file : psmSpecificMap.getFilesAtCharge(charge)) {
// if (!psmSpecificMap.isFileGrouped(charge, file)) { // @TODO: find a way of annotating all thresholds..?
// chargesWithFileSpecificity.add(charge);
// TargetDecoyMap targetDecoyMap = psMaps.getPsmSpecificMap().getTargetDecoyMap(charge, file);
// TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
// double threshold = targetDecoyResults.getUserInput() / 100;
// int thresholdType = targetDecoyResults.getInputType();
// String psmClass = "Charge " + charge + " of file " + file; // @TODO: annotate class?
// if (thresholdType == 0) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002465", "PSM-level global confidence", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // confidence
// } else if (targetDecoyResults.getInputType() == 1) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002350", "PSM-level global FDR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FDR
// } else if (targetDecoyResults.getInputType() == 2) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002464", "PSM-level global FNR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FNR
// }
// }
// }
// }
//@TODO: set the PSM group label
// for (int charge : psmSpecificMap.getChargesFromGroupedFiles()) {
// int correctedCharge = psmSpecificMap.getCorrectedCharge(charge);
// if (correctedCharge == charge) {
// TargetDecoyMap targetDecoyMap = pSMaps.getPsmSpecificMap().getTargetDecoyMap(charge, null);
// TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
// double threshold = targetDecoyResults.getUserInput() / 100;
// int thresholdType = targetDecoyResults.getInputType();
// // @TODO: check the cv terms used!!!
// if (thresholdType == 0) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002465", "PSM-level global confidence", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // confidence
// } else if (targetDecoyResults.getInputType() == 1) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002350", "PSM-level global FDR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FDR
// } else if (targetDecoyResults.getInputType() == 2) {
// writeCvTerm(new CvTerm("PSI-MS", "MS:1002464", "PSM-level global FNR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FNR
// }
// }
// }
//
// @TODO: re-add psm ptm thresholds
// PsmPTMMap psmPTMMap = pSMaps.getPsmPTMMap();
// if (psmPTMMap != null) { // backward compatibility: information only present in versions 0.28.2 and later
// for (Double ptmMass : psmPTMMap.getModificationsScored()) {
// for (int mapKey : psmPTMMap.getKeys(ptmMass).keySet()) {
// TargetDecoyMap targetDecoyMap = psmPTMMap.getTargetDecoyMap(ptmMass, mapKey);
// TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
// double threshold = targetDecoyResults.getUserInput() / 100;
// int thresholdType = targetDecoyResults.getInputType(); // For now only FDR is implemented but others will follow after my next transatlantic flight :)
// String ptmClass = "Modification of mass " + ptmMass;
// //@TODO: find cv terms
// }
// }
// }
// @TODO: one for ptm scores, one per ptm per charge state per file
// match quality thresholds
// @TODO: match quality thresholds?? some are per file...
}
tabCounter--;
br.write(getCurrentTabSpace() + "</Threshold>" + System.getProperty("line.separator"));
tabCounter--;
br.write(getCurrentTabSpace() + "</SpectrumIdentificationProtocol>" + System.getProperty("line.separator"));
// add ProteinDetectionProtocol
br.write(getCurrentTabSpace() + "<ProteinDetectionProtocol "
+ "analysisSoftware_ref=\"ID_software\" id=\"PeptideShaker_1\">" + System.getProperty("line.separator"));
tabCounter++;
// br.write(getCurrentTabSpace() + "<AnalysisParams>" + System.getProperty("line.separator"));
// tabCounter++;
// @TODO: add cv terms? (children of MS:1001302)
// tabCounter--;
// br.write(getCurrentTabSpace() + "</AnalysisParams>" + System.getProperty("line.separator"));
// protein level threshold
br.write(getCurrentTabSpace() + "<Threshold>" + System.getProperty("line.separator"));
tabCounter++;
if (!targetDecoy) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1001494", "no threshold", null));
} else {
PSMaps psMaps = new PSMaps();
psMaps = (PSMaps) identification.getUrParam(psMaps);
ProteinMap proteinMap = psMaps.getProteinMap();
TargetDecoyMap targetDecoyMap = proteinMap.getTargetDecoyMap();
TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
double threshold = targetDecoyResults.getUserInput() / 100;
int thresholdType = targetDecoyResults.getInputType();
if (thresholdType == 0) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1002461", "protein group-level global confidence", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // confidence
} else if (targetDecoyResults.getInputType() == 1) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1002369", "protein group-level global FDR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FDR
} else if (targetDecoyResults.getInputType() == 2) {
writeCvTerm(new CvTerm("PSI-MS", "MS:1002460", "protein group-level global FNR", Double.toString(Util.roundDouble(threshold, CONFIDENCE_DECIMALS)))); // FNR
}
}
tabCounter--;
br.write(getCurrentTabSpace() + "</Threshold>" + System.getProperty("line.separator"));