ResultWindow window = new ResultWindow(peakListRow, searchedMass, this);
window.setTitle("Searching for " + massFormater.format(searchedMass)
+ " amu");
desktop.addInternalFrame(window);
IsotopePattern detectedPattern = peakListRow.getBestIsotopePattern();
if ((isotopeFilter) && (detectedPattern == null)) {
final String msg = "Cannot calculate isotope pattern scores, because selected"
+ " peak does not have any isotopes. Have you run the isotope peak grouper?";
MZmineCore.getDesktop().displayMessage(msg);
}
try {
String compoundIDs[] = gateway.findCompounds(searchedMass,
mzTolerance, numOfResults, db.getParameterSet());
// Get the number of results
numItems = compoundIDs.length;
if (numItems == 0) {
window.setTitle("Searching for "
+ massFormater.format(searchedMass)
+ " amu: no results found");
}
// Process each one of the result ID's.
for (int i = 0; i < numItems; i++) {
if (getStatus() != TaskStatus.PROCESSING) {
return;
}
DBCompound compound = gateway.getCompound(compoundIDs[i],
db.getParameterSet());
String formula = compound
.getPropertyValue(PeakIdentity.PROPERTY_FORMULA);
if (formula != null) {
// First modify the formula according to the ionization
String adjustedFormula = FormulaUtils.ionizeFormula(
formula, ionType, charge);
logger.finest("Calculating isotope pattern for compound formula "
+ formula + " adjusted to " + adjustedFormula);
// Generate IsotopePattern for this compound
IsotopePattern compoundIsotopePattern = IsotopePatternCalculator
.calculateIsotopePattern(adjustedFormula, 0.001,
charge, ionType.getPolarity());
compound.setIsotopePattern(compoundIsotopePattern);
IsotopePattern rawDataIsotopePattern = peakListRow
.getBestIsotopePattern();
// If required, check isotope score
if (isotopeFilter && (rawDataIsotopePattern != null)
&& (compoundIsotopePattern != null)) {