how to parse the sdfile?

User 05309f4af8

17-03-2009 14:28:15

i want to get all fields and values from sdfile, how to parase the sdfile?





thanks and best regards!





<<sample.sdf>>








  -ISIS-  01150915402D





 22 26  0  0  0  0  0  0  0  0999 V2000


   -0.8621   -0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -0.8621    0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    0.0000   -0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -1.7276   -0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    0.0000    0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -1.7276    0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    0.8621   -0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -2.5931   -0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    0.8621    0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -2.5931    0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    1.7276   -0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -3.4724   -0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    1.7276    0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -3.4724    0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    2.5931   -0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -4.3448   -0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    2.5931    0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


   -4.3448    0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    3.4655   -0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    3.4655    0.9931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    4.3448   -0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


    4.3448    0.4931    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0


  1  2  1  0  0  0  0


  1  3  2  0  0  0  0


  1  4  1  0  0  0  0


  2  5  2  0  0  0  0


  2  6  1  0  0  0  0


  3  7  1  0  0  0  0


  4  8  2  0  0  0  0


  5  9  1  0  0  0  0


  6 10  2  0  0  0  0


  7 11  2  0  0  0  0


  8 12  1  0  0  0  0


  9 13  2  0  0  0  0


 10 14  1  0  0  0  0


 11 15  1  0  0  0  0


 12 16  2  0  0  0  0


 13 17  1  0  0  0  0


 14 18  2  0  0  0  0


 15 19  2  0  0  0  0


 17 20  2  0  0  0  0


 19 21  1  0  0  0  0


 20 22  1  0  0  0  0


  7  9  1  0  0  0  0


  8 10  1  0  0  0  0


 15 17  1  0  0  0  0


 16 18  1  0  0  0  0


 21 22  2  0  0  0  0


M  END


> <CD_FORMULA>


C22H14





> <CD_MOLWEIGHT>


278.3466





> <MOLNAME>


PENTACENE





$$$$

ChemAxon e274e1bada

17-03-2009 15:30:40

Hi,








you can use the setFieldConnections(String) method in the Importer for this.





Please read the API doc: http://www.chemaxon.com/jchem/doc/api/chemaxon/jchem/db/Importer.html











Best Regards, Edvard

ChemAxon 9c0afc9aaf

23-03-2009 15:50:40

If you do not want to import into a database you can also use MolImporter to create a Molecule:





http://www.chemaxon.com/jchem/doc/api/chemaxon/formats/MolImporter.html





Then you can use:





http://www.chemaxon.com/jchem/doc/api/chemaxon/struc/Molecule.html#getPropertyCount()





http://www.chemaxon.com/jchem/doc/api/chemaxon/struc/Molecule.html#getPropertyKey(int)





http://www.chemaxon.com/jchem/doc/api/chemaxon/struc/Molecule.html#getProperty(java.lang.String)