use of net.sf.mzmine.modules.peaklistmethods.msms.msmsscore.MSMSScore in project mzmine2 by mzmine.
the class SingleRowPredictionTask method checkConstraints.
private void checkConstraints(IMolecularFormula cdkFormula) {
// Check elemental ratios
if (checkRatios) {
boolean check = ElementalHeuristicChecker.checkFormula(cdkFormula, ratiosParameters);
if (!check)
return;
}
Double rdbeValue = RDBERestrictionChecker.calculateRDBE(cdkFormula);
// Check RDBE condition
if (checkRDBE && (rdbeValue != null)) {
boolean check = RDBERestrictionChecker.checkRDBE(rdbeValue, rdbeParameters);
if (!check)
return;
}
// Calculate isotope similarity score
final IsotopePattern detectedPattern = peakListRow.getBestIsotopePattern();
final String stringFormula = MolecularFormulaManipulator.getString(cdkFormula);
final String adjustedFormula = FormulaUtils.ionizeFormula(stringFormula, ionType, charge);
final double isotopeNoiseLevel = isotopeParameters.getParameter(IsotopePatternScoreParameters.isotopeNoiseLevel).getValue();
// Fixed min abundance
final double minPredictedAbundance = 0.00001;
final IsotopePattern predictedIsotopePattern = IsotopePatternCalculator.calculateIsotopePattern(adjustedFormula, minPredictedAbundance, charge, ionType.getPolarity());
Double isotopeScore = null;
if ((checkIsotopes) && (detectedPattern != null)) {
isotopeScore = IsotopePatternScoreCalculator.getSimilarityScore(detectedPattern, predictedIsotopePattern, isotopeParameters);
final double minScore = isotopeParameters.getParameter(IsotopePatternScoreParameters.isotopePatternScoreThreshold).getValue();
if (isotopeScore < minScore)
return;
}
// MS/MS evaluation is slowest, so let's do it last
Double msmsScore = null;
Feature bestPeak = peakListRow.getBestPeak();
RawDataFile dataFile = bestPeak.getDataFile();
Map<DataPoint, String> msmsAnnotations = null;
int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
if ((checkMSMS) && (msmsScanNumber > 0)) {
Scan msmsScan = dataFile.getScan(msmsScanNumber);
String massListName = msmsParameters.getParameter(MSMSScoreParameters.massList).getValue();
MassList ms2MassList = msmsScan.getMassList(massListName);
if (ms2MassList == null) {
setStatus(TaskStatus.ERROR);
setErrorMessage("The MS/MS scan #" + msmsScanNumber + " in file " + dataFile.getName() + " does not have a mass list called '" + massListName + "'");
return;
}
MSMSScore score = MSMSScoreCalculator.evaluateMSMS(cdkFormula, msmsScan, msmsParameters);
double minMSMSScore = msmsParameters.getParameter(MSMSScoreParameters.msmsMinScore).getValue();
if (score != null) {
msmsScore = score.getScore();
msmsAnnotations = score.getAnnotation();
// Check the MS/MS condition
if (msmsScore < minMSMSScore)
return;
}
}
// Create a new formula entry
final ResultFormula resultEntry = new ResultFormula(cdkFormula, predictedIsotopePattern, rdbeValue, isotopeScore, msmsScore, msmsAnnotations);
// Add the new formula entry
resultWindow.addNewListItem(resultEntry);
foundFormulas++;
}
use of net.sf.mzmine.modules.peaklistmethods.msms.msmsscore.MSMSScore in project mzmine2 by mzmine.
the class FormulaPredictionPeakListTask method checkConstraints.
private boolean checkConstraints(IMolecularFormula cdkFormula, PeakListRow peakListRow) {
// Check elemental ratios
if (checkRatios) {
boolean check = ElementalHeuristicChecker.checkFormula(cdkFormula, ratiosParameters);
if (!check) {
return false;
}
}
Double rdbeValue = RDBERestrictionChecker.calculateRDBE(cdkFormula);
// Check RDBE condition
if (checkRDBE && (rdbeValue != null)) {
boolean check = RDBERestrictionChecker.checkRDBE(rdbeValue, rdbeParameters);
if (!check) {
return false;
}
}
// Calculate isotope similarity score
IsotopePattern detectedPattern = peakListRow.getBestIsotopePattern();
IsotopePattern predictedIsotopePattern = null;
Double isotopeScore = null;
if ((checkIsotopes) && (detectedPattern != null)) {
String stringFormula = MolecularFormulaManipulator.getString(cdkFormula);
String adjustedFormula = FormulaUtils.ionizeFormula(stringFormula, ionType, charge);
final double isotopeNoiseLevel = isotopeParameters.getParameter(IsotopePatternScoreParameters.isotopeNoiseLevel).getValue();
final double detectedPatternHeight = detectedPattern.getHighestDataPoint().getIntensity();
final double minPredictedAbundance = isotopeNoiseLevel / detectedPatternHeight;
predictedIsotopePattern = IsotopePatternCalculator.calculateIsotopePattern(adjustedFormula, minPredictedAbundance, charge, ionType.getPolarity());
isotopeScore = IsotopePatternScoreCalculator.getSimilarityScore(detectedPattern, predictedIsotopePattern, isotopeParameters);
final double minScore = isotopeParameters.getParameter(IsotopePatternScoreParameters.isotopePatternScoreThreshold).getValue();
if (isotopeScore < minScore) {
return false;
}
}
// MS/MS evaluation is slowest, so let's do it last
Double msmsScore = null;
Feature bestPeak = peakListRow.getBestPeak();
RawDataFile dataFile = bestPeak.getDataFile();
int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
if ((checkMSMS) && (msmsScanNumber > 0)) {
Scan msmsScan = dataFile.getScan(msmsScanNumber);
String massListName = msmsParameters.getParameter(MSMSScoreParameters.massList).getValue();
MassList ms2MassList = msmsScan.getMassList(massListName);
if (ms2MassList == null) {
setStatus(TaskStatus.ERROR);
setErrorMessage("The MS/MS scan #" + msmsScanNumber + " in file " + dataFile.getName() + " does not have a mass list called '" + massListName + "'");
return false;
}
MSMSScore score = MSMSScoreCalculator.evaluateMSMS(cdkFormula, msmsScan, msmsParameters);
double minMSMSScore = msmsParameters.getParameter(MSMSScoreParameters.msmsMinScore).getValue();
if (score != null) {
msmsScore = score.getScore();
// Check the MS/MS condition
if (msmsScore < minMSMSScore) {
return false;
}
}
}
return true;
}
Aggregations