2 # BioPerl module for Bio::Symbol::Alphabet
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::Alphabet - BSANE/BioCORBA compliant symbol list alphabet
21 my $alphabet = Bio::Symbols::Alphabet->new(-symbols => [ @s ],
22 -subalphabets => [ @alphas ] );
24 my @symbols = $alphabet->symbols;
25 my @subalphas = $alphabet->alphabets;
26 if( $alphabet->contains($symbol) ) {
33 Alphabet contains set of symbols, which can be concatenated to
34 form symbol lists. Sequence string, for example, is stringified
35 representation of the symbol list (tokens of symbols).
37 This module was implemented for the purposes of meeting the
38 BSANE/BioCORBA spec 0.3 only.
44 User feedback is an integral part of the evolution of this and other
45 Bioperl modules. Send your comments and suggestions preferably to
46 the Bioperl mailing list. Your participation is much appreciated.
48 bioperl-l@bioperl.org - General discussion
49 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
53 Please direct usage questions or support issues to the mailing list:
55 I<bioperl-l@bioperl.org>
57 rather than to the module maintainer directly. Many experienced and
58 reponsive experts will be able look at the problem and quickly
59 address it. Please include a thorough description of the problem
60 with code and data examples if at all possible.
64 Report bugs to the Bioperl bug tracking system to help us keep track
65 of the bugs and their resolution. Bug reports can be submitted via the
68 https://github.com/bioperl/bioperl-live/issues
70 =head1 AUTHOR - Jason Stajich
72 Email jason@bioperl.org
76 The rest of the documentation details each of the object methods.
77 Internal methods are usually preceded with a _
82 # Let the code begin...
85 package Bio
::Symbol
::Alphabet
;
88 # Object preamble - inherits from Bio::Root::Root
91 use base
qw(Bio::Root::Root Bio::Symbol::AlphabetI);
96 Usage : my $obj = Bio::Symbol::Alphabet->new();
97 Function: Builds a new Bio::Symbol::Alphabet object
98 Returns : Bio::Symbol::Alphabet
99 Args : -symbols => Array ref of Bio::Symbol::SymbolI objects
100 -subalphas=> Array ref of Bio::Symbol::AlphabetI objects
101 representing sub alphabets
106 my($class,@args) = @_;
108 my $self = $class->SUPER::new
(@args);
109 $self->{'_symbols'} = [];
110 $self->{'_alphabets'} = [];
111 my ($symbols, $subalphas) = $self->_rearrange([qw(SYMBOLS SUBALPHAS)],
114 defined $symbols && ref($symbols) =~ /array/i && $self->symbols(@
$symbols);
115 defined $subalphas && ref($subalphas) =~ /array/i && $self->alphabets(@
$subalphas);
119 =head2 AlphabetI Interface methods
126 Usage : my @symbols = $alphabet->symbols();
127 Function: Get/Set Symbol list for an alphabet
128 List of symbols, which make up this alphabet.
129 Returns : Array of Bio::Symbol::SymbolI objects
130 Args : (optionalalphabets) Array of Bio::Symbol::SymbolI objects
135 my ($self,@args) = @_;
137 $self->{'_symbols'} = [];
138 foreach my $symbol ( @args ) {
139 if( ! defined $symbol || ! ref($symbol) ||
140 ! $symbol->isa('Bio::Symbol::SymbolI') ) {
141 $self->warn("Did not provide a proper Bio::Symbol::SymbolI to method 'symbols' (got $symbol)");
143 push @
{$self->{'_symbols'}}, $symbol;
147 return @
{$self->{'_symbols'}};
153 Usage : my @alphabets = $alphabet->alphabets();
154 Function: Get/Set Sub Alphabet list for an alphabet
155 Sub-alphabets. E.g. codons made from DNAxDNAxDNA alphabets
156 Returns : Array of Bio::Symbol::AlphabetI objects
157 Args : (optional) Array of Bio::Symbol::AlphabetI objects
162 my ($self,@args) = @_;
164 $self->{'_alphabets'} = [];
165 foreach my $alpha ( @args ) {
166 if( ! $alpha->isa('Bio::Symbol::AlphabetI') ) {
167 $self->warn("Did not provide a proper Bio::Symbol::AlphabetI to method 'alphabets' (got $alpha)");
169 push @
{$self->{'_alphabets'}}, $alpha;
173 return @
{$self->{'_alphabets'}};
179 Usage : if($alphabet->contains($symbol)) { }
180 Function: Tests of Symbol is contained in this alphabet
182 Args : Bio::Symbol::SymbolI
187 my ($self,$testsymbol) = @_;
188 foreach my $symbol ( $self->symbols ) {
189 return 1 if( $symbol->equals($testsymbol) );