test_class.declarator: builder
test_class.modifier: private static
test_class.original_string: private static IChemObjectBuilder builder;
test_class.type: IChemObjectBuilder
test_class.var_name: builder
test_class.file: tool/formula/src/test/java/org/openscience/cdk/formula/rules/RDBERuleTest.java
test_class.identifier: RDBERuleTest
test_class.superclass: extends FormulaRuleTest
test_case.body: @Test
      public void testGetRDBEValue_IMolecularFormula() throws ClassNotFoundException, CDKException, Exception {
  
          RDBERule rule = new RDBERule();
  
          IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C2H4", builder);
  
          Assert.assertEquals(1.0, rule.getRDBEValue(formula).get(0), 0.0001);
      }
test_case.class_method_signature: RDBERuleTest.testGetRDBEValue_IMolecularFormula()
test_case.full_signature: @Test public void testGetRDBEValue_IMolecularFormula()
test_case.identifier: testGetRDBEValue_IMolecularFormula
test_case.invocations: getMajorIsotopeMolecularFormula assertEquals get getRDBEValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetRDBEValue_IMolecularFormula()
focal_class.declarator: oxidationStateTable = null
focal_class.modifier: private static
focal_class.original_string: private static Map<String, int[]> oxidationStateTable = null;
focal_class.type: Map<String, int[]>
focal_class.var_name: oxidationStateTable
focal_class.declarator: logger              = LoggingToolFactory.createLoggingTool(RDBERule.class)
focal_class.modifier: private static
focal_class.original_string: private static ILoggingTool       logger              = LoggingToolFactory.createLoggingTool(RDBERule.class);
focal_class.type: ILoggingTool
focal_class.var_name: logger
focal_class.declarator: min                 = -0.5
focal_class.modifier: private
focal_class.original_string: private double                    min                 = -0.5;
focal_class.type: double
focal_class.var_name: min
focal_class.declarator: max                 = 30
focal_class.modifier: private
focal_class.original_string: private double                    max                 = 30;
focal_class.type: double
focal_class.var_name: max
focal_class.file: tool/formula/src/main/java/org/openscience/cdk/formula/rules/RDBERule.java
focal_class.identifier: RDBERule
focal_class.interfaces: implements IRule
focal_class.class_method_signature: RDBERule.RDBERule()
focal_class.full_signature: public  RDBERule()
focal_class.identifier: RDBERule
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  RDBERule()
focal_class.class_method_signature: RDBERule.setParameters(Object[] params)
focal_class.full_signature: @Override public void setParameters(Object[] params)
focal_class.identifier: setParameters
focal_class.modifiers: @Override public
focal_class.parameters: (Object[] params)
focal_class.return: void
focal_class.signature: void setParameters(Object[] params)
focal_class.class_method_signature: RDBERule.getParameters()
focal_class.full_signature: @Override public Object[] getParameters()
focal_class.identifier: getParameters
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Object[]
focal_class.signature: Object[] getParameters()
focal_class.class_method_signature: RDBERule.validate(IMolecularFormula formula)
focal_class.full_signature: @Override public double validate(IMolecularFormula formula)
focal_class.identifier: validate
focal_class.modifiers: @Override public
focal_class.parameters: (IMolecularFormula formula)
focal_class.return: double
focal_class.signature: double validate(IMolecularFormula formula)
focal_class.class_method_signature: RDBERule.validate(IMolecularFormula formula, double value)
focal_class.full_signature: public boolean validate(IMolecularFormula formula, double value)
focal_class.identifier: validate
focal_class.modifiers: public
focal_class.parameters: (IMolecularFormula formula, double value)
focal_class.return: boolean
focal_class.signature: boolean validate(IMolecularFormula formula, double value)
focal_class.class_method_signature: RDBERule.getRDBEValue(IMolecularFormula formula)
focal_class.full_signature: public List<Double> getRDBEValue(IMolecularFormula formula)
focal_class.identifier: getRDBEValue
focal_class.modifiers: public
focal_class.parameters: (IMolecularFormula formula)
focal_class.return: List<Double>
focal_class.signature: List<Double> getRDBEValue(IMolecularFormula formula)
focal_class.class_method_signature: RDBERule.getOxidationState(IAtom newAtom)
focal_class.full_signature: private int[] getOxidationState(IAtom newAtom)
focal_class.identifier: getOxidationState
focal_class.modifiers: private
focal_class.parameters: (IAtom newAtom)
focal_class.return: int[]
focal_class.signature: int[] getOxidationState(IAtom newAtom)
focal_class.class_method_signature: RDBERule.createTable()
focal_class.full_signature: private void createTable()
focal_class.identifier: createTable
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void createTable()
focal_method.body: public List<Double> getRDBEValue(IMolecularFormula formula) {
          List<Double> RDBEList = new ArrayList<Double>();
          // The number of combinations with repetition
          // (v+n-1)!/[n!(v-1)!]
          int nE = 0; // number of elements to change
          List<Integer> nV = new ArrayList<Integer>(); // number of valence changing
          for (Iterator<IIsotope> it = formula.isotopes().iterator(); it.hasNext();) {
              IIsotope isotope = it.next();
              int[] valence = getOxidationState(formula.getBuilder().newInstance(IAtom.class, isotope.getSymbol()));
              if (valence.length != 1) {
                  for (int i = 0; i < valence.length; i++) {
                      nV.add(valence[i]);
                  }
                  nE += MolecularFormulaManipulator.getElementCount(formula,
                          formula.getBuilder().newInstance(IElement.class, isotope.getSymbol()));
              }
          }
  
          double RDBE = 0;
          if (nE == 0) {
              for (Iterator<IIsotope> it = formula.isotopes().iterator(); it.hasNext();) {
                  IIsotope isotope = it.next();
                  int[] valence = getOxidationState(formula.getBuilder().newInstance(IAtom.class, isotope.getSymbol()));
                  double value = (valence[0] - 2) * formula.getIsotopeCount(isotope) / 2.0;
                  RDBE += value;
              }
              RDBE += 1;
              RDBEList.add(RDBE);
          } else {
              double RDBE_1 = 0;
              for (Iterator<IIsotope> it = formula.isotopes().iterator(); it.hasNext();) {
                  IIsotope isotope = it.next();
                  int[] valence = getOxidationState(formula.getBuilder().newInstance(IAtom.class, isotope.getSymbol()));
                  double value = (valence[0] - 2) * formula.getIsotopeCount(isotope) * 0.5;
                  RDBE_1 += value;
              }
              String[] valences = new String[nV.size()];
              for (int i = 0; i < valences.length; i++)
                  valences[i] = Integer.toString(nV.get(i));
  
              Combinations c = new Combinations(valences, nE);
              while (c.hasMoreElements()) {
                  double RDBE_int = 0.0;
                  Object[] combo = (Object[]) c.nextElement();
                  for (int i = 0; i < combo.length; i++) {
                      int value = (Integer.parseInt((String) combo[i]) - 2) / 2;
                      RDBE_int += value;
                  }
                  RDBE = 1 + RDBE_1 + RDBE_int;
                  RDBEList.add(RDBE);
              }
          }
          return RDBEList;
      }
focal_method.class_method_signature: RDBERule.getRDBEValue(IMolecularFormula formula)
focal_method.full_signature: public List<Double> getRDBEValue(IMolecularFormula formula)
focal_method.identifier: getRDBEValue
focal_method.invocations: iterator isotopes hasNext next getOxidationState newInstance getBuilder getSymbol add getElementCount newInstance getBuilder getSymbol iterator isotopes hasNext next getOxidationState newInstance getBuilder getSymbol getIsotopeCount add iterator isotopes hasNext next getOxidationState newInstance getBuilder getSymbol getIsotopeCount size toString get hasMoreElements nextElement parseInt add
focal_method.modifiers: public
focal_method.parameters: (IMolecularFormula formula)
focal_method.return: List<Double>
focal_method.signature: List<Double> getRDBEValue(IMolecularFormula formula)