/** * Constructor for the RDBE object. */ public RDBERule() { createTable(); }
/** * Constructor for the MMElementRule object. */ public MMElementRule() { // initiate Hashmap default this.hashMap = getWisley_500(); }
/** * @return java.lang.Object, the next combination from the supplied Object array. * <p> * Actually, an array of Objects is returned. The declaration must say just Object, * because the Combinations class implements Enumeration, which declares that the * nextElement() returns a plain Object. Users must cast the returned object to (Object[]). */ public Object nextElement() { if (!hasMore) return null; Object[] out = new Object[m]; for (int i = 0; i < m; i++) { out[i] = inArray[index[i]]; } moveIndex(); return out; }
/** * 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 ChargeRule(); Object[] params = new Object[1]; params[0] = -1.0; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertEquals(1, objects.length); double charge = (Double) objects[0]; Assert.assertEquals(-1.0, charge, 0.00001); }
/** * 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 testSetParameters() throws Exception { IRule rule = new MMElementRule(); Object[] params = new Object[2]; params[0] = MMElementRule.Database.DNP; params[1] = MMElementRule.RangeMass.Minus1000; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertSame(MMElementRule.Database.DNP, objects[0]); Assert.assertSame(MMElementRule.RangeMass.Minus1000, objects[1]); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefault() throws ClassNotFoundException, CDKException, Exception { IRule rule = new ChargeRule(); Object[] objects = rule.getParameters(); Assert.assertEquals(1, objects.length); double charge = (Double) objects[0]; Assert.assertEquals(0.0, charge, 0.00001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefault() throws Exception { IRule rule = new ToleranceRangeRule(); Object[] objects = rule.getParameters(); Assert.assertEquals(2, objects.length); double mass = (Double) objects[0]; Assert.assertEquals(0.0, mass, 0.00001); double tolerance = (Double) objects[1]; Assert.assertEquals(0.05, tolerance, 0.00001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefault() throws Exception { IRule rule = new IsotopePatternRule(); Object[] objects = rule.getParameters(); Assert.assertNull(objects[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 testDefault() throws Exception { IRule rule = new MMElementRule(); Object[] objects = rule.getParameters(); Assert.assertSame(MMElementRule.Database.WILEY, objects[0]); Assert.assertSame(MMElementRule.RangeMass.Minus500, objects[1]); }
/** * 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 testDefault() throws ClassNotFoundException, CDKException, Exception { IRule rule = new RDBERule(); Object[] objects = rule.getParameters(); Assert.assertEquals(2, objects.length); double min = (Double) objects[0]; double max = (Double) objects[1]; Assert.assertEquals(-0.5, min, 0.00001); Assert.assertEquals(30, max, 0.00001); }
/** * Move the index forward a notch. The algorithm finds the rightmost * index element that can be incremented, increments it, and then * changes the elements to the right to each be 1 plus the element on their left. * <p> * For example, if an index of 5 things taken 3 at a time is at {0 3 4}, only the 0 can * be incremented without running out of room. The next index is {1, 1+1, 1+2) or * {1, 2, 3}. This will be followed by {1, 2, 4}, {1, 3, 4}, and {2, 3, 4}. * <p> * The algorithm is from Applied Combinatorics, by Alan Tucker. * */ private void moveIndex() { int i = rightmostIndexBelowMax(); if (i >= 0) { index[i] = index[i] + 1; for (int j = i + 1; j < m; j++) index[j] = index[j - 1]; } else hasMore = false; }
public static void setRule(Class<? extends IRule> ruleClass) throws Exception { FormulaRuleTest.ruleClass = ruleClass; FormulaRuleTest.rule = getRule(); }
/** * 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.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); }