Fixing SDF Files Using Marvin API

User a9d76a1173

17-12-2011 18:07:16



Hi ,


I have a sdf file that is not properly formatted. When I open it with marvin view and save as a sdf I get a properly formatted sdf. I am trying to replicate this functionality using api. Reading part works fine. Writing does not work. I get an empty file. 


Here is the code


private void marvinSDFWrite()
      {
       try
       {
      
FileInputStream fileInputStream = new
FileInputStream(Settings.getCurrentDirectory()+sep+Settings.getJobName()+"_filtered.sdf");
       FileOutputStream os = new FileOutputStream(Settings.getCurrentDirectory()+sep+"molconnIn.sdf");
       MolImporter molImporter = new MolImporter(fileInputStream);
       MolExporter molExporter = new MolExporter(os,"sdf");
       Molecule molecule;
        while ((molecule = molImporter.read()) != null) {
            molExporter.write(molecule);
            }
        molImporter.close();
        molExporter.close();
       }
       catch (Exception e)
       {
           System.out.println(e.toString());
       }
      }


What am I doing wrong?? I am getting java.lang.NullPointerException Is there anything else marvin does to reformat sdf? standardization perhaps ?


 

ChemAxon e500b51457

19-12-2011 14:29:46

Hello,


Please follow this topic:


https://www.chemaxon.com/forum/viewtopic.php?p=39278#39278


 


Regards,


Erika