|
NAMEChemistry::Pattern - Chemical substructure pattern matchingSYNOPSISuse Chemistry::Pattern; use Chemistry::Mol; use Chemistry::File::SMILES; # Create a pattern and a molecule from SMILES strings my $mol_str = "C1CCCC1C(Cl)=O"; my $patt_str = "C(=O)Cl"; my $mol = Chemistry::Mol->parse($mol_str, format => 'smiles'); my $patt = Chemistry::Pattern->parse($patt_str, format => 'smiles'); # try to match the pattern while ($patt->match($mol)) { @matched_atoms = $patt->atom_map; print "Matched: (@matched_atoms)\n"; # should print something like "Matched: (a6 a8 a7)" } DESCRIPTIONThis module implements basic pattern matching for molecules. The Chemistry::Pattern class is a subclass of Chemistry::Mol, so patterns have all the properties of molecules and can come from reading the same file formats. Of course there are certain formats (such as SMARTS) that are exclusively used to describe patterns.To perform a pattern matching operation on a molecule, follow these steps. 1) Create a pattern object, either by parsing a file or string, or by adding atoms and bonds by hand by using Chemistry::Mol methods. Note that atoms and bonds in a pattern should be Chemistry::Pattern::Atom and Chemistry::Patern::Bond objects. Let's assume that the pattern object is stored in $patt and that the molecule is $mol. 2) Execute the pattern on the molecule by calling $patt->match($mol). 3) If $patt->match() returns true, extract the "map" that relates the pattern to the molecule by calling $patt->atom_map or $patt->bond_map. These methods return a list of the atoms or bonds in the molecule that are matched by the corresponding atoms in the pattern. Thus $patt->atom_map(1) would be analogous to the $1 special variable used for regular expresion matching. The difference between Chemistry::Pattern and Perl regular expressions is that atoms and bonds are always captured. 4) If more than one match for the molecule is desired, repeat from step (2) until match() returns false. METHODS
VERSION0.27SEE ALSOChemistry::Pattern::Atom, Chemistry::Pattern::Bond, Chemistry::Mol, Chemistry::File, Chemistry::File::SMARTS.The PerlMol website <http://www.perlmol.org/> AUTHORIvan Tubert-Brohman <itub@cpan.org>COPYRIGHTCopyright (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.
Visit the GSP FreeBSD Man Page Interface. |