blib/lib/Chemistry/File/FormulaPattern.pm

filter: Statementstmt 83.3% 15 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 83.3% 20 / 24 CC 1 SCAR 1.8
CC
1
Cov
83%
parse_string
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Chemistry/File/MidasPattern.pm ↑ Summary Chemistry-Mok-0.25/mok »
1 package Chemistry::File::FormulaPattern;
2  
3 9 $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<mok>. All of the real work is done by
35 L<Chemistry::FormulaPattern>.
36  
37 This module register the 'formula_pattern' format with L<Chemistry::Mol>.
38  
39 =cut
40  
41 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 9 ▶use base "Chemistry::File";
Subroutine BEGIN: called CC=1 SCAR=0.0
44 9 ▶use Chemistry::FormulaPattern;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 9 Chemistry::Mol->register_format(formula_pattern => __PACKAGE__);
47  
48 0 ▶sub parse_string {
Subroutine parse_string: not called CC=1 SCAR=6.9
Pod documented
49 0 my ($self, $s, %opts) = @_;
50 0 my $patt = Chemistry::FormulaPattern->new($s);
51 #$patt->options(%opts);
52 0 $patt;
53 }
54  
55 9 1;
56  
57 =head1 VERSION
58  
59 0.10
60  
61 =head1 SEE ALSO
62  
63 L<Chemistry::Pattern>, L<Chemistry::File>, L<Chemistry::Mol>,
64 L<Chemistry::MacroMol>, L<mok>.
65  
66 The PerlMol website L<http://www.perlmol.org/>
67  
68 =head1 AUTHOR
69  
70 Ivan Tubert-Brohman E<lt>itub@cpan.orgE<gt>
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  
« blib/lib/Chemistry/File/MidasPattern.pm ↑ Summary Chemistry-Mok-0.25/mok »