@Test public void protonatePhenolateMajorIsotopes() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("[C6H5O]-", bldr); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, +1)); assertThat(MolecularFormulaManipulator.getString(mf), is("C6H6O")); assertThat(mf.getCharge(), is(0)); assertThat(mf.getIsotopeCount(), is(3)); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefaultValidFalse() throws ClassNotFoundException, CDKException, Exception { IRule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C2H4", builder); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefaultValidFalse() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C2H4", builder); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit.NH4+ * * @return The test suite */ @Test public void testAnticipatedIonState_2() throws ClassNotFoundException, CDKException, Exception { RDBERule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("NH4", builder); Assert.assertEquals(0.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit.C4H8O3S1 * * @return The test suite */ @Test public void test2() throws ClassNotFoundException, CDKException, Exception { RDBERule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C4H8O3S1", builder); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit.NH4+ * * @return The test suite */ @Test public void testAnticipatedIonState_1() throws ClassNotFoundException, CDKException, Exception { RDBERule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("NH4", builder); formula.setCharge(1); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testC45H71N7O10() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C45H71N7O10", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testNPlus() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("NH4", builder); formula.setCharge(1); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testC47H75N5O10() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C47H75N5O10", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test for JUnit: * * @return Description of the Return Value */ @Test public void testGetIsotopes_IMolecularFormula() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C41H79N8O3P1", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(2, isos.getNumberOfIsotopes(), 0.001); }
/** * A unit test for JUnit: * * @return Description of the Return Value */ @Test public void testGetIsotopes_IMolecularFormula_withoutONE() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C41H79N8O3P", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.01); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(6, isos.getNumberOfIsotopes(), 0.001); }
/** * A unit test suite for JUnit.C2H11N4O4 * * @return The test suite */ @Test public void testDefaultValidFalse_SetParam() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C2H11N4O4", builder); formula.setCharge(1); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testC45H75NO15() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C45H75NO15", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testC50H95NO10() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C50H95NO10", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefaultValidTrue() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C4H13N1O5", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testC49H75NO12() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C49H75NO12", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testN() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("NH3", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * Calculate isotopes for C20H30Fe2P2S4Cl4 (in CDK 1.5.12, this call * sometimes returns 34 and sometimes 35 isotopes, non-deterministically). */ @Ignore("Non-deterministic test value is bad! This likely depends on our current isotope data which is also bad.") public void testCalculateIsotopesC20H30Fe2P2S4Cl4() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C20H30Fe2P2S4Cl4", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.01); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(35, isos.getNumberOfIsotopes()); }
/** * Calculate isotopes for C10000 (failed in CDK 1.5.12). */ @Test public void testCalculateIsotopesC10000() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C10000", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(44, isos.getNumberOfIsotopes()); for (int i = 0; i < isos.getNumberOfIsotopes(); i++) Assert.assertTrue(isos.getIsotope(i).getMass() > 120085); }
/** Test formula mass calculation */ @Test public void testGetMajorIsotopeMolecularFormula_String_IChemObjectBuilder() throws Exception { IMolecularFormula mf2 = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C11H17", builder); Assert.assertEquals(28, MolecularFormulaManipulator.getAtomCount(mf2)); Assert.assertEquals(2, mf2.getIsotopeCount()); IIsotope carbon = Isotopes.getInstance().getMajorIsotope("C"); IIsotope hydrogen = Isotopes.getInstance().getMajorIsotope("H"); double totalMass = carbon.getExactMass() * 11; totalMass += hydrogen.getExactMass() * 17; Assert.assertEquals(totalMass, MolecularFormulaManipulator.getTotalExactMass(mf2), 0.0000001); }