molimporter.read() and comments

User 7c177bab3b

16-09-2010 12:37:57

I was wondering if molimporter.read() had any support for comments in a smarts or smiles file?


The documentation states that molimporter.read() gets the next molecule. Does this mean that it skips rows in a file that don't give a valid molecule? What about blank lines?


e.g. The following smarts file seems to be read okay, giving just one query


# comment here
aNC(=O)a<tab>name


using the snippet from your TagByQuery code from an earlier post


        MolImporter molimp = new MolImporter(smartsfile + "{fTAG}"); 
        molimp.setQueryMode(true); //SMARTS
        Molecule mol;
        queries = new ArrayList<Molecule>();
        while ((mol = molimp.read())!= null) {
            queries.add(mol);
        }
        molimp.close();


Thanks


Stephen

ChemAxon 5433b8e56b

16-09-2010 14:43:34

Hi Stephen,


yes it will omit the lines started with #, and it will read empty lines as empty molecules.


You can test if a molecule is empty with the Molecule.isEmpty method.


Regards,
Istvan