Hi Mark

> I am parsing a PubChem SDF file into a smiles string but I can’t seem
> to remove the explicit hydrogens. I have tried using an
> AtomContainerManipulator but this does not appear to make a difference
> to the output (a very ugly smiles string). Code is below.

The AtomContainerManipulator.removeHydrogens doesn't remove the hydrogen
of the own atomcontainer but it creates a clone of the atomcontainer
without the hydrogens which is the return object.

in this case you can use:

mol = AtomContainerManipulator.removeHydrogens(mol);

the method removeHydrogens is static. It is not necessary to initiate
the constructor.

> 
Best regards,
 Miquel

>  
> 
> public static String getSmilesFromPubChem(String id, String type)
> throws CDKException, IOException {
> 
>         IMolecule mol = getPubChemMolecule(id,type);
> 
>         SmilesGenerator generator = new SmilesGenerator();
> 
>        returngenerator.createSMILES(mol);
> 
>     }
> 
>     
> 
>     public static IMolecule getPubChemMolecule(String id, String type)
> throws CDKException, IOException {
> 
>         IMolecule mol = null;
> 
>         URL url = new
> URL(String.format("http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?%s=%s&disopt=SaveSDF",type,id));
> 
>        // can't seem to get this to work with ReaderFactory
> 
>         Reader reader = new
> BufferedReader(newInputStreamReader(url.openStream()));
> 
>         IteratingMDLReader mdlReader = new IteratingMDLReader(reader,
> DefaultChemObjectBuilder.getInstance());
> 
>        if( mdlReader.hasNext() ) {
> 
>             mol = (IMolecule) mdlReader.next();
> 
>             AtomContainerManipulator manip = new
> AtomContainerManipulator();
> 
>             manip.removeHydrogens(mol);
> 
>         }
> 
>        return mol;
> 
>     }
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________ Cdk-user mailing list 
> [email protected] 
> https://lists.sourceforge.net/lists/listinfo/cdk-user


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to