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