test_class.declarator: builder = SilentChemObjectBuilder.getInstance()
test_class.modifier: private final static
test_class.original_string: private final static IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
test_class.type: IChemObjectBuilder
test_class.var_name: builder
test_class.file: tool/formula/src/test/java/org/openscience/cdk/tools/manipulator/MolecularFormulaRangeManipulatorTest.java
test_class.identifier: MolecularFormulaRangeManipulatorTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testGetRange_IMolecularFormulaSet() {
          IMolecularFormula mf1 = new MolecularFormula(); /* C4H12NO4 */
          mf1.addIsotope(builder.newInstance(IIsotope.class, "C"), 4);
          mf1.addIsotope(builder.newInstance(IIsotope.class, "H"), 12);
          mf1.addIsotope(builder.newInstance(IIsotope.class, "N"), 1);
          mf1.addIsotope(builder.newInstance(IIsotope.class, "O"), 4);
  
          IMolecularFormula mf2 = new MolecularFormula(); /* C7H20N4O2 */
          mf2.addIsotope(builder.newInstance(IIsotope.class, "C"), 7);
          mf2.addIsotope(builder.newInstance(IIsotope.class, "H"), 20);
          mf2.addIsotope(builder.newInstance(IIsotope.class, "N"), 4);
          mf2.addIsotope(builder.newInstance(IIsotope.class, "O"), 2);
  
          IMolecularFormula mf3 = new MolecularFormula(); /* C9H5O7 */
          mf3.addIsotope(builder.newInstance(IIsotope.class, "C"), 9);
          mf3.addIsotope(builder.newInstance(IIsotope.class, "H"), 5);
          mf3.addIsotope(builder.newInstance(IIsotope.class, "O"), 7);
  
          IMolecularFormulaSet mfSet = new MolecularFormulaSet();
          mfSet.addMolecularFormula(mf1);
          mfSet.addMolecularFormula(mf2);
          mfSet.addMolecularFormula(mf3);
  
          MolecularFormulaRange mfRange = MolecularFormulaRangeManipulator.getRange(mfSet);
  
          /* Result: C4-9H5-20N0-4O2-7 */
  
          Assert.assertEquals(4, mfRange.getIsotopeCount());
          Assert.assertEquals(4, mfRange.getIsotopeCountMin(builder.newInstance(IIsotope.class, "C")));
          Assert.assertEquals(9, mfRange.getIsotopeCountMax(builder.newInstance(IIsotope.class, "C")));
          Assert.assertEquals(5, mfRange.getIsotopeCountMin(builder.newInstance(IIsotope.class, "H")));
          Assert.assertEquals(20, mfRange.getIsotopeCountMax(builder.newInstance(IIsotope.class, "H")));
          Assert.assertEquals(0, mfRange.getIsotopeCountMin(builder.newInstance(IIsotope.class, "N")));
          Assert.assertEquals(4, mfRange.getIsotopeCountMax(builder.newInstance(IIsotope.class, "N")));
          Assert.assertEquals(2, mfRange.getIsotopeCountMin(builder.newInstance(IIsotope.class, "O")));
          Assert.assertEquals(7, mfRange.getIsotopeCountMax(builder.newInstance(IIsotope.class, "O")));
  
      }
test_case.class_method_signature: MolecularFormulaRangeManipulatorTest.testGetRange_IMolecularFormulaSet()
test_case.full_signature: @Test public void testGetRange_IMolecularFormulaSet()
test_case.identifier: testGetRange_IMolecularFormulaSet
test_case.invocations: addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addIsotope newInstance addMolecularFormula addMolecularFormula addMolecularFormula getRange assertEquals getIsotopeCount assertEquals getIsotopeCountMin newInstance assertEquals getIsotopeCountMax newInstance assertEquals getIsotopeCountMin newInstance assertEquals getIsotopeCountMax newInstance assertEquals getIsotopeCountMin newInstance assertEquals getIsotopeCountMax newInstance assertEquals getIsotopeCountMin newInstance assertEquals getIsotopeCountMax newInstance
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetRange_IMolecularFormulaSet()
focal_class.file: tool/formula/src/main/java/org/openscience/cdk/tools/manipulator/MolecularFormulaRangeManipulator.java
focal_class.identifier: MolecularFormulaRangeManipulator
focal_class.class_method_signature: MolecularFormulaRangeManipulator.getRange(IMolecularFormulaSet mfSet)
focal_class.full_signature: public static MolecularFormulaRange getRange(IMolecularFormulaSet mfSet)
focal_class.identifier: getRange
focal_class.modifiers: public static
focal_class.parameters: (IMolecularFormulaSet mfSet)
focal_class.return: MolecularFormulaRange
focal_class.signature: MolecularFormulaRange getRange(IMolecularFormulaSet mfSet)
focal_class.class_method_signature: MolecularFormulaRangeManipulator.getMaximalFormula(MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.full_signature: public static IMolecularFormula getMaximalFormula(MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.identifier: getMaximalFormula
focal_class.modifiers: public static
focal_class.parameters: (MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.return: IMolecularFormula
focal_class.signature: IMolecularFormula getMaximalFormula(MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.class_method_signature: MolecularFormulaRangeManipulator.getMinimalFormula(MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.full_signature: public static IMolecularFormula getMinimalFormula(MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.identifier: getMinimalFormula
focal_class.modifiers: public static
focal_class.parameters: (MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_class.return: IMolecularFormula
focal_class.signature: IMolecularFormula getMinimalFormula(MolecularFormulaRange mfRange, IChemObjectBuilder builder)
focal_method.body: public static MolecularFormulaRange getRange(IMolecularFormulaSet mfSet) {
          MolecularFormulaRange mfRange = new MolecularFormulaRange();
  
          for (IMolecularFormula mf : mfSet.molecularFormulas()) {
              for (IIsotope isotope : mf.isotopes()) {
                  int occur_new = mf.getIsotopeCount(isotope);
                  if (!mfRange.contains(isotope)) {
                      mfRange.addIsotope(isotope, occur_new, occur_new);
                  } else {
                      int occur_old_Max = mfRange.getIsotopeCountMax(isotope);
                      int occur_old_Min = mfRange.getIsotopeCountMin(isotope);
                      if (occur_new > occur_old_Max) {
                          mfRange.removeIsotope(isotope);
                          mfRange.addIsotope(isotope, occur_old_Min, occur_new);
                      } else if (occur_new < occur_old_Min) {
                          mfRange.removeIsotope(isotope);
                          mfRange.addIsotope(isotope, occur_new, occur_old_Max);
                      }
                  }
              }
          }
          // looking for those Isotopes which are not contained which then should be 0.
          for (IMolecularFormula mf : mfSet.molecularFormulas()) {
              if (mf.getIsotopeCount() != mfRange.getIsotopeCount()) {
                  for (IIsotope isotope : mfRange.isotopes()) {
                      if (!mf.contains(isotope)) {
                          int occurMax = mfRange.getIsotopeCountMax(isotope);
                          mfRange.addIsotope(isotope, 0, occurMax);
                      }
                  }
              }
          }
          return mfRange;
      }
focal_method.class_method_signature: MolecularFormulaRangeManipulator.getRange(IMolecularFormulaSet mfSet)
focal_method.full_signature: public static MolecularFormulaRange getRange(IMolecularFormulaSet mfSet)
focal_method.identifier: getRange
focal_method.invocations: molecularFormulas isotopes getIsotopeCount contains addIsotope getIsotopeCountMax getIsotopeCountMin removeIsotope addIsotope removeIsotope addIsotope molecularFormulas getIsotopeCount getIsotopeCount isotopes contains getIsotopeCountMax addIsotope
focal_method.modifiers: public static
focal_method.parameters: (IMolecularFormulaSet mfSet)
focal_method.return: MolecularFormulaRange
focal_method.signature: MolecularFormulaRange getRange(IMolecularFormulaSet mfSet)