RDBERule implements IRule { @Override public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ", formula); List<Double> RDBEList = getRDBEValue(formula); for (Iterator<Double> it = RDBEList.iterator(); it.hasNext();) { double RDBE = it.next(); if (min <= RDBE && RDBE <= 30) if (validate(formula, RDBE)) return 1.0; } return 0.0; } RDBERule(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override double validate(IMolecularFormula formula); boolean validate(IMolecularFormula formula, double value); List<Double> getRDBEValue(IMolecularFormula formula);  }
@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); }
@Test public void testDefaultValidTrue() throws ClassNotFoundException, CDKException, Exception { IRule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C1H4", builder); formula.setCharge(0); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
@Test public void testValidate_IMolecularFormula_double() throws ClassNotFoundException, CDKException, Exception { RDBERule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C2H4", builder); Assert.assertTrue(rule.validate(formula, 2.0)); }
@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); }
@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); }
@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); }
@Test public void testPCCharged() throws ClassNotFoundException, CDKException, Exception { RDBERule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C42H85NO8P", builder); formula.setCharge(1); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }
@Test public void testB() throws ClassNotFoundException, CDKException, Exception { RDBERule rule = new RDBERule(); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C6H9BNO2", builder); formula.setCharge(1); Assert.assertEquals(1.0, rule.validate(formula), 0.0001); }