Hi Alex,
On Thu, Aug 18, 2011 at 2:54 PM, Alex Henderson
<[email protected]> wrote:
> I'd like to take an InChI string and return an IMolecule that has all the
> hydrogens set explicitly. The code I have so far is below. Unfortunately it
> doesn't work properly.
Your InChI does not seem to use the Fixed-H layer... is that correct?
> It would appear that the atomtyping returns sp3 hybridisation for all the
> carbon atoms and so too much hydrogen is added.
>
> Would someone be kind enough to identify what's missing/wrong?
>
> String
> inchi="InChI=1S/C6H8O6/c7-1-2(8)5-3(9)4(10)6(11)12-5/h2,5,7-10H,1H2/t2-,5+/m0/s1";
> // ascorbic acid C6H8O6
The above comment aside, it seems all hydrogens are localized, and the
InChI seems to indicate 8 hydrogens and where they are...
> StringReader ins = new StringReader(inchi);
> INChIPlainTextReader reader = new INChIPlainTextReader(ins);
> ChemFile chemFile = (ChemFile)reader.read((ChemObject)new
> ChemFile());
>
> IChemSequence seq = chemFile.getChemSequence(0);
> IChemModel model = seq.getChemModel(0);
> IMoleculeSet moleculeSet = model.getMoleculeSet();
> IMolecule molecule = moleculeSet.getMolecule(0);
>
> CDKAtomTypeMatcher matcher =
> CDKAtomTypeMatcher.getInstance(molecule.getBuilder());
> for (IAtom atom : molecule.atoms()) {
> IAtomType type = matcher.findMatchingAtomType(molecule, atom);
> AtomTypeManipulator.configure(atom, type);
> }
The InChI already has the hydrogen count information, but it could be
that that information is lost, or not correctly taken into account by
the atom typer... it has to do with various kinds of missing
information, and might be making a mistake here with the bond orders
missing...
> CDKHydrogenAdder adder =
> CDKHydrogenAdder.getInstance(molecule.getBuilder());
> adder.addImplicitHydrogens(molecule);
As the H-count info is already available, I would skip this step
alltogether... can you verify that the InChI reader code is in fact
reading the hydrogen counts? if it isn't, that would explain the
C.sp3's...
Egon
--
Dr E.L. Willighagen
Postdoctoral Researcher
Institutet för miljömedicin
Karolinska Institutet (http://ki.se/imm)
Homepage: http://egonw.github.com/
LinkedIn: http://se.linkedin.com/in/egonw
Blog: http://chem-bla-ics.blogspot.com/
PubList: http://www.citeulike.org/user/egonw/tag/papers
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user