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/formula/IsotopePatternSimilarityTest.java
test_class.identifier: IsotopePatternSimilarityTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testExperiment() {
  
          IsotopePattern spExp = new IsotopePattern();
          spExp.setMonoIsotope(new IsotopeContainer(762.6006, 124118304));
          spExp.addIsotope(new IsotopeContainer(763.6033, 57558840));
          spExp.addIsotope(new IsotopeContainer(764.6064, 15432262));
          spExp.setCharge(1.0);
  
          IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C42H85NO8P",
                  SilentChemObjectBuilder.getInstance());
  
          IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.01);
          IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula);
  
          IsotopePatternSimilarity is = new IsotopePatternSimilarity();
          double score = is.compare(spExp, patternIsoPredicted);
  
          Assert.assertEquals(0.97, score, .01);
      }
test_case.class_method_signature: IsotopePatternSimilarityTest.testExperiment()
test_case.full_signature: @Test public void testExperiment()
test_case.identifier: testExperiment
test_case.invocations: setMonoIsotope addIsotope addIsotope setCharge getMajorIsotopeMolecularFormula getInstance getIsotopes compare assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testExperiment()
focal_class.declarator: chargeToAdd
focal_class.modifier: private
focal_class.original_string: private double        chargeToAdd;
focal_class.type: double
focal_class.var_name: chargeToAdd
focal_class.declarator: tolerance_ppm = 1
focal_class.modifier: private
focal_class.original_string: private double        tolerance_ppm = 1;
focal_class.type: double
focal_class.var_name: tolerance_ppm
focal_class.declarator: massE         = 0.0005485
focal_class.modifier: private static
focal_class.original_string: private static double massE         = 0.0005485;
focal_class.type: double
focal_class.var_name: massE
focal_class.file: tool/formula/src/main/java/org/openscience/cdk/formula/IsotopePatternSimilarity.java
focal_class.identifier: IsotopePatternSimilarity
focal_class.class_method_signature: IsotopePatternSimilarity.IsotopePatternSimilarity()
focal_class.full_signature: public  IsotopePatternSimilarity()
focal_class.identifier: IsotopePatternSimilarity
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  IsotopePatternSimilarity()
focal_class.class_method_signature: IsotopePatternSimilarity.seTolerance(double tolerance)
focal_class.full_signature: public void seTolerance(double tolerance)
focal_class.identifier: seTolerance
focal_class.modifiers: public
focal_class.parameters: (double tolerance)
focal_class.return: void
focal_class.signature: void seTolerance(double tolerance)
focal_class.class_method_signature: IsotopePatternSimilarity.getTolerance()
focal_class.full_signature: public double getTolerance()
focal_class.identifier: getTolerance
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getTolerance()
focal_class.class_method_signature: IsotopePatternSimilarity.compare(IsotopePattern isoto1, IsotopePattern isoto2)
focal_class.full_signature: public double compare(IsotopePattern isoto1, IsotopePattern isoto2)
focal_class.identifier: compare
focal_class.modifiers: public
focal_class.parameters: (IsotopePattern isoto1, IsotopePattern isoto2)
focal_class.return: double
focal_class.signature: double compare(IsotopePattern isoto1, IsotopePattern isoto2)
focal_class.class_method_signature: IsotopePatternSimilarity.getClosestDataDiff(IsotopeContainer isoContainer, IsotopePattern pattern)
focal_class.full_signature: private int getClosestDataDiff(IsotopeContainer isoContainer, IsotopePattern pattern)
focal_class.identifier: getClosestDataDiff
focal_class.modifiers: private
focal_class.parameters: (IsotopeContainer isoContainer, IsotopePattern pattern)
focal_class.return: int
focal_class.signature: int getClosestDataDiff(IsotopeContainer isoContainer, IsotopePattern pattern)
focal_method.body: public double compare(IsotopePattern isoto1, IsotopePattern isoto2) {
  
          IsotopePattern iso1 = IsotopePatternManipulator.sortAndNormalizedByIntensity(isoto1);
          IsotopePattern iso2 = IsotopePatternManipulator.sortAndNormalizedByIntensity(isoto2);
  
          /* charge to add */
          if (isoto1.getCharge() == 1)
              chargeToAdd = massE;
          else if (isoto1.getCharge() == -1)
              chargeToAdd = -massE;
          else
              chargeToAdd = 0;
  
          for (IsotopeContainer isoC : iso1.getIsotopes()) {
              double mass = isoC.getMass();
              isoC.setMass(mass + chargeToAdd);
          }
  
          double diffMass, diffAbun, factor, totalFactor = 0d;
          double score = 0d, tempScore;
          // Maximum number of isotopes to be compared according predicted isotope
          // pattern. It is assumed that this will have always more isotopeContainers
          int length = iso1.getNumberOfIsotopes();
  
          for (int i = 0; i < length; i++) {
              IsotopeContainer isoContainer = iso1.getIsotopes().get(i);
              factor = isoContainer.getIntensity();
              totalFactor += factor;
  
              // Search for the closest isotope in the second pattern (detected) to the
              // current isotope (predicted pattern)
              int closestDp = getClosestDataDiff(isoContainer, iso2);
              if (closestDp == -1) continue;
  
              diffMass = isoContainer.getMass() - iso2.getIsotopes().get(closestDp).getMass();
              diffMass = Math.abs(diffMass);
  
              diffAbun = 1.0d - (isoContainer.getIntensity() / iso2.getIsotopes().get(closestDp).getIntensity());
              diffAbun = Math.abs(diffAbun);
  
              tempScore = 1 - (diffMass + diffAbun);
  
              if (tempScore < 0) tempScore = 0;
  
              score += (tempScore * factor);
  
          }
  
          return score / totalFactor;
      }
focal_method.class_method_signature: IsotopePatternSimilarity.compare(IsotopePattern isoto1, IsotopePattern isoto2)
focal_method.full_signature: public double compare(IsotopePattern isoto1, IsotopePattern isoto2)
focal_method.identifier: compare
focal_method.invocations: sortAndNormalizedByIntensity sortAndNormalizedByIntensity getCharge getCharge getIsotopes getMass setMass getNumberOfIsotopes get getIsotopes getIntensity getClosestDataDiff getMass getMass get getIsotopes abs getIntensity getIntensity get getIsotopes abs
focal_method.modifiers: public
focal_method.parameters: (IsotopePattern isoto1, IsotopePattern isoto2)
focal_method.return: double
focal_method.signature: double compare(IsotopePattern isoto1, IsotopePattern isoto2)