G'day,

I'm migrating code from CDK 1.2 to 1.4.  The code I wrote (several years
ago now) for implicitly representing hydrogens still compiles and runs
against CDK 1.4 but I'm wondering whether there are better techniques
available now.

The code I use is in a utility class (of static methods):

     /**
      * Implicitly represent the hydrogens in a structure.
      *
      * @param mol The structure to convert.
      * @return The molecule(s) with implicit hydrogens.
      */
     public static IAtomContainer makeHydrogensImplicit(final
IAtomContainer mol)
     {
         LOG.fine("Make H implicit");

         // Explicit -> Implicit H: addExH then removeH is better than
         // removeH then addImpH.

         final CDKAtomTypeMatcher matcher =

CDKAtomTypeMatcher.getInstance(NoNotificationChemObjectBuilder.getInstance());
         final IAtomContainer m2 = new AtomContainer(mol);
         try
         {
             final int atom_cnt = m2.getAtomCount();
             for (int i = 0;
                  i < atom_cnt;
                  i++)
             {
                 final IAtom atom = m2.getAtom(i);
                 AtomTypeManipulator.configure(atom,
matcher.findMatchingAtomType(m2, atom));
             }

CDKHydrogenAdder.getInstance(m2.getBuilder()).addImplicitHydrogens(m2);
         }
         catch (final Throwable e)
         {
             LOG.log(Level.WARNING, "Failed to add hydrogens", e);
         }

         // Explicit -> Implicit H.
         return
AtomContainerManipulator.removeHydrogensPreserveMultiplyBonded(m2);
     }

Thanks,
Chris.



Syngenta Limited, Registered in England No 2710846
Registered Office : Syngenta Limited, European Regional Centre, Priestley Road, 
Surrey Research Park, Guildford, Surrey, GU2 7YH, United Kingdom



message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 


------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to