Search in sources :

Example 6 with IIsotope

use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.

the class FormulaUtils method getElementMass.

/**
 * Returns the exact mass of an element. Mass is obtained from the CDK library.
 */
public static double getElementMass(String element) {
    try {
        Isotopes isotopeFactory = Isotopes.getInstance();
        IIsotope majorIsotope = isotopeFactory.getMajorIsotope(element);
        // If the isotope symbol does not exist, return 0
        if (majorIsotope == null) {
            return 0;
        }
        double mass = majorIsotope.getExactMass();
        return mass;
    } catch (IOException e) {
        e.printStackTrace();
        return 0;
    }
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) IOException(java.io.IOException) Isotopes(org.openscience.cdk.config.Isotopes)

Example 7 with IIsotope

use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.

the class FormulaUtils method replaceAllIsotopesWithoutExactMass.

/**
 * Searches for all isotopes exactmass=null and replaces them with the major isotope
 *
 * @param f
 * @return
 * @throws IOException
 */
public static IMolecularFormula replaceAllIsotopesWithoutExactMass(IMolecularFormula f) throws IOException {
    for (IIsotope iso : f.isotopes()) {
        // find isotope without exact mass
        if (iso.getExactMass() == null || iso.getExactMass() == 0) {
            int isotopeCount = f.getIsotopeCount(iso);
            f.removeIsotope(iso);
            // replace
            IsotopeFactory iFac = Isotopes.getInstance();
            IIsotope major = iFac.getMajorIsotope(iso.getAtomicNumber());
            if (major != null)
                f.addIsotope(major, isotopeCount);
            return replaceAllIsotopesWithoutExactMass(f);
        }
    }
    // no isotope found
    return f;
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) IsotopeFactory(org.openscience.cdk.config.IsotopeFactory)

Example 8 with IIsotope

use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.

the class ElementsParameter method saveValueToXML.

@Override
public void saveValueToXML(Element xmlElement) {
    if (value == null)
        return;
    StringBuilder s = new StringBuilder();
    for (IIsotope i : value.isotopes()) {
        s.append(i.getSymbol());
        s.append("[");
        s.append(value.getIsotopeCountMin(i));
        s.append("-");
        s.append(value.getIsotopeCountMax(i));
        s.append("]");
    }
    xmlElement.setTextContent(s.toString());
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope)

Example 9 with IIsotope

use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.

the class ElementsTableComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == addElementButton) {
        JFrame parent = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, this);
        PeriodicTableDialog dialog = new PeriodicTableDialog(parent);
        dialog.setVisible(true);
        IIsotope chosenIsotope = dialog.getSelectedIsotope();
        if (chosenIsotope == null)
            return;
        elementsTableModel.addRow(chosenIsotope, 0, 100);
    }
    if (src == removeElementButton) {
        int selectedRow = elementsTable.getSelectedRow();
        if (selectedRow < 0)
            return;
        elementsTableModel.removeRow(selectedRow);
    }
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) JFrame(javax.swing.JFrame) PeriodicTableDialog(net.sf.mzmine.util.dialogs.PeriodicTableDialog)

Example 10 with IIsotope

use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.

the class ElementsTableComponent method setElements.

public void setElements(MolecularFormulaRange elements) {
    if (elements == null)
        return;
    for (IIsotope isotope : elements.isotopes()) {
        int minCount = elements.getIsotopeCountMin(isotope);
        int maxCount = elements.getIsotopeCountMax(isotope);
        elementsTableModel.addRow(isotope, minCount, maxCount);
    }
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope)

Aggregations

IIsotope (org.openscience.cdk.interfaces.IIsotope)16 IMolecularFormula (org.openscience.cdk.interfaces.IMolecularFormula)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)3 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)3 MolecularFormulaRange (org.openscience.cdk.formula.MolecularFormulaRange)3 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)3 IOException (java.io.IOException)2 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)2 Isotopes (org.openscience.cdk.config.Isotopes)2 Range (com.google.common.collect.Range)1 Color (java.awt.Color)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 JComponent (javax.swing.JComponent)1 JFrame (javax.swing.JFrame)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 OverlayLayout (javax.swing.OverlayLayout)1 Border (javax.swing.border.Border)1