Search in sources :

Example 1 with SilentChemObjectBuilder

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;
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) SilentChemObjectBuilder(org.openscience.cdk.silent.SilentChemObjectBuilder) IMolecularFormula(org.openscience.cdk.interfaces.IMolecularFormula) ExtendedIsotopePattern(net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern) DataPoint(net.sf.mzmine.datamodel.DataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)1 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)1 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)1 IIsotope (org.openscience.cdk.interfaces.IIsotope)1 IMolecularFormula (org.openscience.cdk.interfaces.IMolecularFormula)1 SilentChemObjectBuilder (org.openscience.cdk.silent.SilentChemObjectBuilder)1