Hi all,

I'm attempting to use CDK for the first time, but am having problems with the 
following code:


        /**
         * 
         * @param inchiTerm1
         * @param inchiTerm2
         * @return float
         * @throws CDKException 
         */
        private float getScore( final String inchiTerm1, final String 
inchiTerm2 ) throws CDKException
        {
                // System.out.println( inchiTerm1 + "\t" + inchiTerm2 ); 
//$NON-NLS-1$
                final IAtomContainer molecule1 = 
(IAtomContainer)getIChemObject( inchiTerm1 );
                final IAtomContainer molecule2 = 
(IAtomContainer)getIChemObject( inchiTerm2 );
                final Fingerprinter fingerprinter = new Fingerprinter();
                final BitSet fingerprint1 = fingerprinter.getFingerprint( 
molecule1 );
                final BitSet fingerprint2 = fingerprinter.getFingerprint( 
molecule2 );
                return Tanimoto.calculate( fingerprint1, fingerprint2 );
        }

        /**
         * @param inchiTerm
         * @return IChemObject
         * @throws CDKException 
         */
        private IChemObject getIChemObject( final String inchiTerm ) throws 
CDKException
        {
                return new INChIPlainTextReader( new ByteArrayInputStream( 
inchiTerm.replace( "InChI", "INChI" ).getBytes() ) ).read( new ChemFile() ); // 
Need to replace 'InChI' for 'INChI', unfortunately...
        }


I'm wanting to generate BitSets from Inchi strings, but am failing in the 
getIChemObject method. It seems that the reader doesn't like the following 
Inchi string, despite the fact that it came from ChEBI and seems to be OK in 
other applications.

InChI=1/C3H6N2O4/c4-3(9)5-1(6)2(7)8/h1,6H,(H,7,8)(H3,4,5,9)/t1-/m0/s1/f/h5,7H,4H2

I'm aware that there may be better ways of reading Inchis, but looking at the 
API, this was the best that I can do.

Cheers,

Neil.

Neil Swainston
Experimental Officer

Manchester Centre for Integrative Systems Biology
Manchester Interdisciplinary Biocentre
University of Manchester
Manchester M1 7DN
England
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to