changes all issue tracking in preparation for switch to github issues
[bioperl-live.git] / Bio / Symbol / Alphabet.pm
blobdadb94c1bdeab683ec6e11e2c2bad97a49b02a19
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
14 =head1 NAME
16 Bio::Symbol::Alphabet - BSANE/BioCORBA compliant symbol list alphabet
18 =head1 SYNOPSIS
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) ) {
27 # do something
31 =head1 DESCRIPTION
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.
40 =head1 FEEDBACK
42 =head2 Mailing Lists
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
51 =head2 Support
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.
62 =head2 Reporting Bugs
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
66 web:
68 https://github.com/bioperl/bioperl-live/issues
70 =head1 AUTHOR - Jason Stajich
72 Email jason@bioperl.org
74 =head1 APPENDIX
76 The rest of the documentation details each of the object methods.
77 Internal methods are usually preceded with a _
79 =cut
82 # Let the code begin...
85 package Bio::Symbol::Alphabet;
86 use strict;
88 # Object preamble - inherits from Bio::Root::Root
91 use base qw(Bio::Root::Root Bio::Symbol::AlphabetI);
93 =head2 new
95 Title : new
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
103 =cut
105 sub new {
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)],
112 @args);
114 defined $symbols && ref($symbols) =~ /array/i && $self->symbols(@$symbols);
115 defined $subalphas && ref($subalphas) =~ /array/i && $self->alphabets(@$subalphas);
116 return $self;
119 =head2 AlphabetI Interface methods
121 =cut
123 =head2 symbols
125 Title : symbols
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
132 =cut
134 sub symbols {
135 my ($self,@args) = @_;
136 if( @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)");
142 } else {
143 push @{$self->{'_symbols'}}, $symbol;
147 return @{$self->{'_symbols'}};
150 =head2 alphabets
152 Title : alphabets
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
159 =cut
161 sub alphabets {
162 my ($self,@args) = @_;
163 if( @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)");
168 } else {
169 push @{$self->{'_alphabets'}}, $alpha;
173 return @{$self->{'_alphabets'}};
176 =head2 contains
178 Title : contains
179 Usage : if($alphabet->contains($symbol)) { }
180 Function: Tests of Symbol is contained in this alphabet
181 Returns : Boolean
182 Args : Bio::Symbol::SymbolI
184 =cut
186 sub contains{
187 my ($self,$testsymbol) = @_;
188 foreach my $symbol ( $self->symbols ) {
189 return 1 if( $symbol->equals($testsymbol) );
191 return 0;