logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Chemistry::File::SDF - MDL Structure Data File reader/writer

Author

       Ivan Tubert-Brohman <itub@cpan.org>

Caveats

       Note that by storing the SDF data as a hash, there can be only one field with a given name. The SDF
       format description is not entirely clear in this regard.  Also note that SDF data field names are
       considered to be case-sensitive.

Description

       MDL SDF (V2000) reader.

       This module automatically registers the 'sdf' format with Chemistry::Mol.

       The parser returns a list of Chemistry::Mol objects.  SDF data can be accessed by the $mol->attr method.
       Attribute names are stored as a hash ref at the "sdf/data" attribute, as shown in the synopsis. When a
       data item has a single line in the SDF file, the attribute is stored as a string; when there's more than
       one line, they are stored as an array reference. The rest of the information on the line that holds the
       field name is ignored.

       This module is part of the PerlMol project, <https://github.com/perlmol>.

Name

       Chemistry::File::SDF - MDL Structure Data File reader/writer

See Also

       Chemistry::Mol

       The MDL file format specification.  <http://www.mdl.com/downloads/public/ctfile/ctfile.pdf> or Arthur
       Dalby et al., J. Chem. Inf. Comput. Sci, 1992, 32, 244-255.

Source Code Repository

       <https://github.com/perlmol/Chemistry-File-MDLMol>

Synopsis

           use Chemistry::File::SDF;

           # Simple interface (all at once)
           # read all the molecules in the file
           my @mols = Chemistry::Mol->read('myfile.sdf');

           # assuming that the file includes a <PKA> data item...
           print $mols[0]->attr("sdf/data")->{PKA};

           # write a bunch of molecules to an SDF file
           Chemistry::Mol->write('myfile.sdf', mols => \@mols);

           # or write just one molecule
           $mol->write('myfile.sdf');

           # Low level interface (one at a time)
           # create reader
           my $reader = Chemistry::Mol->file('myfile.sdf');
           $reader->open('<');
           while (my $mol = $reader->read_mol($reader->fh)) {
               # do something with $mol
           }

See Also