File Coverage

blib/lib/Chemistry/File/FormulaPattern.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Chemistry::File::FormulaPattern;
2              
3             $VERSION = '0.10';
4              
5             =head1 NAME
6              
7             Chemistry::File::FormulaPattern - Wrapper Chemistry::File class for Formula patterns
8              
9             =head1 SYNOPSIS
10              
11             use Chemistry::File::FormulaPattern;
12              
13             # somehow get a bunch of molecules...
14             use Chemistry::File::SDF;
15             my @mols = Chemistry::Mol->read("file.sdf");
16              
17             # we want molecules with six carbons and 8 or more hydrogens
18             my $patt = Chemistry::Pattern->new("C6H8-", format => "formula_pattern");
19              
20             for my $mol (@mols) {
21             if ($patt->match($mol)) {
22             print $mol->name, " has a nice formula!\n";
23             }
24             }
25              
26             # a concise way of selecting molecules with grep
27             my @matches = grep { $patt->match($mol) } @mols;
28              
29             =head1 DESCRIPTION
30              
31             This is a wrapper class for reading Formula Patterns using the standard
32             Chemistry::Mol I/O interface. This allows Formula patterns to be used
33             interchangeably with other pattern languages such as SMARTS in the context of
34             programs such as L. All of the real work is done by
35             L.
36              
37             This module register the 'formula_pattern' format with L.
38              
39             =cut
40              
41 1     1   22830 use strict;
  1         2  
  1         36  
42 1     1   5 use warnings;
  1         2  
  1         31  
43 1     1   5 use base "Chemistry::File";
  1         6  
  1         1008  
44 1     1   28791 use Chemistry::FormulaPattern;
  1         4  
  1         108  
45              
46             Chemistry::Mol->register_format(formula_pattern => __PACKAGE__);
47              
48             sub parse_string {
49 8     8 1 6550 my ($self, $s, %opts) = @_;
50 8         38 my $patt = Chemistry::FormulaPattern->new($s);
51             #$patt->options(%opts);
52 8         37 $patt;
53             }
54              
55             1;
56              
57             =head1 VERSION
58              
59             0.10
60              
61             =head1 SEE ALSO
62              
63             L, L, L,
64             L, L.
65              
66             The PerlMol website L
67              
68             =head1 AUTHOR
69              
70             Ivan Tubert-Brohman Eitub@cpan.orgE
71              
72             =head1 COPYRIGHT
73              
74             Copyright (c) 2004 Ivan Tubert-Brohman. All rights reserved. This program is
75             free software; you can redistribute it and/or modify it under the same terms as
76             Perl itself.
77              
78             =cut
79