/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testNitrogenRule() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); Assert.assertNotNull(rule); }
/** * Validate the nitrogen rule 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 mass = MolecularFormulaManipulator.getTotalMassNumber(formula); if (mass == 0) return 0.0; int numberN = MolecularFormulaManipulator.getElementCount(formula, formula.getBuilder().newInstance(IElement.class, "N")); numberN += getOthers(formula); if (formula.getCharge() == null || formula.getCharge() == 0 || !isOdd(Math.abs(formula.getCharge()))) { if (isOdd(mass) && isOdd(numberN)) { return 1.0; } else if (!isOdd(mass) && (numberN == 0 || !isOdd(numberN))) { return 1.0; } else return 0.0; } else { if (!isOdd(mass) && isOdd(numberN)) { return 1.0; } else if (isOdd(mass) && (numberN == 0 || !isOdd(numberN))) { return 1.0; } else return 0.0; } }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefault() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); Object[] objects = rule.getParameters(); Assert.assertNull(objects); }
/** * 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. * * @return The test suite */ @Test public void testSetParameters() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); rule.setParameters(null); Object[] objects = rule.getParameters(); Assert.assertNull(objects); }
/** * 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. Compounds like Fe, Co, Hg, Pt, As.C40H46FeN6O8S2 * * @return The test suite */ @Test public void testWithFe() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula("C40H46FeN6O8S2", builder); formula.setCharge(2); 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 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 testDoubleCharge() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula("C22H34N2S2", builder); formula.setCharge(2); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
/** * A unit test suite for JUnit. Compounds like Fe, Co, Hg, Pt, As.C40H46FeN6O8S2 * * @return The test suite */ @Test public void testWithCo() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula("C43H50CoN4O16", 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 testC36H42N2O23() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C36H42N2O23", 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); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testNominalMass() throws ClassNotFoundException, CDKException, Exception { IRule rule = new NitrogenRule(); IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula("C25H53NO7P", builder); formula.setCharge(1); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }