test_class.declarator: smiles = new SmilesParser(SilentChemObjectBuilder.getInstance())
test_class.modifier: static
test_class.original_string: static SmilesParser smiles = new SmilesParser(SilentChemObjectBuilder.getInstance());
test_class.type: SmilesParser
test_class.var_name: smiles
test_class.file: descriptor/cip/src/test/java/org/openscience/cdk/geometry/cip/rules/CIPLigandRuleTest.java
test_class.identifier: CIPLigandRuleTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testDeepRecursion() throws Exception {
          IAtomContainer molecule = smiles.parseSmiles("CC([H])(CCCCCCCCCC)CCCCCCCCC");
          ILigand ligand1 = CIPTool.defineLigand(molecule, new VisitedAtoms(), 1, 3);
          ILigand ligand2 = CIPTool.defineLigand(molecule, new VisitedAtoms(), 1, 13);
          ISequenceSubRule<ILigand> rule = new CIPLigandRule();
          Assert.assertEquals(1, rule.compare(ligand1, ligand2));
          Assert.assertEquals(-1, rule.compare(ligand2, ligand1));
      }
test_case.class_method_signature: CIPLigandRuleTest.testDeepRecursion()
test_case.full_signature: @Test public void testDeepRecursion()
test_case.identifier: testDeepRecursion
test_case.invocations: parseSmiles defineLigand defineLigand assertEquals compare assertEquals compare
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDeepRecursion()
focal_class.declarator: numberRule = new CombinedAtomicMassNumberRule()
focal_class.original_string: CombinedAtomicMassNumberRule numberRule = new CombinedAtomicMassNumberRule();
focal_class.type: CombinedAtomicMassNumberRule
focal_class.var_name: numberRule
focal_class.file: descriptor/cip/src/main/java/org/openscience/cdk/geometry/cip/rules/CIPLigandRule.java
focal_class.identifier: CIPLigandRule
focal_class.interfaces: implements ISequenceSubRule<ILigand>
focal_class.class_method_signature: CIPLigandRule.compare(ILigand ligand1, ILigand ligand2)
focal_class.full_signature: @Override public int compare(ILigand ligand1, ILigand ligand2)
focal_class.identifier: compare
focal_class.modifiers: @Override public
focal_class.parameters: (ILigand ligand1, ILigand ligand2)
focal_class.return: int
focal_class.signature: int compare(ILigand ligand1, ILigand ligand2)
focal_class.class_method_signature: CIPLigandRule.order(ILigand[] ligands)
focal_class.full_signature: private ILigand[] order(ILigand[] ligands)
focal_class.identifier: order
focal_class.modifiers: private
focal_class.parameters: (ILigand[] ligands)
focal_class.return: ILigand[]
focal_class.signature: ILigand[] order(ILigand[] ligands)
focal_method.body: @Override
      public int compare(ILigand ligand1, ILigand ligand2) {
          int numberComp = numberRule.compare(ligand1, ligand2);
          if (numberComp != 0) return numberComp;
  
          // OK, now I need to recurse...
          ILigand[] ligand1Ligands = CIPTool.getLigandLigands(ligand1);
          ILigand[] ligand2Ligands = CIPTool.getLigandLigands(ligand2);
          // if neither have ligands:
          if (ligand1Ligands.length == 0 && ligand2Ligands.length == 0) return 0;
          // else if one has no ligands
          if (ligand1Ligands.length == 0) return -1;
          if (ligand2Ligands.length == 0) return 1;
          // ok, both have at least one ligand
          int minLigandCount = Math.min(ligand1Ligands.length, ligand2Ligands.length);
          if (ligand1Ligands.length > 1) ligand1Ligands = order(ligand1Ligands);
          if (ligand2Ligands.length > 1) ligand2Ligands = order(ligand2Ligands);
          // first do a basic number rule
          for (int i = 0; i < minLigandCount; i++) {
              int comparison = numberRule.compare(ligand1Ligands[i], ligand2Ligands[i]);
              if (comparison != 0) return comparison;
          }
          if (ligand1Ligands.length == ligand2Ligands.length) {
              // it that does not resolve it, do a full, recursive compare
              for (int i = 0; i < minLigandCount; i++) {
                  int comparison = compare(ligand1Ligands[i], ligand2Ligands[i]);
                  if (comparison != 0) return comparison;
              }
          }
          // OK, if we reached this point, then the ligands they 'share' are all equals, so the one
          // with more ligands wins
          if (ligand1Ligands.length > ligand2Ligands.length)
              return 1;
          else if (ligand1Ligands.length < ligand2Ligands.length)
              return -1;
          else
              return 0;
      }
focal_method.class_method_signature: CIPLigandRule.compare(ILigand ligand1, ILigand ligand2)
focal_method.full_signature: @Override public int compare(ILigand ligand1, ILigand ligand2)
focal_method.identifier: compare
focal_method.invocations: compare getLigandLigands getLigandLigands min order order compare compare
focal_method.modifiers: @Override public
focal_method.parameters: (ILigand ligand1, ILigand ligand2)
focal_method.return: int
focal_method.signature: int compare(ILigand ligand1, ILigand ligand2)