The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

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
    }

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.

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

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.

AUTHOR

Ivan Tubert-Brohman <itub@cpan.org>

COPYRIGHT

Copyright (c) 2009 Ivan Tubert-Brohman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.