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::MDLMol - MDL molfile reader/writer

Author

       Ivan Tubert-Brohman <itub@cpan.org>

Description

       MDL Molfile (V2000) reader/writer.

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

       The first three lines of the molfile are stored as $mol->name, $mol->attr("mdlmol/line2"), and
       $mol->attr("mdlmol/comment").

       This version only reads and writes some of the information available in a molfile: it reads coordinates,
       atom and bond types, charges, isotopes, radicals, and atom lists. It does not read other things such as
       stereochemistry, 3d properties, etc.

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

   Queryproperties
       The MDL molfile format supports query properties such as atom lists, and special bond types such as
       "single or double", "single or aromatic", "double or aromatic", "ring bond", or "any". These properties
       are supported by this module in conjunction with Chemistry::Pattern. However, support for query
       properties is currently read-only, and the other properties listed in the specification are not supported
       yet.

       So that atom and bond objects can use these special query options, the conditions are represented as Perl
       subroutines. The generated code can be read from the 'mdlmol/test_sub' attribute:

           $atom->attr('mdlmol/test_sub');
           $bond->attr('mdlmol/test_sub');

       This may be useful for debugging, such as when an atom doesn't seem to match as expected.

   AromaticQueries
       To be able to search for aromatic substructures are represented by Kekule structures, molfiles that are
       read as patterns (with "Chemistry::Pattern-"read) are aromatized automatically by using the
       Chemistry::Ring module. The default bond test from Chemistry::Pattern::Bond is overridden by one that
       checks the aromaticity in addition to the bond order.  The test is,

           $patt->aromatic ?  $bond->aromatic
               : (!$bond->aromatic && $patt->order == $bond->order);

       That is, aromatic pattern bonds match aromatic bonds, and aliphatic pattern bonds match aliphatic bonds
       with the same bond order.

Name

       Chemistry::File::MDLMol - MDL molfile reader/writer

See Also

       Chemistry::Mol

       The MDL file format specification.
       <https://discover.3ds.com/ctfile-documentation-request-form#_ga=2.229779804.1581205944.1643725102-a2d5f010-6f4c-11ec-a2da-e3641d195888>,
       <https://discover.3ds.com/sites/default/files/2020-08/biovia_ctfileformats_2020.pdf>,
       <https://web.archive.org/web/20070927033700/http://www.mdl.com/downloads/public/ctfile/ctfile.pdf>, or
       Arthur Dalby et al., J. Chem. Inf. Comput. Sci, 1992, 32, 244-255.
       <https://doi.org/10.1021/ci00007a012>.

Source Code Repository

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

Synopsis

           use Chemistry::File::MDLMol;

           # read a molecule
           my $mol = Chemistry::Mol->read('myfile.mol');

           # write a molecule
           $mol->write("myfile.mol");

           # use a molecule as a query for substructure matching
           use Chemistry::Pattern;
           use Chemistry::Ring;
           Chemistry::Ring::aromatize_mol($mol);

           my $patt = Chemistry::Pattern->read('query.mol');
           if ($patt->match($mol)) {
               print "it matches!\n";
           }

See Also