3 # BioPerl module for Bio::Symbol::Alphabet
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Jason Stajich <jason@bioperl.org>
9 # Copyright Jason Stajich
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Symbol::Alphabet - BSANE/BioCORBA compliant symbol list alphabet
22 my $alphabet = Bio::Symbols::Alphabet->new(-symbols => [ @s ],
23 -subalphabets => [ @alphas ] );
25 my @symbols = $alphabet->symbols;
26 my @subalphas = $alphabet->alphabets;
27 if( $alphabet->contains($symbol) ) {
34 Alphabet contains set of symbols, which can be concatenated to
35 form symbol lists. Sequence string, for example, is stringified
36 representation of the symbol list (tokens of symbols).
38 This module was implemented for the purposes of meeting the
39 BSANE/BioCORBA spec 0.3 only.
45 User feedback is an integral part of the evolution of this and other
46 Bioperl modules. Send your comments and suggestions preferably to
47 the Bioperl mailing list. Your participation is much appreciated.
49 bioperl-l@bioperl.org - General discussion
50 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
54 Please direct usage questions or support issues to the mailing list:
56 I<bioperl-l@bioperl.org>
58 rather than to the module maintainer directly. Many experienced and
59 reponsive experts will be able look at the problem and quickly
60 address it. Please include a thorough description of the problem
61 with code and data examples if at all possible.
65 Report bugs to the Bioperl bug tracking system to help us keep track
66 of the bugs and their resolution. Bug reports can be submitted via the
69 http://bugzilla.open-bio.org/
71 =head1 AUTHOR - Jason Stajich
73 Email jason@bioperl.org
77 The rest of the documentation details each of the object methods.
78 Internal methods are usually preceded with a _
83 # Let the code begin...
86 package Bio
::Symbol
::Alphabet
;
89 # Object preamble - inherits from Bio::Root::Root
92 use base
qw(Bio::Root::Root Bio::Symbol::AlphabetI);
97 Usage : my $obj = Bio::Symbol::Alphabet->new();
98 Function: Builds a new Bio::Symbol::Alphabet object
99 Returns : Bio::Symbol::Alphabet
100 Args : -symbols => Array ref of Bio::Symbol::SymbolI objects
101 -subalphas=> Array ref of Bio::Symbol::AlphabetI objects
102 representing sub alphabets
107 my($class,@args) = @_;
109 my $self = $class->SUPER::new
(@args);
110 $self->{'_symbols'} = [];
111 $self->{'_alphabets'} = [];
112 my ($symbols, $subalphas) = $self->_rearrange([qw(SYMBOLS SUBALPHAS)],
115 defined $symbols && ref($symbols) =~ /array/i && $self->symbols(@
$symbols);
116 defined $subalphas && ref($subalphas) =~ /array/i && $self->alphabets(@
$subalphas);
120 =head2 AlphabetI Interface methods
127 Usage : my @symbols = $alphabet->symbols();
128 Function: Get/Set Symbol list for an alphabet
129 List of symbols, which make up this alphabet.
130 Returns : Array of Bio::Symbol::SymbolI objects
131 Args : (optionalalphabets) Array of Bio::Symbol::SymbolI objects
136 my ($self,@args) = @_;
138 $self->{'_symbols'} = [];
139 foreach my $symbol ( @args ) {
140 if( ! defined $symbol || ! ref($symbol) ||
141 ! $symbol->isa('Bio::Symbol::SymbolI') ) {
142 $self->warn("Did not provide a proper Bio::Symbol::SymbolI to method 'symbols' (got $symbol)");
144 push @
{$self->{'_symbols'}}, $symbol;
148 return @
{$self->{'_symbols'}};
154 Usage : my @alphabets = $alphabet->alphabets();
155 Function: Get/Set Sub Alphabet list for an alphabet
156 Sub-alphabets. E.g. codons made from DNAxDNAxDNA alphabets
157 Returns : Array of Bio::Symbol::AlphabetI objects
158 Args : (optional) Array of Bio::Symbol::AlphabetI objects
163 my ($self,@args) = @_;
165 $self->{'_alphabets'} = [];
166 foreach my $alpha ( @args ) {
167 if( ! $alpha->isa('Bio::Symbol::AlphabetI') ) {
168 $self->warn("Did not provide a proper Bio::Symbol::AlphabetI to method 'alphabets' (got $alpha)");
170 push @
{$self->{'_alphabets'}}, $alpha;
174 return @
{$self->{'_alphabets'}};
180 Usage : if($alphabet->contains($symbol)) { }
181 Function: Tests of Symbol is contained in this alphabet
183 Args : Bio::Symbol::SymbolI
188 my ($self,$testsymbol) = @_;
189 foreach my $symbol ( $self->symbols ) {
190 return 1 if( $symbol->equals($testsymbol) );