I just transfered my previous message to a new thread cauz it was  
merged with a previous thread having the same title... Sorry for this  
:) (I'm not a big fan of these mailing list on sourceforge..)


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()){


Indeed, the UNDEFINED CDK constant is defined as null...

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




----- Fin du message transféré -----


-- 
Vincent Le Guilloux

Phd Student - ICOA - UMR CNRS 6005
Div. of chemoinformatic and molecular modeling.
University of Orléans
Phone: ++33 2 38 49 45 77
Fax  : ++33 2 38 41 72 81



------------------------------------------------------------------------------
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