Chemistry::File::SDF(3pm)

Chemistry::File::SDF3pm

Mdl structure data file reader/writer

Usage

    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
    }

Overview

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

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.

Source code repository

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

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

Author

Ivan Tubert-Brohman <[email protected]>

From libchemistry-file-mdlmol-perl 0.24-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.