3 # BioPerl module for Bio::PopGen::Marker
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::PopGen::Marker - A genetic marker which one uses to generate genotypes
21 my $name = $marker->name(); # marker name
22 my $description = $marker->description(); # description
23 my $type = $marker->type(); # coded type of the marker
24 my $unique_id = $marker->unique_id; # optional unique ID
25 my @alleles = $marker->get_Alleles(); # the known alleles
26 my %allele_freqs = $marker->get_Allele_Frequencies(); # keys are marker names
27 # vals are frequencies
28 # may change to handle multiple populations
32 This object will not contain genotype information pertaining to an
33 individual, but rather population level statistics and descriptive
34 information about a marker.
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to
42 the Bioperl mailing list. Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 L<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted via
64 http://bugzilla.open-bio.org/
66 =head1 AUTHOR - Jason Stajich
68 Email jason-at-bioperl.org
72 Matthew Hahn, matthew.hahn-at-duke.edu
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
::PopGen
::Marker
;
88 # Object preamble - inherits from Bio::Root::Root
91 use vars
qw($UniqueCounter);
95 use base qw(Bio::Root::Root Bio::PopGen::MarkerI);
100 Usage : my $obj = Bio::PopGen::Marker->new();
101 Function: Builds a new Bio::PopGen::Marker object
102 Returns : an instance of Bio::PopGen::Marker
103 Args : -name => [string] marker name
104 -description => [string] marker description
105 -type => [string] marker type
106 -unique_id => [string/int] unique id
107 -allele_freq => [hash ref] allele frequencies
112 my($class,@args) = @_;
114 my $self = $class->SUPER::new
(@args);
115 my ($name,$desc,$type,$uid,$af) = $self->_rearrange([qw(NAME
119 ALLELE_FREQ)],@args);
120 $self->{'_allele_freqs'} = {};
121 if( ! defined $uid ) {
122 $uid = $UniqueCounter++;
127 $self->throw("Must provide a name when initializing a Marker");
129 defined $desc && $self->description($desc);
130 defined $type && $self->type($type);
131 $self->unique_id($uid);
133 if( ref($af) !~ /HASH/i ) {
134 $self->warn("Must provide valid Hash reference for allele_freq method");
136 foreach my $allele ( keys %$af ) {
137 $self->add_Allele_Frequency($allele, $af->{$allele});
147 Usage : my $name = $marker->name();
148 Function: Get the name of the marker
149 Returns : string representing the name of the marker
150 Args : [optional] name
158 return $self->{'_name'} = shift if @_;
159 return $self->{'_name'};
166 Usage : my $desc = $marker->description
167 Function: Get the marker description free text
169 Args : [optional] string
177 return $self->{'_description'} = shift if @_;
178 return $self->{'_description'};
184 Usage : my $type = $marker->type;
185 Function: Get coded string for marker type
187 Args : [optional] string
195 return $self->{'_type'} = shift if @_;
196 return $self->{'_type'};
203 Usage : my $id = $marker->unique_id;
204 Function: Get the unique marker ID
205 Returns : unique ID string
206 Args : [optional ] string
214 return $self->{'_uniqueid'} = shift if @_;
215 return $self->{'_uniqueid'};
221 Usage : my @alleles = $marker->get_Alleles();
222 Function: Get the available marker alleles
223 Returns : Array of strings
230 my (@numeric,@alpha);
232 for ( keys %{$self->{'_allele_freqs'}} ) {
233 if( /[^\d\.\-e]/ ) { push @alpha, $_ }
234 else { push @numeric, $_ }
236 @numeric = sort { $b <=> $a } @numeric;
237 @alpha = sort { $b cmp $a } @alpha;
238 return @numeric,@alpha;
242 =head2 get_Allele_Frequencies
244 Title : get_Allele_Frequencies
245 Usage : my %allele_freqs = $marker->get_Allele_Frequencies;
246 Function: Get the alleles and their frequency (set relative to
247 a given population - you may want to create different
248 markers with the same name for different populations
249 with this current implementation
250 Returns : Associative array where keys are the names of the alleles
256 sub get_Allele_Frequencies
{
257 return %{$_[0]->{'_allele_freqs'}};
260 =head2 add_Allele_Frequency
262 Title : add_Allele_Frequency
263 Usage : $marker->add_Allele_Frequency($allele,$freq)
264 Function: Adds an allele frequency
266 Args : $allele - allele name
267 $freq - frequency value
272 sub add_Allele_Frequency
{
273 my ($self,$allele,$freq) = @_;
274 $self->{'_allele_freqs'}->{$allele} = $freq;
279 Title : reset_alleles
280 Usage : $marker->reset_alleles();
281 Function: Reset the alleles for a marker
290 $self->{'_allele_freqs'} = {};