use of org.openscience.cdk.silent.SilentChemObjectBuilder in project mzmine2 by mzmine.
the class DPPAnyElementIsotopeGrouperTask method getIsotopePatterns.
/**
* Returns an array of isotope patterns for the given string. Every element gets its own isotope
* pattern.
*
* @param elements String of element symbols
* @param mergeWidth
* @param minAbundance
* @return
*/
public static ExtendedIsotopePattern[] getIsotopePatterns(String elements, double mergeWidth, double minAbundance) {
SilentChemObjectBuilder builder = (SilentChemObjectBuilder) SilentChemObjectBuilder.getInstance();
IMolecularFormula form = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula(elements, builder);
ExtendedIsotopePattern[] isotopePatterns = new ExtendedIsotopePattern[form.getIsotopeCount()];
int i = 0;
// create a isotope pattern for every element
for (IIsotope element : form.isotopes()) {
isotopePatterns[i] = (ExtendedIsotopePattern) IsotopePatternCalculator.calculateIsotopePattern(element.getSymbol(), minAbundance, mergeWidth, 1, PolarityType.NEUTRAL, true);
i++;
}
// also, we want to keep track of the isotope composition, to do that cleanly, we remove the
// lightest isotope description
ExtendedIsotopePattern[] cleanedPatterns = new ExtendedIsotopePattern[form.getIsotopeCount()];
i = 0;
for (ExtendedIsotopePattern p : isotopePatterns) {
String[] composition = p.getIsotopeCompositions();
composition[0] = "";
cleanedPatterns[i] = new ExtendedIsotopePattern(p.getDataPoints(), p.getStatus(), p.getDescription(), composition);
i++;
}
return cleanedPatterns;
}
Aggregations