test_class.file: tool/formula/src/test/java/org/openscience/cdk/formula/IsotopePatternManipulatorTest.java
test_class.identifier: IsotopePatternManipulatorTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testSortByIntensity_IsotopePattern() {
          IsotopePattern spExp = new IsotopePattern();
          spExp.setMonoIsotope(new IsotopeContainer(157.07503, 0.0001));
          spExp.addIsotope(new IsotopeContainer(156.07770, 1));
          spExp.addIsotope(new IsotopeContainer(157.08059, 0.0003));
          spExp.addIsotope(new IsotopeContainer(158.08135, 0.002));
          spExp.setCharge(1);
  
          IsotopePattern isoNorma = IsotopePatternManipulator.sortByIntensity(spExp);
          List<IsotopeContainer> listISO = isoNorma.getIsotopes();
          Assert.assertEquals(156.07770, isoNorma.getMonoIsotope().getMass(), 0.00001);
          Assert.assertEquals(156.07770, listISO.get(0).getMass(), 0.00001);
          Assert.assertEquals(158.08135, listISO.get(1).getMass(), 0.00001);
          Assert.assertEquals(157.08059, listISO.get(2).getMass(), 0.00001);
          Assert.assertEquals(157.07503, listISO.get(3).getMass(), 0.00001);
  
          Assert.assertEquals(1, isoNorma.getMonoIsotope().getIntensity(), 0.00001);
          Assert.assertEquals(1, listISO.get(0).getIntensity(), 0.00001);
          Assert.assertEquals(0.002, listISO.get(1).getIntensity(), 0.00001);
          Assert.assertEquals(0.0003, listISO.get(2).getIntensity(), 0.001);
          Assert.assertEquals(0.0001, listISO.get(3).getIntensity(), 0.00001);
  
          Assert.assertEquals(1, isoNorma.getCharge(), 0.00001);
      }
test_case.class_method_signature: IsotopePatternManipulatorTest.testSortByIntensity_IsotopePattern()
test_case.full_signature: @Test public void testSortByIntensity_IsotopePattern()
test_case.identifier: testSortByIntensity_IsotopePattern
test_case.invocations: setMonoIsotope addIsotope addIsotope addIsotope setCharge sortByIntensity getIsotopes assertEquals getMass getMonoIsotope assertEquals getMass get assertEquals getMass get assertEquals getMass get assertEquals getMass get assertEquals getIntensity getMonoIsotope assertEquals getIntensity get assertEquals getIntensity get assertEquals getIntensity get assertEquals getIntensity get assertEquals getCharge
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSortByIntensity_IsotopePattern()
focal_class.file: tool/formula/src/main/java/org/openscience/cdk/formula/IsotopePatternManipulator.java
focal_class.identifier: IsotopePatternManipulator
focal_class.class_method_signature: IsotopePatternManipulator.normalize(IsotopePattern isotopeP)
focal_class.full_signature: public static IsotopePattern normalize(IsotopePattern isotopeP)
focal_class.identifier: normalize
focal_class.modifiers: public static
focal_class.parameters: (IsotopePattern isotopeP)
focal_class.return: IsotopePattern
focal_class.signature: IsotopePattern normalize(IsotopePattern isotopeP)
focal_class.class_method_signature: IsotopePatternManipulator.sortAndNormalizedByIntensity(IsotopePattern isotopeP)
focal_class.full_signature: public static IsotopePattern sortAndNormalizedByIntensity(IsotopePattern isotopeP)
focal_class.identifier: sortAndNormalizedByIntensity
focal_class.modifiers: public static
focal_class.parameters: (IsotopePattern isotopeP)
focal_class.return: IsotopePattern
focal_class.signature: IsotopePattern sortAndNormalizedByIntensity(IsotopePattern isotopeP)
focal_class.class_method_signature: IsotopePatternManipulator.sortByIntensity(IsotopePattern isotopeP)
focal_class.full_signature: public static IsotopePattern sortByIntensity(IsotopePattern isotopeP)
focal_class.identifier: sortByIntensity
focal_class.modifiers: public static
focal_class.parameters: (IsotopePattern isotopeP)
focal_class.return: IsotopePattern
focal_class.signature: IsotopePattern sortByIntensity(IsotopePattern isotopeP)
focal_class.class_method_signature: IsotopePatternManipulator.sortByMass(IsotopePattern isotopeP)
focal_class.full_signature: public static IsotopePattern sortByMass(IsotopePattern isotopeP)
focal_class.identifier: sortByMass
focal_class.modifiers: public static
focal_class.parameters: (IsotopePattern isotopeP)
focal_class.return: IsotopePattern
focal_class.signature: IsotopePattern sortByMass(IsotopePattern isotopeP)
focal_method.body: public static IsotopePattern sortByIntensity(IsotopePattern isotopeP) {
          try {
              
              IsotopePattern isoSort = (IsotopePattern) isotopeP.clone();
              
              // Do nothing for empty isotope pattern
              if (isoSort.getNumberOfIsotopes() == 0)
                  return isoSort;
  
              // Sort the isotopes
              List<IsotopeContainer> listISO = isoSort.getIsotopes();
              Collections.sort(listISO, new Comparator<IsotopeContainer>() {
                  @Override
                  public int compare(IsotopeContainer o1, IsotopeContainer o2) {
                      return Double.compare(o2.getIntensity(),o1.getIntensity());
                  }
              });
             
              // Set the monoisotopic peak to the one with highest intensity
              isoSort.setMonoIsotope(listISO.get(0));
              
              return isoSort;
  
          } catch (CloneNotSupportedException e) {
              e.printStackTrace();
          }
  
          return null;
      }
focal_method.class_method_signature: IsotopePatternManipulator.sortByIntensity(IsotopePattern isotopeP)
focal_method.full_signature: public static IsotopePattern sortByIntensity(IsotopePattern isotopeP)
focal_method.identifier: sortByIntensity
focal_method.invocations: clone getNumberOfIsotopes getIsotopes sort compare getIntensity getIntensity setMonoIsotope get printStackTrace
focal_method.modifiers: public static
focal_method.parameters: (IsotopePattern isotopeP)
focal_method.return: IsotopePattern
focal_method.signature: IsotopePattern sortByIntensity(IsotopePattern isotopeP)