Rajarshi Guha wrote:
On Dec 9, 2007, at 1:35 AM, Nina Jeliazkova wrote:

  
Hi,

I think I've found the reason - when a molecule is created via
SmilesParser, the hybridization of atoms is correctly set. If a  
molecule
is read from a file, atom.getHybridization() method returns null.   
Thus
for aromaticity detection to work properly, we need some preprocessing
after the molecule is read, or/and some exception thrown if  
aromaticity
detector encounters nulls in getHybridization method.
    

Have you tried perform atom typing before the aromaticity detection?  
I think the method is detectAndConfigureAtomTypes or something like that

  
Thanks, I was not sure which method is to be run for preprocessing. Now, with the code below, the compounds from the two SDF files are indeed recognised as aromatics.
However, I could only find a private method findAndConfigureAtomTypesForAllAtoms (the one below)  in CDKHydrogenAdderTest and CDKValencyCheckerTest.  Is there somewhere a public method?

    private void findAndConfigureAtomTypesForAllAtoms(IAtomContainer container) throws CDKException {
        CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder());
        Iterator<IAtom> atoms = container.atoms();
        while (atoms.hasNext()) {
            IAtom atom = atoms.next();
            IAtomType type = matcher.findMatchingAtomType(container, atom);
            assertNotNull(type);
            AtomTypeManipulator.configure(atom, type);
        }
    }   

 public int printAromaticity() throws Exception {
        IteratingMDLReader resultsReader = new IteratingMDLReader(
                new FileInputStream("plugins/v 1.11/mutant/data/"+getHitsFile()),DefaultChemObjectBuilder.getInstance());
        int aromaticCompounds = 0;
        while (resultsReader.hasNext()) {
            Object o = resultsReader.next();
            IAtomContainer a = (IAtomContainer)o;
            findAndConfigureAtomTypesForAllAtoms(a);
            boolean ok = CDKHueckelAromaticityDetector.detectAromaticity(a);
            if (ok) aromaticCompounds++;
            int aromatic = 0;
            for (int i=0; i < a.getAtomCount();i++) {
                if (a.getAtom(i).getFlag(CDKConstants.ISAROMATIC))
                    aromatic ++;
                //stem.out.print(a.getAtom(i).getHybridization());
                //System.out.print('\t');
            }
            System.out.print(a.getProperty("CAS_iss2"));
            System.out.print('\t');
            System.out.print("is aromatic\t");
            System.out.print(ok);
            System.out.print('\t');
            System.out.print(aromatic);
            System.out.println(" aromatic atoms");
           
        }
        return aromaticCompounds;
    }   

Regards,
Nina
-------------------------------------------------------------------
Rajarshi Guha  <rguha@indiana.edu>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04  06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------

A list is only as strong as its weakest link.
		-- Don Knuth



-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Cdk-devel mailing list
Cdk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-devel