Dear CDKers,

I'm facing several errors happening when writing (because of wrong  
reading?) a SDF file.:

- When a Group Abbreviation is used for a molecule, well it seems the  
CDK set this abbreviation as atomic symbol when writing back the  
molecule to MDL format, eg:

(...)
     2.1012   -2.6351    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
(...)
G   15 10
Ph
(...)

Becomes the following when using SDF writer:

     2.1012   -2.6351    0.0000 Ph  0  0  0  0  0  0  0  0  0  0  0  0

- When the bond stereochemistry is set to 4 (either up or down), a CDK  
exception occurs when writing back the molecule. Here is the exception:

org.openscience.cdk.exception.CDKException: Exception while writing  
MDL file: Exception while writing MDL file: null
         at org.openscience.cdk.io.SDFWriter.write(SDFWriter.java:171)
         at sa2.core.CDKReaderBugTest.testCDK(CDKReaderBugTest.java:76)
         at sa2.core.CDKReaderBugTest.main(CDKReaderBugTest.java:95)
Caused by: org.openscience.cdk.exception.CDKException: Exception while  
writing MDL file: null
         at org.openscience.cdk.io.MDLWriter.write(MDLWriter.java:184)
         at org.openscience.cdk.io.SDFWriter.writeMolecule(SDFWriter.java:201)
         at org.openscience.cdk.io.SDFWriter.write(SDFWriter.java:165)
         ... 2 more
Caused by: java.lang.NullPointerException
         at org.openscience.cdk.io.MDLWriter.writeMolecule(MDLWriter.java:297)
         at org.openscience.cdk.io.MDLWriter.write(MDLWriter.java:178)
         ... 4 more

I think the stereo is in cause because the NullPointerException  
occures here in the MDLWriter:

  297                         switch(bond.getStereo()){


I've used the following code snippet which read a file containing 5  
molecules that illustrate the problem:

public class CDKReaderBugTest {
     public static void testCDK(File f) throws Exception {
         FileInputStream ins = new FileInputStream(f) ;
         IteratingMDLReader reader = new IteratingMDLReader(ins,  
DefaultChemObjectBuilder.getInstance());

         CDKHydrogenAdder hAdder = null ;
         IMolecule mol = null ;
         while (reader.hasNext()) {
             mol = (IMolecule) reader.next() ;

             // Clean molecule
             AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
             if(hAdder == null) {
                 hAdder = CDKHydrogenAdder.getInstance(mol.getBuilder()) ;
             }
             hAdder.addImplicitHydrogens(mol);

             // Show SDF
             StringWriter sw = new StringWriter() ;
             SDFWriter mw = new SDFWriter(sw) ;
             try {
                 mw.write(mol) ;
             }
             catch(Exception e) {
                 System.out.println("Error while writing MDL:  
"+e.getMessage()+" "+n);
                 e.printStackTrace(System.out);
             }
             mw.close() ;
             String mdl = sw.toString() ;

             System.out.println("Atom count: "+mol.getAtomCount());
             System.out.println("MDL: "+mdl);
         }
         reader.close();
     }

     public static void main(String [] args) {
         File f = new File("/home/vince/Desktop/testLMA.sdf") ;
         try {
             testCDK(f);
         }
         catch (Exception ex) {
              
Logger.getLogger(CDKReaderBugTest.class.getName()).log(Level.SEVERE,
                                                                    null, ex);
         }
     }
}

Please, let me know if I'm doing something wrong or if these issues  
are actual bugs.

Cheers ;)
Vincent




------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to