* Returns a calculated similarity score of
*/
public static MSMSScore evaluateMSMS(IMolecularFormula parentFormula,
Scan msmsScan, ParameterSet parameters) {
MZTolerance msmsTolerance = parameters.getParameter(
MSMSScoreParameters.msmsTolerance).getValue();
String massListName = parameters.getParameter(
MSMSScoreParameters.massList).getValue();
MassList massList = msmsScan.getMassList(massListName);
if (massList == null) {
throw new IllegalArgumentException("Scan #"
+ msmsScan.getScanNumber()
+ " does not have a mass list called '" + massListName
+ "'");
}
DataPoint msmsIons[] = massList.getDataPoints();
if (msmsIons == null) {
throw new IllegalArgumentException("Mass list " + massList
+ " does not contain data for scan #"
+ msmsScan.getScanNumber());
}
// Sorted by mass in descending order
ArrayList<ElementRule> rulesSet = new ArrayList<ElementRule>();
for (IIsotope isotope : parentFormula.isotopes()) {
ElementRule rule = new ElementRule(isotope.getSymbol(), 0,
parentFormula.getIsotopeCount(isotope));
rulesSet.add(rule);
}
ElementRule msmsElementRules[] = rulesSet.toArray(new ElementRule[0]);
int totalMSMSpeaks = 0, interpretedMSMSpeaks = 0;
Map<DataPoint, String> msmsAnnotations = new Hashtable<DataPoint, String>();
msmsCycle : for (DataPoint dp : msmsIons) {
// Check if this is an isotope
Range isotopeCheckRange = new Range(dp.getMZ() - 1.4,
dp.getMZ() - 0.6);
for (DataPoint dpCheck : msmsIons) {
// If we have any MS/MS peak with 1 neutron mass smaller m/z
// and higher intensity, it means the current peak is an
// isotope and we should ignore it
if (isotopeCheckRange.contains(dpCheck.getMZ())
&& (dpCheck.getIntensity() > dp.getIntensity())) {
continue msmsCycle;
}
}
// We don't know the charge of the fragment, so we will simply
// assume 1
double neutralLoss = msmsScan.getPrecursorMZ()
* msmsScan.getPrecursorCharge() - dp.getMZ();
// Ignore negative neutral losses and parent ion, <5 may be a
// good threshold
if (neutralLoss < 5)
continue;
Range msmsTargetRange = msmsTolerance
.getToleranceRange(neutralLoss);
FormulaGenerator msmsEngine = new FormulaGenerator(msmsTargetRange,
msmsElementRules);