The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Chemistry::File::SMARTS - SMARTS chemical substructure pattern linear notation parser

SYNOPSYS

#!/usr/bin/perl
use Chemistry::File::SMARTS;

# this string matches an oxygen next to an atom with three 
# neighbors, one of which is a hydrogen, and a positive charge
my $smarts = 'O[D3H+]'; 

# parse a SMARTS string and compile it into a
# Chemistry::Pattern object
my $patt = Chemistry::Pattern->parse("$smarts", format => 'smarts');

# find matches of the pattern in a Chemistry::Mol object $mol
my $mol = Chemistry::Mol->read("myfile.mol");
while ($patt->match($mol)) {
    print "pattern matches atoms: ", $patt->atom_map, "\n"
}

# NOTE: if the SMARTS pattern relies on aromaticity 
# properties, you have to make sure that the target 
# molecule is "aromatized" first:
my $smarts = 'c:a';
my $patt = Chemistry::Pattern->parse("$smarts", format => 'smarts');
use Chemistry::Ring 'aromatize_mol';
aromatize_mol($mol);  # <--- AROMATIZE!!!
while ($patt->match($mol)) {
    print "pattern matches atoms: ", $patt->atom_map, "\n"
}

DESCRIPTION

This module parse a SMARTS string, generating a Chemistry::Pattern object. It is a file I/O driver for the PerlMol toolkit; it's not called directly but by means of the Chemistry::Pattern->parse class method.

For a detailed description of the SMARTS language, see http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html. Note that this module doesn't implement the full language, as detailed under CAVEATS.

This module is part of the PerlMol project, http://www.perlmol.org/.

CAVEATS

The following features are not implemented yet:

ring membership: R, r
chirality: @, @@
recursive SMARTS: $

The parser is very lenient, but if you give it something that's not quite reasonable it will interpret it in a strange way without warning.

VERSION

0.10

SEE ALSO

Chemistry::Pattern, Chemistry::Mol, Chemistry::File, Chemistry::File::SMILES.

For more information about SMARTS, see the SMARTS Theory Manual at http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html

AUTHOR

Ivan Tubert-Brohman <itub@cpan.org>

COPYRIGHT

Copyright (c) 2004 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.