2 # BioPerl module for Bio::Symbol::Symbol
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason@bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Symbol::Symbol - A biological symbol
20 use Bio::Symbol::Symbol;
21 my $thymine = Bio::Symbol::Symbol->new(-name => 'Thy',
23 my $a = Bio::Symbol::Symbol->new(-token => 'A' );
24 my $u = Bio::Symbol::Symbol->new(-token => 'U' );
25 my $g = Bio::Symbol::Symbol->new(-token => 'G' );
27 my $M = Bio::Symbol::Symbol->new(-name => 'Met',
29 -symbols => [ $a, $u, $g ]);
31 my ($name,$token) = ($a->name, $a->token);
32 my @symbols = $a->symbols;
33 my $matches = $a->matches;
37 Symbol represents a single token in the sequence. Symbol can have
38 multiple synonyms or matches within the same Alphabet, which
39 makes possible to represent ambiguity codes and gaps.
41 Symbols can be also composed from ordered list other symbols. For
42 example, codons can be represented by single Symbol using a
43 compound Alphabet made from three DNA Alphabets.
45 This module was implemented for the purposes of meeting the
46 BSANE/BioCORBA spec 0.3 only.
52 User feedback is an integral part of the evolution of this and other
53 Bioperl modules. Send your comments and suggestions preferably to
54 the Bioperl mailing list. Your participation is much appreciated.
56 bioperl-l@bioperl.org - General discussion
57 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
61 Please direct usage questions or support issues to the mailing list:
63 I<bioperl-l@bioperl.org>
65 rather than to the module maintainer directly. Many experienced and
66 reponsive experts will be able look at the problem and quickly
67 address it. Please include a thorough description of the problem
68 with code and data examples if at all possible.
72 Report bugs to the Bioperl bug tracking system to help us keep track
73 of the bugs and their resolution. Bug reports can be submitted via the
76 https://github.com/bioperl/bioperl-live/issues
78 =head1 AUTHOR - Jason Stajich
80 Email jason@bioperl.org
84 The rest of the documentation details each of the object methods.
85 Internal methods are usually preceded with a _
90 # Let the code begin...
93 package Bio
::Symbol
::Symbol
;
96 # Object preamble - inherits from Bio::Root::Root
98 use Bio
::Symbol
::Alphabet
;
100 use base
qw(Bio::Root::Root Bio::Symbol::SymbolI);
105 Usage : my $obj = Bio::Symbol::Symbol->new();
106 Function: Builds a new Bio::Symbol::Symbol object
107 Returns : Bio::Symbol::Symbol
108 Args : -name => descriptive name (string) [e.g. Met]
109 -token => Shorthand token (string) [e.g. M]
110 -symbols => Symbols that make up this symbol (array) [e.g. AUG]
111 -matches => Alphabet in the event symbol is an ambiguity
117 my($class,@args) = @_;
118 my $self = $class->SUPER::new
(@args);
119 $self->{'_symbols'} = [];
121 my ($name, $token, $symbols,
122 $matches) = $self->_rearrange([qw(NAME TOKEN SYMBOLS
125 $token && $self->token($token);
126 $name && $self->name($name);
127 $symbols && ref($symbols) =~ /array/i && $self->symbols(@
$symbols);
128 $matches && $self->matches($matches);
135 Usage : my $name = $symbol->name();
136 Function: Get/Set Descriptive name for Symbol
138 Args : (optional) string
143 my ($self,$value) = @_;
145 $self->{'_name'} = $value;
147 return $self->{'_name'} || '';
153 Usage : my $token = $self->token();
154 Function: Get/Set token for this symbol
155 Example : Letter A,C,G,or T for a DNA alphabet Symbol
157 Args : (optional) string
162 my ($self,$value) = @_;
164 $self->{'_token'} = $value;
166 return $self->{'_token'} || '';
172 Usage : my @symbols = $self->symbols();
173 Function: Get/Set Symbols this Symbol is composed from
174 Example : Ambiguity symbols are made up > 1 base symbol
175 Returns : Array of Bio::Symbol::SymbolI objects
176 Args : (optional) Array of Bio::Symbol::SymbolI objects
182 my ($self,@args) = @_;
184 $self->{'_symbols'} = [@args];
186 return @
{$self->{'_symbols'}};
192 Usage : my $matchalphabet = $symbol->matches();
193 Function: Get/Set (Sub) alphabet of symbols matched by this symbol
194 including the symbol itself (i.e. if symbol is DNA
195 ambiguity code W then the matches contains symbols for W
197 Returns : Bio::Symbol::AlphabetI
198 Args : (optional) Bio::Symbol::AlphabetI
203 my ($self,$matches) = @_;
206 if( ! $matches->isa('Bio::Symbol::AlphabetI') ) {
207 $self->warn("Must pass in a Bio::Symbol::AlphabetI object to matches function");
208 # stick with previous value
210 $self->{'_matches'} = $matches;
213 return $self->{'_matches'};
219 Usage : if( $symbol->equals($symbol2) ) { }
220 Function: Tests if a symbol is equal to another
222 Args : Bio::Symbol::SymbolI
227 my ($self,$symbol2) = @_;
228 # Let's just test based on Tokens for now
229 # Doesn't handle DNA vs PROTEIN accidential comparisons
230 return $self->token eq $symbol2->token;