~ubuntu-branches/ubuntu/lucid/bioperl/lucid

« back to all changes in this revision

Viewing changes to Bio/PopGen/PopulationI.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: PopulationI.pm,v 1.6 2003/07/29 02:53:06 jason Exp $
 
2
#
 
3
# BioPerl module for Bio::PopGen::PopulationI
 
4
#
 
5
# Cared for by Jason Stajich <jason@bioperl.org>
 
6
#
 
7
# Copyright Jason Stajich
 
8
#
 
9
# You may distribute this module under the same terms as perl itself
 
10
 
 
11
# POD documentation - main docs before the code
 
12
 
 
13
=head1 NAME
 
14
 
 
15
Bio::PopGen::PopulationI - Interface for Populations
 
16
 
 
17
=head1 SYNOPSIS
 
18
 
 
19
  # Get Bio::PopGen::PopulationI object somehow, like
 
20
  # from Bio::Population::Population
 
21
 
 
22
  print "name is ", $population->name(), "\n";
 
23
  print "source is ", $population->source(), "\n";
 
24
  print "description is ", $population->description(), "\n";
 
25
 
 
26
  print "For marker $markername:\n";
 
27
  foreach my $genotype ( $population->get_Genotypes(-marker => $markername) ) {
 
28
      print "Individual ", $genotype->individual_id, " genotype alleles are ",
 
29
      join(',', $genotype->get_Alleles()), "\n";
 
30
  }
 
31
  # get a marker with allele frequencies calculated from the population
 
32
  my $marker = $population->get_Marker($markername); 
 
33
  my %af = $marker->get_Allele_Frequencies;
 
34
  foreach my $allele ( keys %af ) {
 
35
      print "$allele $af{$allele}\n";
 
36
  }
 
37
 
 
38
=head1 DESCRIPTION
 
39
 
 
40
This interface describes the basics of a population.  One can use this
 
41
object to get the genotypes of specific individuals, only those
 
42
individuals which have a certain marker, or create a marker with
 
43
allele frequency information.
 
44
 
 
45
=head1 FEEDBACK
 
46
 
 
47
=head2 Mailing Lists
 
48
 
 
49
User feedback is an integral part of the evolution of this and other
 
50
Bioperl modules. Send your comments and suggestions preferably to the
 
51
Bioperl mailing list.  Your participation is much appreciated.
 
52
 
 
53
  bioperl-l@bioperl.org              - General discussion
 
54
  http://bioperl.org/MailList.shtml  - About the mailing lists
 
55
 
 
56
=head2 Reporting Bugs
 
57
 
 
58
Report bugs to the Bioperl bug tracking system to help us keep track
 
59
of the bugs and their resolution. Bug reports can be submitted via
 
60
email or the web:
 
61
 
 
62
  http://bugzilla.bioperl.org/
 
63
 
 
64
=head1 AUTHOR - Jason Stajich
 
65
 
 
66
Email jason-at-bioperl.org
 
67
 
 
68
=head1 CONTRIBUTORS
 
69
 
 
70
Matthew Hahn, matthew.hahn-at-duke.edu
 
71
 
 
72
=head1 APPENDIX
 
73
 
 
74
The rest of the documentation details each of the object methods.
 
75
Internal methods are usually preceded with a _
 
76
 
 
77
=cut
 
78
 
 
79
 
 
80
# Let the code begin...
 
81
 
 
82
 
 
83
package Bio::PopGen::PopulationI;
 
84
use vars qw(@ISA);
 
85
use strict;
 
86
use Carp;
 
87
use Bio::Root::RootI;
 
88
 
 
89
@ISA = qw( Bio::Root::RootI );
 
90
 
 
91
=head2 name
 
92
 
 
93
 Title   : name
 
94
 Usage   : my $name = $pop->name
 
95
 Function: Get the population name
 
96
 Returns : string representing population name
 
97
 Args    : [optional] string representing population name
 
98
 
 
99
 
 
100
=cut
 
101
 
 
102
sub name{
 
103
   my ($self,@args) = @_;
 
104
   $self->throw_not_implemented();
 
105
}
 
106
 
 
107
 
 
108
 
 
109
=head2 description
 
110
 
 
111
 Title   : description
 
112
 Usage   : my $description = $pop->description
 
113
 Function: Get the population description
 
114
 Returns : string representing population description
 
115
 Args    : [optional] string representing population description
 
116
 
 
117
 
 
118
=cut
 
119
 
 
120
sub description{
 
121
   my ($self,@args) = @_;
 
122
   $self->throw_not_implemented();
 
123
}
 
124
 
 
125
=head2 source
 
126
 
 
127
 Title   : source
 
128
 Usage   : my $source = $pop->source
 
129
 Function: Get the population source
 
130
 Returns : string representing population source
 
131
 Args    : [optional] string representing population source
 
132
 
 
133
 
 
134
=cut
 
135
 
 
136
sub source{
 
137
   my ($self,@args) = @_;
 
138
   $self->throw_not_implemented();
 
139
}
 
140
 
 
141
=head2 get_Individuals
 
142
 
 
143
 Title   : get_Individuals
 
144
 Usage   : my @inds = $pop->get_Individuals();
 
145
 Function: Return the individuals, alternatively restrict by a criteria
 
146
 Returns : Array of L<Bio::PopGen::IndividualI> objects
 
147
 Args    : none if want all the individuals OR,
 
148
           -unique_id => To get an individual with a specific id
 
149
           -marker    => To only get individuals which have a genotype specific
 
150
                        for a specific marker name
 
151
 
 
152
 
 
153
=cut
 
154
 
 
155
sub get_Individuals{
 
156
    shift->throw_not_implemented();
 
157
}
 
158
 
 
159
=head2 get_Genotypes
 
160
 
 
161
 Title   : get_Genotypes
 
162
 Usage   : my @genotypes = $pop->get_Genotypes(-marker => $name)
 
163
 Function: Get the genotypes for all the individuals for a specific
 
164
           marker name
 
165
 Returns : Array of L<Bio::PopGen::GenotypeI> objects
 
166
 Args    : -marker => name of the marker
 
167
 
 
168
 
 
169
=cut
 
170
 
 
171
sub get_Genotypes{
 
172
    shift->throw_not_implemented;
 
173
}
 
174
 
 
175
=head2 get_Marker
 
176
 
 
177
 Title   : get_Marker
 
178
 Usage   : my $marker = $population->get_Marker($name)
 
179
 Function: Get a Bio::PopGen::Marker object based on this population
 
180
 Returns : L<Bio::PopGen::MarkerI> object
 
181
 Args    : name of the marker
 
182
 
 
183
 
 
184
=cut
 
185
 
 
186
sub get_Marker{
 
187
    shift->throw_not_implemented();
 
188
}
 
189
 
 
190
=head2 get_marker_names
 
191
 
 
192
 Title   : get_marker_names
 
193
 Usage   : my @names = $pop->get_marker_names;
 
194
 Function: Get the names of the markers
 
195
 Returns : Array of strings
 
196
 Args    : none
 
197
 
 
198
 
 
199
=cut
 
200
 
 
201
sub get_marker_names{
 
202
    my ($self) = @_;
 
203
    $self->throw_not_implemented();
 
204
}
 
205
 
 
206
=head2 get_Markers
 
207
 
 
208
 Title   : get_Markers
 
209
 Usage   : my @markers = $pop->get_Markers();
 
210
 Function: Will retrieve a list of instantiated MarkerI objects 
 
211
           for a population.  This is a convience method combining
 
212
           get_marker_names with get_Marker
 
213
 Returns : List of array of Bio::PopGen::MarkerI objects
 
214
 Args    : none
 
215
 
 
216
 
 
217
=cut
 
218
 
 
219
sub get_Markers{
 
220
    my ($self) = shift;
 
221
    return map { $self->get_Marker($_) } $self->get_marker_names();
 
222
}
 
223
 
 
224
 
 
225
=head2 number_individuals
 
226
 
 
227
 Title   : number_individuals
 
228
 Usage   : my $count = $pop->number_individuals;
 
229
 Function: Get the count of the number of individuals
 
230
 Returns : integer >= 0
 
231
 Args    : [optional] marker name, will return a count of the number
 
232
           of individuals which have this marker
 
233
 
 
234
 
 
235
=cut
 
236
 
 
237
sub get_number_individuals{
 
238
   my ($self) = @_;
 
239
   $self->throw_not_implemented();
 
240
}
 
241
 
 
242
1;