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.

 

Thanks in advance for the help J

 

~Mark.

 

 

public static String getSmilesFromPubChem(String id, String type) throws
CDKException, IOException {

        IMolecule mol = getPubChemMolecule(id,type);

        SmilesGenerator generator = new SmilesGenerator();

        return generator.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(new
InputStreamReader(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

Reply via email to