/** * @throws java.io.IOException if there is error in getting the {@link IsotopeFactory} */ public PubChemXMLHelper(IChemObjectBuilder builder) throws IOException { this.builder = builder; factory = Isotopes.getInstance(); }
private void ensureFactory() { if (factory == null) { try { factory = Isotopes.getInstance(); } catch (IOException exception) { logger.error("Could not load the IsotopeFactory: " + exception.getMessage()); } } }
private static double scaledAtomicMasses(IElement element) throws java.io.IOException, ClassNotFoundException { IsotopeFactory isofac = Isotopes.getInstance(); double realmasses = isofac.getNaturalMass(element); return (realmasses / CARBON_MASS); }
/** * Constructor for the MolecularFormulaCheckerTest object. * */ public MolecularFormulaCheckerTest() { super(); try { ifac = Isotopes.getInstance(); } catch (IOException e) { e.printStackTrace(); } }
@Test public void testGetInstance_IChemObjectBuilder() throws Exception { Isotopes isofac = Isotopes.getInstance(); Assert.assertNotNull(isofac); }
/** * The JUnit setup method */ @BeforeClass public static void setUp() throws Exception { builder = DefaultChemObjectBuilder.getInstance(); ifac = Isotopes.getInstance(); setRule(IsotopePatternRule.class); }
@Test public void testGetElement_String() throws Exception { IsotopeFactory elfac = Isotopes.getInstance(); IElement element = elfac.getElement("Br"); Assert.assertEquals(35, element.getAtomicNumber().intValue()); }
@Test public void testGetMajorIsotope_Nonelement() throws Exception { IsotopeFactory isofac = Isotopes.getInstance(); IIsotope isotope = isofac.getMajorIsotope("E"); assertNull(isotope); }
@Test public void testGetElementSymbol_int() throws Exception { IsotopeFactory elfac = Isotopes.getInstance(); String symbol = elfac.getElementSymbol(8); Assert.assertEquals("O", symbol); }
@Test public void testIsElement_String() throws Exception { Isotopes isofac = Isotopes.getInstance(); Assert.assertTrue(isofac.isElement("C")); }
/** * @cdk.bug 3534288 */ @Test(expected = IllegalArgumentException.class) public void testNonexistingElement() throws Exception { Isotopes isofac = Isotopes.getInstance(); IAtom xxAtom = new Atom("Xx"); isofac.configure(xxAtom); }
@Test public void testGetIsotopes() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope[] list = isofac.getIsotopes(); Assert.assertTrue(list.length > 200); }
@Test public void testGetIsotope_NonElement() throws Exception { Isotopes isofac = Isotopes.getInstance(); assertNull(isofac.getIsotope("R", 13)); }
@Test public void configureDoesNotSetMajorIsotope() throws Exception { IAtom atom = new Atom("CH4"); Isotopes isotopes = Isotopes.getInstance(); IIsotope major = isotopes.getMajorIsotope(atom.getSymbol()); assertThat(major, is(notNullValue())); assertThat(major.getMassNumber(), is(12)); isotopes.configure(atom); assertThat(atom.getMassNumber(), is(nullValue())); }
@Test public void testConfigure_IAtom() throws Exception { Isotopes isofac = Isotopes.getInstance(); Atom atom = new Atom("H"); isofac.configure(atom); Assert.assertEquals(1, atom.getAtomicNumber().intValue()); }
@Test public void testGetMajorIsotope_String() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope isotope = isofac.getMajorIsotope("Te"); Assert.assertEquals(129.9062244, isotope.getExactMass(), 0.0001); }
@Test public void testGetIsotopes_double_double() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope[] list = isofac.getIsotopes(87.90, 0.01); // should return: // Isotope match: 88Sr has mass 87.9056121 // Isotope match: 88Y has mass 87.9095011 Assert.assertEquals(2, list.length); Assert.assertEquals(88, list[0].getMassNumber().intValue()); Assert.assertEquals(88, list[1].getMassNumber().intValue()); }
@Test public void testGetNaturalMass_IElement() throws Exception { Isotopes isofac = Isotopes.getInstance(); Assert.assertEquals(1.0079760, isofac.getNaturalMass(new Element("H")), 0.1); }
@Test public void testGetMajorIsotopeMass_IMolecularFormula() throws Exception { IMolecularFormula formula = new MolecularFormula(); formula.addIsotope(builder.newInstance(IIsotope.class, "C")); formula.addIsotope(builder.newInstance(IIsotope.class, "H"), 4); double expectedMass = 0.0; expectedMass += Isotopes.getInstance().getMajorIsotope("C").getExactMass(); expectedMass += 4.0 * Isotopes.getInstance().getMajorIsotope("H").getExactMass(); double totalExactMass = MolecularFormulaManipulator.getMajorIsotopeMass(formula); Assert.assertEquals(expectedMass, totalExactMass, 0.000001); }
/** * 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()); }