File Coverage

blib/lib/Chemistry/File/MidasPattern.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Chemistry::File::MidasPattern;
2              
3             $VERSION = '0.11';
4              
5             =head1 NAME
6              
7             Chemistry::File::MidasPattern - Wrapper Chemistry::File class for Midas patterns
8              
9             =head1 SYNOPSIS
10              
11             use Chemistry::File::MidasPattern;
12             use Chemistry::File::PDB;
13              
14             # read a molecule
15             my $mol = Chemistry::MacroMol->read("test.pdb");
16              
17             # define a pattern matching carbons alpha and beta
18             # in all valine residues
19             my $str = ':VAL@CA,CB';
20             my $patt = Chemistry::MidasPattern->parse($str, format => 'midas');
21             # Chemistry::Mol->parse($str, format => 'midas') also works
22              
23             # apply the pattern to the molecule
24             $patt->match($mol);
25              
26             # extract the results
27             for my $atom ($patt->atom_map) {
28             printf "%s\t%s\n", $atom->attr("pdb/residue_name"), $atom->name;
29             }
30             printf "FOUND %d atoms\n", scalar($patt->atom_map);
31              
32             =head1 DESCRIPTION
33              
34             This is a wrapper class for reading Midas Patterns using the standard
35             Chemistry::Mol I/O interface. This allows Midas patterns to be used
36             interchangeably with other pattern languages such as SMARTS in the context of
37             programs such as L. All of the real work is done by
38             L.
39              
40             This module register the 'midas' format with Chemistry::Mol.
41              
42             =cut
43              
44 1     1   35362 use strict;
  1         2  
  1         36  
45 1     1   6 use warnings;
  1         2  
  1         30  
46 1     1   5 use base "Chemistry::File";
  1         6  
  1         1375  
47 1     1   58523 use Chemistry::MidasPattern;
  1         4  
  1         164  
48              
49             Chemistry::Mol->register_format(midas => __PACKAGE__);
50              
51             sub parse_string {
52 18     18 1 160615 my ($self, $s, %opts) = @_;
53 18         106 my $patt = Chemistry::MidasPattern->new($s);
54 18         89 $patt->options(%opts);
55 18         81 $patt;
56             }
57              
58             1;
59              
60             =head1 VERSION
61              
62             0.11
63              
64             =head1 SEE ALSO
65              
66             L, L, L,
67             L, L.
68              
69             The PerlMol website L
70              
71             =head1 AUTHOR
72              
73             Ivan Tubert Eitub@cpan.orgE
74              
75             =head1 COPYRIGHT
76              
77             Copyright (c) 2005 Ivan Tubert. All rights reserved. This program is free
78             software; you can redistribute it and/or modify it under the same terms as
79             Perl itself.
80              
81             =cut
82