File Coverage

Bio/Symbol/DNAAlphabet.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 4 100.0
condition 4 6 66.6
subroutine 5 5 100.0
pod 1 1 100.0
total 44 46 95.6


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Symbol::DNAAlphabet
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Jason Stajich
7             #
8             # Copyright Jason Stajich
9             #
10             # You may distribute this module under the same terms as perl itself
11              
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::Symbol::DNAAlphabet - A ready made DNA alphabet
17              
18             =head1 SYNOPSIS
19              
20             use Bio::Symbol::DNAAlphabet;
21             my $alpha = Bio::Symbol::DNAAlphabet->new();
22             foreach my $symbol ( $alpha->symbols ) {
23             print "symbol is $symbol\n";
24             }
25              
26             =head1 DESCRIPTION
27              
28             This object builds an Alphabet with DNA symbols.
29              
30             =head1 FEEDBACK
31              
32             =head2 Mailing Lists
33              
34             User feedback is an integral part of the evolution of this and other
35             Bioperl modules. Send your comments and suggestions preferably to
36             the Bioperl mailing list. Your participation is much appreciated.
37              
38             bioperl-l@bioperl.org - General discussion
39             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
40              
41             =head2 Support
42              
43             Please direct usage questions or support issues to the mailing list:
44              
45             I
46              
47             rather than to the module maintainer directly. Many experienced and
48             reponsive experts will be able look at the problem and quickly
49             address it. Please include a thorough description of the problem
50             with code and data examples if at all possible.
51              
52             =head2 Reporting Bugs
53              
54             Report bugs to the Bioperl bug tracking system to help us keep track
55             of the bugs and their resolution. Bug reports can be submitted via the
56             web:
57              
58             https://github.com/bioperl/bioperl-live/issues
59              
60             =head1 AUTHOR - Jason Stajich
61              
62             Email jason@bioperl.org
63              
64             =head1 APPENDIX
65              
66             The rest of the documentation details each of the object methods.
67             Internal methods are usually preceded with a _
68              
69             =cut
70              
71              
72             # Let the code begin...
73              
74              
75             package Bio::Symbol::DNAAlphabet;
76 1     1   644 use strict;
  1         1  
  1         23  
77              
78 1     1   4 use Bio::Symbol::Symbol;
  1         1  
  1         15  
79 1     1   230 use Bio::Tools::IUPAC;
  1         2  
  1         24  
80              
81 1     1   5 use base qw(Bio::Symbol::Alphabet);
  1         1  
  1         245  
82              
83             =head2 new
84              
85             Title : new
86             Usage : my $obj = Bio::Symbol::DNAAlphabet->new();
87             Function: Builds a new Bio::Symbol::DNAAlphabet object
88             Returns : Bio::Symbol::DNAAlphabet
89             Args :
90              
91              
92             =cut
93              
94             sub new {
95 1     1 1 4 my($class,@args) = @_;
96 1         6 my $self = $class->SUPER::new(@args);
97 1         4 my %alphabet = Bio::Tools::IUPAC::iupac_iub();
98 1         2 my %symbols;
99 1         4 foreach my $let ( keys %alphabet ) {
100 17 100 66     19 next unless @{$alphabet{$let}} == 1 || $let eq 'U';
  17         41  
101 5         15 $symbols{$let} = Bio::Symbol::Symbol->new(-name => $let,
102             -token => $let);
103             }
104            
105 1         5 foreach my $let ( keys %alphabet ) {
106 17 100 66     40 next if( $symbols{$let} || $let eq 'U');
107 12         13 my @subsymbols;
108            
109 12         12 foreach my $sublet ( @{$alphabet{$let}} ) {
  12         19  
110 32         41 push @subsymbols, $symbols{$sublet};
111             }
112 12         26 my $alpha = Bio::Symbol::Alphabet->new(-symbols => \@subsymbols);
113 12         34 $symbols{$let} = Bio::Symbol::Symbol->new(-name => $let,
114             -token => $let,
115             -matches => $alpha,
116             -symbols => \@subsymbols);
117             }
118            
119 1         10 $self->symbols(values %symbols);
120 1         4 return $self;
121             }
122              
123              
124             1;