/** * Constructor of the IsotopeContainer object setting a IMolecularFormula * object and intensity value. * * @param formula The formula of this container * @param intensity The intensity of this container */ public IsotopeContainer(IMolecularFormula formula, double intensity) { forms.add(formula); if (formula != null) masOs = MolecularFormulaManipulator.getTotalExactMass(formula); inte = intensity; }
/** * Validate the Tolerance Range of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ @Override public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ", formula); double totalExactMass = MolecularFormulaManipulator.getTotalExactMass(formula); if (Math.abs(totalExactMass - mass) > tolerance) return 0.0; else return 1.0; }
double massMim = MolecularFormulaManipulator.getTotalExactMass(minimalMF) - tolerance; double massMap = MolecularFormulaManipulator.getTotalExactMass(maximalMF) + tolerance; if (massMim > mass || massMap < mass) { logger.error("Proposed mass is out of the range: ", mass);
if (listI.contains(i)) continue; double value = MolecularFormulaManipulator.getTotalExactMass(formulaSet.getMolecularFormula(i)); double diff = Math.abs(mass - Math.abs(value)); if (valueMin > diff) {
/** * Test total Exact Mass. * * @throws IOException * @throws ClassNotFoundException * @throws CDKException */ @Test public void testGetTotalExactMassWithCharge_IMolecularFormula() throws Exception { IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("CH5O", builder); double totalExactMass = MolecularFormulaManipulator.getTotalExactMass(formula); Assert.assertEquals(33.034040, totalExactMass, 0.0001); formula.setCharge(1); double totalExactMass2 = MolecularFormulaManipulator.getTotalExactMass(formula); Assert.assertEquals(33.03349, totalExactMass2, 0.0001); }
/** * Test total Exact Mass. * * @throws IOException * @throws ClassNotFoundException * @throws CDKException */ @Test public void testGetTotalExactMassWithChargeNeg_IMolecularFormula() throws IOException, ClassNotFoundException { IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("H2PO4", builder); formula.setCharge(-1); double totalExactMass2 = MolecularFormulaManipulator.getTotalExactMass(formula); Assert.assertEquals(96.96961875390926, totalExactMass2, 0.0001); }
@Test public void noNullPointerExceptionForExactMassOfRGroups() throws Exception { IMolecularFormula formula = new MolecularFormula(); formula.addIsotope(new Isotope("C")); formula.addIsotope(new Isotope("H"), 3); formula.addIsotope(new Isotope("R")); assertThat(MolecularFormulaManipulator.getTotalExactMass(formula), closeTo(15.0234, 0.01)); }
pri = Math.pow(eval[0] * eval[1] * eval[2], 1.0 / 3.0); else pri = Math.sqrt(eval[0] * ccf / MolecularFormulaManipulator.getTotalExactMass(formula)); retval.add(Math.sqrt(Math.PI * 2 * pri * ccf / MolecularFormulaManipulator.getTotalExactMass(formula)));
/** * Test total Exact Mass. It is necessary to have added the * corresponding isotope before to calculate the exact mass. * */ @Test public void testBug_1944604() throws Exception { IMolecularFormula formula = new MolecularFormula(); IIsotope carb = builder.newInstance(IIsotope.class, "C"); formula.addIsotope(carb); Assert.assertEquals("C1", MolecularFormulaManipulator.getString(formula, true)); double totalExactMass = MolecularFormulaManipulator.getTotalExactMass(formula); Assert.assertEquals(12.0, totalExactMass, 0.000001); }
pri = Math.pow(eval[0] * eval[1] * eval[2], 1.0 / 3.0); else pri = Math.sqrt(eval[0] * ccf / MolecularFormulaManipulator.getTotalExactMass(formula)); retval.add(Math.sqrt(Math.PI * 2 * pri * ccf / MolecularFormulaManipulator.getTotalExactMass(formula)));
/** * Test total Exact Mass. */ @Test public void testGetTotalExactMass_IMolecularFormula() throws Exception { IMolecularFormula formula = new MolecularFormula(); IIsotope carb = builder.newInstance(IIsotope.class, "C"); carb.setExactMass(12.00); IIsotope cl = builder.newInstance(IIsotope.class, "Cl"); cl.setExactMass(34.96885268); formula.addIsotope(carb); formula.addIsotope(cl); double totalExactMass = MolecularFormulaManipulator.getTotalExactMass(formula); Assert.assertEquals(46.96885268, totalExactMass, 0.000001); }
/** * Tests that an atom which has not be configured with isotope information, * provides the correct exact mass. * @cdk.bug 1944604 */ @Test public void testSingleAtomFromSmiles() throws CDKException { IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("C")); // previously performed inside SmilesParser AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); CDKHydrogenAdder.getInstance(DefaultChemObjectBuilder.getInstance()).addImplicitHydrogens(mol); IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula(mol); double exactMass = MolecularFormulaManipulator.getTotalExactMass(mf); Assert.assertEquals(16.0313, exactMass, 0.0001); }
/** 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); }