/** * Returns an Element with a given element symbol. * *@param symbol The element symbol for the requested element *@return The configured element */ public IElement getElement(String symbol) { return getMajorIsotope(symbol); }
/** * Returns an element according to a given atomic number. * *@param atomicNumber The elements atomic number *@return The Element */ public IElement getElement(int atomicNumber) { return getMajorIsotope(atomicNumber); }
/** * Returns an Element with a given element symbol. * *@param symbol The element symbol for the requested element *@return The configured element */ public IElement getElement(String symbol) { return getMajorIsotope(symbol); }
/** * Returns an element according to a given atomic number. * *@param atomicNumber The elements atomic number *@return The Element */ public IElement getElement(int atomicNumber) { return getMajorIsotope(atomicNumber); }
/** * Returns the symbol matching the element with the given atomic number. * * @param atomicNumber The elements atomic number * @return The symbol of the Element */ public String getElementSymbol(int atomicNumber) { IIsotope isotope = getMajorIsotope(atomicNumber); return isotope.getSymbol(); }
/** * Returns the symbol matching the element with the given atomic number. * * @param atomicNumber The elements atomic number * @return The symbol of the Element */ public String getElementSymbol(int atomicNumber) { IIsotope isotope = getMajorIsotope(atomicNumber); return isotope.getSymbol(); }
/** * Returns the most abundant (major) isotope whose symbol equals element. * *@param symbol the symbol of the element in question *@return The Major Isotope value */ public IIsotope getMajorIsotope(String symbol) { return getMajorIsotope(Elements.ofString(symbol).number()); }
/** * Returns the most abundant (major) isotope whose symbol equals element. * *@param symbol the symbol of the element in question *@return The Major Isotope value */ public IIsotope getMajorIsotope(String symbol) { return getMajorIsotope(Elements.ofString(symbol).number()); }
private double[] getAtomicMasses(IAtom[] a) { double[] am = new double[a.length]; IsotopeFactory factory = null; try { factory = Isotopes.getInstance(); } catch (Exception e) { logger.error("Error while instantiating the isotope factory: ", e.getMessage()); logger.debug(e); } assert factory != null; for (int i = 0; i < a.length; i++) { am[i] = factory.getMajorIsotope(a[i].getSymbol()).getExactMass(); } return (am); }
private Integer getMassNumber(ILigand ligand) { Integer massNumber = ligand.getLigandAtom().getMassNumber(); if (massNumber != null) return massNumber; if (factory == null) return 0; return factory.getMajorIsotope(ligand.getLigandAtom().getSymbol()).getMassNumber(); }
private Integer getMassNumber(ILigand ligand) { Integer massNumber = ligand.getLigandAtom().getMassNumber(); if (massNumber != null) return massNumber; if (factory == null) return 0; return factory.getMajorIsotope(ligand.getLigandAtom().getSymbol()).getMassNumber(); }
private double[] getAtomicMasses(IAtomContainer ac) { double[] am = new double[ac.getAtomCount()]; IsotopeFactory factory = null; try { factory = Isotopes.getInstance(); } catch (Exception e) { logger.error("Error while instantiating the isotope factory: ", e.getMessage()); logger.debug(e); } assert factory != null; for (int i = 0; i < ac.getAtomCount(); i++) { am[i] = factory.getMajorIsotope(ac.getAtom(i).getSymbol()).getExactMass(); } return (am); }
public void undo() throws CannotUndoException { this.atom.setSymbol(formerSymbol); try { IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder()); this.atom.setMassNumber(ifac.getMajorIsotope(formerSymbol).getMassNumber()); chemModelRelay.updateAtom(atom); ifac.configure(atom); } catch (OptionalDataException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Test public void testMassNumberDisplayWithDefinedIsotopes() throws Exception { IsotopeFactory ifac = Isotopes.getInstance(); IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = bldr.newInstance(IMolecularFormula.class); mf.addIsotope(ifac.getMajorIsotope("C"), 7); mf.addIsotope(ifac.getMajorIsotope("O"), 3); mf.addIsotope(ifac.getMajorIsotope("H"), 3); mf.addIsotope(ifac.getMajorIsotope("Br"), 1); mf.addIsotope(ifac.getIsotope("Br", 81), 1); Isotopes.clearMajorIsotopes(mf); assertThat(MolecularFormulaManipulator.getString(mf, false, false), is("C7H3Br2O3")); assertThat(MolecularFormulaManipulator.getString(mf, false, true), is("C7H3Br[81]BrO3")); }
@Test public void testGetMajorIsotope_Nonelement() throws Exception { IsotopeFactory isofac = Isotopes.getInstance(); IIsotope isotope = isofac.getMajorIsotope("E"); assertNull(isotope); }
@Test public void testGetHTML_IMolecularFormulaWithIsotope() { MolecularFormula formula = new MolecularFormula(); formula.addIsotope(ifac.getMajorIsotope("C"), 2); formula.addIsotope(ifac.getMajorIsotope("H"), 6); Assert.assertEquals("<sup>12</sup>C<sub>2</sub><sup>1</sup>H<sub>6</sub>", MolecularFormulaManipulator.getHTML(formula, false, true)); }
@Test public void testGetHTML_IMolecularFormulaWithIsotopeAndCharge() { MolecularFormula formula = new MolecularFormula(); formula.addIsotope(ifac.getMajorIsotope("C"), 2); formula.addIsotope(ifac.getMajorIsotope("H"), 6); formula.setCharge(1); Assert.assertEquals("<sup>12</sup>C<sub>2</sub><sup>1</sup>H<sub>6</sub><sup>+</sup>", MolecularFormulaManipulator.getHTML(formula, true, true)); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testIsValidSum_IMolecularFormula() { IMolecularFormula formula = new MolecularFormula(); formula.addIsotope(ifac.getMajorIsotope("C"), 1); formula.addIsotope(ifac.getMajorIsotope("H"), 100); List<IRule> rules = new ArrayList<IRule>(); rules.add(new MMElementRule()); MolecularFormulaChecker MFChecker = new MolecularFormulaChecker(rules); Assert.assertEquals(0.0, MFChecker.isValidSum(formula), 0.001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testIsValid_NOT() { IMolecularFormula formula = new MolecularFormula(); formula.addIsotope(ifac.getMajorIsotope("C"), 1); formula.addIsotope(ifac.getMajorIsotope("H"), 100); List<IRule> rules = new ArrayList<IRule>(); rules.add(new MMElementRule()); MolecularFormulaChecker MFChecker = new MolecularFormulaChecker(rules); IMolecularFormula formulaWith = MFChecker.isValid(formula); Assert.assertEquals(0.0, formulaWith.getProperty((new MMElementRule()).getClass())); }
/** * Test negative mass */ @Test(expected = IllegalArgumentException.class) public void testNegativeMass() throws Exception { IsotopeFactory ifac = Isotopes.getInstance(); IIsotope c = ifac.getMajorIsotope("C"); MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.addIsotope(c, 0, 100); new MolecularFormulaGenerator(builder, -20, -10, new MolecularFormulaRange()); }