/** * Mass number for a atom with a given atomic number and exact mass. * @param atomicNumber atomic number * @param exactMass exact mass * @return the mass number (or null) if no mass number was found * @throws IOException isotope configuration could not be loaded */ private Integer massNumber(int atomicNumber, double exactMass) throws IOException { String symbol = PeriodicTable.getSymbol(atomicNumber); IIsotope isotope = Isotopes.getInstance().getIsotope(symbol, exactMass, 0.001); return isotope != null ? isotope.getMassNumber() : null; } }
/** * Mass number for a atom with a given atomic number and exact mass. * * @param atomicNumber atomic number * @param exactMass exact mass * @return the mass number (or null) if no mass number was found * @throws IOException isotope configuration could not be loaded */ private Integer massNumber(int atomicNumber, double exactMass) throws IOException { String symbol = PeriodicTable.getSymbol(atomicNumber); IIsotope isotope = Isotopes.getInstance().getIsotope(symbol, exactMass, 0.001); return isotope != null ? isotope.getMassNumber() : null; }
/** * Mass number for a atom with a given atomic number and exact mass. * @param atomicNumber atomic number * @param exactMass exact mass * @return the mass number (or null) if no mass number was found * @throws IOException isotope configuration could not be loaded */ private Integer massNumber(int atomicNumber, double exactMass) throws IOException { String symbol = PeriodicTable.getSymbol(atomicNumber); IIsotope isotope = Isotopes.getInstance().getIsotope(symbol, exactMass, 0.001); return isotope != null ? isotope.getMassNumber() : null; } }
/** * Mass number for a atom with a given atomic number and exact mass. * * @param atomicNumber atomic number * @param exactMass exact mass * @return the mass number (or null) if no mass number was found * @throws IOException isotope configuration could not be loaded */ private Integer massNumber(int atomicNumber, double exactMass) throws IOException { String symbol = PeriodicTable.getSymbol(atomicNumber); IIsotope isotope = Isotopes.getInstance().getIsotope(symbol, exactMass, 0.001); return isotope != null ? isotope.getMassNumber() : null; }
@Test public void testGetIsotope_NonElement() throws Exception { Isotopes isofac = Isotopes.getInstance(); assertNull(isofac.getIsotope("R", 13)); }
@Test public void testYeahSure() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope match = isofac.getIsotope("H", 13.00001, 0.0001); assertNull(match); }
@Test public void testGetIsotopeFromExactMass_LargeTolerance() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope carbon13 = isofac.getIsotope("C", 13); IIsotope match = isofac.getIsotope(carbon13.getSymbol(), carbon13.getExactMass(), 2.0); Assert.assertNotNull(match); Assert.assertEquals(13, match.getMassNumber().intValue()); }
@Test public void testGetIsotopeFromExactMass() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope carbon13 = isofac.getIsotope("C", 13); IIsotope match = isofac.getIsotope(carbon13.getSymbol(), carbon13.getExactMass(), 0.0001); Assert.assertNotNull(match); Assert.assertEquals(13, match.getMassNumber().intValue()); }
@Test public void testGetIsotopeFromExactMass_NonElement() throws Exception { Isotopes isofac = Isotopes.getInstance(); IIsotope match = isofac.getIsotope("R", 13.00001, 0.0001); assertNull(match); }
@Test public void testGetIsotope() throws Exception { Isotopes isofac = Isotopes.getInstance(); Assert.assertEquals(13.00335484, isofac.getIsotope("C", 13).getExactMass(), 0.0000001); }
mw += atom.getExactMass(); else { IIsotope isotope = isotopes.getIsotope(atom.getSymbol(), atom.getMassNumber()); if (isotope == null) mw += isotopes.getNaturalMass(atom);
@Test public void protonateDeuteratedPhenolate() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = bldr.newInstance(IMolecularFormula.class); // [C6DH4O]- (parser not good enough ATM so need to create like this) IIsotope deuterium = Isotopes.getInstance().getIsotope("H", 2); IIsotope hydrogen = Isotopes.getInstance().getMajorIsotope(1); mf.addIsotope(deuterium, 1); mf.addIsotope(hydrogen, 4); mf.addIsotope(Isotopes.getInstance().getMajorIsotope(6), 6); mf.addIsotope(Isotopes.getInstance().getMajorIsotope(8), 1); mf.setCharge(-1); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, +1)); assertThat(MolecularFormulaManipulator.getString(mf), is("C6H6O")); assertThat(mf.getCharge(), is(0)); assertThat(mf.getIsotopeCount(), is(4)); assertThat(mf.getIsotopeCount(deuterium), is(1)); assertThat(mf.getIsotopeCount(hydrogen), is(5)); }
} else { if (exactMass == null) { IIsotope temp = Isotopes.getInstance().getIsotope(isotope.getSymbol(), massNum); if (temp != null) exactMass = temp.getExactMass();