test_class.file: legacy/src/test/java/org/openscience/cdk/normalize/SMSDNormalizerTest.java
test_class.identifier: SMSDNormalizerTest
test_case.body: @Test
      public void testRemoveHydrogensAndPreserveAtomID() throws InvalidSmilesException {
          String rawMolSmiles = "[H]POOSC(Br)C(Cl)C(F)I";
          SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
          IAtomContainer atomContainer = sp.parseSmiles(rawMolSmiles);
          IAtom beforeAtom = null;
          IAtom afterAtom = null;
          for (IAtom a : atomContainer.atoms()) {
              if (a.getSymbol().equalsIgnoreCase("P")) {
                  beforeAtom = a;
                  a.setID("TEST");
                  break;
              }
          }
          IAtomContainer result = SMSDNormalizer.removeHydrogensAndPreserveAtomID(atomContainer);
  
          for (IAtom a : result.atoms()) {
              if (a.getSymbol().equalsIgnoreCase("P")) {
                  afterAtom = a;
                  break;
              }
          }
  
          assertEquals(afterAtom.getID(), beforeAtom.getID());
      }
test_case.class_method_signature: SMSDNormalizerTest.testRemoveHydrogensAndPreserveAtomID()
test_case.full_signature: @Test public void testRemoveHydrogensAndPreserveAtomID()
test_case.identifier: testRemoveHydrogensAndPreserveAtomID
test_case.invocations: getInstance parseSmiles atoms equalsIgnoreCase getSymbol setID removeHydrogensAndPreserveAtomID atoms equalsIgnoreCase getSymbol assertEquals getID getID
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRemoveHydrogensAndPreserveAtomID()
focal_class.file: legacy/src/main/java/org/openscience/cdk/normalize/SMSDNormalizer.java
focal_class.identifier: SMSDNormalizer
focal_class.class_method_signature: SMSDNormalizer.makeDeepCopy(IAtomContainer container)
focal_class.full_signature: public static IAtomContainer makeDeepCopy(IAtomContainer container)
focal_class.identifier: makeDeepCopy
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer container)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer makeDeepCopy(IAtomContainer container)
focal_class.class_method_signature: SMSDNormalizer.aromatizeMolecule(IAtomContainer mol)
focal_class.full_signature: public static void aromatizeMolecule(IAtomContainer mol)
focal_class.identifier: aromatizeMolecule
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer mol)
focal_class.return: void
focal_class.signature: void aromatizeMolecule(IAtomContainer mol)
focal_class.class_method_signature: SMSDNormalizer.getExplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.full_signature: public static int getExplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.identifier: getExplicitHydrogenCount
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer atomContainer, IAtom atom)
focal_class.return: int
focal_class.signature: int getExplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.class_method_signature: SMSDNormalizer.getImplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.full_signature: public static int getImplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.identifier: getImplicitHydrogenCount
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer atomContainer, IAtom atom)
focal_class.return: int
focal_class.signature: int getImplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.class_method_signature: SMSDNormalizer.getHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.full_signature: public static int getHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.identifier: getHydrogenCount
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer atomContainer, IAtom atom)
focal_class.return: int
focal_class.signature: int getHydrogenCount(IAtomContainer atomContainer, IAtom atom)
focal_class.class_method_signature: SMSDNormalizer.removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer)
focal_class.full_signature: public static IAtomContainer removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer)
focal_class.identifier: removeHydrogensAndPreserveAtomID
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer atomContainer)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer)
focal_class.class_method_signature: SMSDNormalizer.convertExplicitToImplicitHydrogens(IAtomContainer atomContainer)
focal_class.full_signature: public static IAtomContainer convertExplicitToImplicitHydrogens(IAtomContainer atomContainer)
focal_class.identifier: convertExplicitToImplicitHydrogens
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer atomContainer)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer convertExplicitToImplicitHydrogens(IAtomContainer atomContainer)
focal_class.class_method_signature: SMSDNormalizer.percieveAtomTypesAndConfigureAtoms(IAtomContainer container)
focal_class.full_signature: public static void percieveAtomTypesAndConfigureAtoms(IAtomContainer container)
focal_class.identifier: percieveAtomTypesAndConfigureAtoms
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer container)
focal_class.return: void
focal_class.signature: void percieveAtomTypesAndConfigureAtoms(IAtomContainer container)
focal_class.class_method_signature: SMSDNormalizer.copyAtoms(IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.full_signature: private static IAtom[] copyAtoms(IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.identifier: copyAtoms
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.return: IAtom[]
focal_class.signature: IAtom[] copyAtoms(IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.class_method_signature: SMSDNormalizer.copyBonds(IAtom[] atoms, IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.full_signature: private static void copyBonds(IAtom[] atoms, IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.identifier: copyBonds
focal_class.modifiers: private static
focal_class.parameters: (IAtom[] atoms, IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.return: void
focal_class.signature: void copyBonds(IAtom[] atoms, IAtomContainer container, IAtomContainer newAtomContainer)
focal_class.class_method_signature: SMSDNormalizer.reComputeHydrogens(IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.full_signature: private static IAtomContainer reComputeHydrogens(IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.identifier: reComputeHydrogens
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer reComputeHydrogens(IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.class_method_signature: SMSDNormalizer.cloneAndMarkNonHBonds(IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.full_signature: private static IAtomContainer cloneAndMarkNonHBonds(IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.identifier: cloneAndMarkNonHBonds
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer cloneAndMarkNonHBonds(IAtomContainer mol, IAtomContainer atomContainer,
              List<IAtom> remove, Map<IAtom, IAtom> map)
focal_class.class_method_signature: SMSDNormalizer.set2D(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void set2D(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: set2D
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void set2D(IAtomContainer container, int index, IAtom[] atoms)
focal_class.class_method_signature: SMSDNormalizer.set3D(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void set3D(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: set3D
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void set3D(IAtomContainer container, int index, IAtom[] atoms)
focal_class.class_method_signature: SMSDNormalizer.setFractionalPoint3d(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void setFractionalPoint3d(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: setFractionalPoint3d
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void setFractionalPoint3d(IAtomContainer container, int index, IAtom[] atoms)
focal_class.class_method_signature: SMSDNormalizer.setID(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void setID(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: setID
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void setID(IAtomContainer container, int index, IAtom[] atoms)
focal_class.class_method_signature: SMSDNormalizer.setHydrogenCount(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void setHydrogenCount(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: setHydrogenCount
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void setHydrogenCount(IAtomContainer container, int index, IAtom[] atoms)
focal_class.class_method_signature: SMSDNormalizer.setCharge(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void setCharge(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: setCharge
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void setCharge(IAtomContainer container, int index, IAtom[] atoms)
focal_class.class_method_signature: SMSDNormalizer.setStereoParity(IAtomContainer container, int index, IAtom[] atoms)
focal_class.full_signature: private static void setStereoParity(IAtomContainer container, int index, IAtom[] atoms)
focal_class.identifier: setStereoParity
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container, int index, IAtom[] atoms)
focal_class.return: void
focal_class.signature: void setStereoParity(IAtomContainer container, int index, IAtom[] atoms)
focal_class.superclass: extends AtomContainerManipulator
focal_method.body: public static IAtomContainer removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer) {
          Map<IAtom, IAtom> map = new HashMap<IAtom, IAtom>(); // maps original atoms to clones.
          List<IAtom> remove = new ArrayList<IAtom>(); // lists removed Hs.
          IAtomContainer mol = null;
          if (atomContainer.getBondCount() > 0) {
              // Clone atoms except those to be removed.
              mol = atomContainer.getBuilder().newInstance(IAtomContainer.class);
              int count = atomContainer.getAtomCount();
              for (int i = 0; i < count; i++) {
                  // Clone/remove this atom?
                  IAtom atom = atomContainer.getAtom(i);
                  if (!atom.getSymbol().equals("H")) {
                      IAtom clonedAtom = null;
                      try {
                          clonedAtom = (IAtom) atom.clone();
                      } catch (CloneNotSupportedException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
                      //added by Asad to preserve the Atom ID for atom mapping without Hydrogen
                      clonedAtom.setID(atom.getID());
                      clonedAtom.setFlags(atom.getFlags());
                      int countH = 0;
                      if (atom.getImplicitHydrogenCount() != null) {
                          countH = atom.getImplicitHydrogenCount();
                      }
                      clonedAtom.setImplicitHydrogenCount(countH);
                      mol.addAtom(clonedAtom);
                      map.put(atom, clonedAtom);
  
                  } else {
                      remove.add(atom); // maintain list of removed H.
                  }
              }
              //            Clone bonds except those involving removed atoms.
              mol = cloneAndMarkNonHBonds(mol, atomContainer, remove, map);
              //            Recompute hydrogen counts of neighbours of removed Hydrogens.
              mol = reComputeHydrogens(mol, atomContainer, remove, map);
  
          } else {
              mol = atomContainer.getBuilder().newInstance(IAtomContainer.class, atomContainer);
              mol.addProperties(atomContainer.getProperties());
              mol.setFlags(atomContainer.getFlags());
              if (atomContainer.getID() != null) {
                  mol.setID(atomContainer.getID());
              }
              if (atomContainer.getAtom(0).getSymbol().equalsIgnoreCase("H")) {
                  System.err.println("WARNING: single hydrogen atom removal not supported!");
              }
  
          }
  
          return mol;
      }
focal_method.class_method_signature: SMSDNormalizer.removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer)
focal_method.full_signature: public static IAtomContainer removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer)
focal_method.identifier: removeHydrogensAndPreserveAtomID
focal_method.invocations: getBondCount newInstance getBuilder getAtomCount getAtom equals getSymbol clone printStackTrace setID getID setFlags getFlags getImplicitHydrogenCount getImplicitHydrogenCount setImplicitHydrogenCount addAtom put add cloneAndMarkNonHBonds reComputeHydrogens newInstance getBuilder addProperties getProperties setFlags getFlags getID setID getID equalsIgnoreCase getSymbol getAtom println
focal_method.modifiers: public static
focal_method.parameters: (IAtomContainer atomContainer)
focal_method.return: IAtomContainer
focal_method.signature: IAtomContainer removeHydrogensAndPreserveAtomID(IAtomContainer atomContainer)