G'day,

>  The atom type perception is best done by passing the full molecule,
>  rather than atom by atom. I do not know the exact speed up, but there
>  is some replication involved when calculating atom type perception one
>  by one (such as ring detection). Use he other findMatchingAtomType
>  method

Thanks - that's better.  My atom typing code was based on the snippet provided 
in the JavaDoc for CDKHydrogenAdder:

IMolecule methane = new Molecule();
IAtom carbon = new Atom("C");
methane.addAtom(carbon);
CDKAtomTypeMatcher matcher = 
CDKAtomTypeMatcher.getInstance(methane.getNewBuilder());
for (IAtom atom : methane.atoms) {
   IAtomType type = matcher.findMatchingAtomType(methane, atom);
   AtomTypeManipulator.configure(atom, type);
}
CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(methane.getNewBuilder());
adder.addImplicitHydrogens(methane);

So using Egon's suggestion I now have:

// Explicit ->  Implicit H: addImpH then removeH is better than removeH then 
addImpH.
final IChemObjectBuilder builder = 
NoNotificationChemObjectBuilder.getInstance();
final CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(builder);
final IAtomContainer result = new AtomContainer(mol);
try
{
   // Type the atoms.
   int t = 0;
   final IAtomType[] types = matcher.findMatchingAtomType(result);
   for (final IAtom atom : result.atoms())
   {
     final IAtomType type = types[t++];
     if (type != null)
     {
       AtomTypeManipulator.configure(atom, type);
     }
   }

  // Add implicit hydrogens.
  CDKHydrogenAdder.getInstance(builder).addImplicitHydrogens(result);
}
catch (final CDKException e)
{
   LOG.log(Level.WARNING, "Failed to add hydrogens", e);
}

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

Many 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