2 # BioPerl module for Bio::Cluster::SequenceFamily
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Shawn Hoon <shawnh@fugu-sg.org>
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Cluster::SequenceFamily - Sequence Family object
21 use Bio::Cluster::SequenceFamily;
24 my $file = File::Spec->catfile('t','data','swiss.dat');
25 my $seqio= Bio::SeqIO->new(-format => 'swiss',
28 while(my $seq = $seqio->next_seq){
33 my $family = Bio::Cluster::SequenceFamily->new(
34 -family_id=>"Family_1",
35 -description=>"Family Description Here",
36 -annotation_score=>"100",
41 foreach my $mem ($family->get_members){
42 print $mem->display_id."\t".$mem->desc."\n";
45 #select members if members have a Bio::Species Object
47 my @mem = $family->get_members(-binomial=>"Homo sapiens");
48 @mem = $family->get_members(-ncbi_taxid => 9606);
49 @mem = $family->get_members(-common_name=>"Human");
50 @mem = $family->get_members(-species=>"sapiens");
51 @mem = $family->get_members(-genus=>"Homo");
55 This is a simple Family object that may hold any group of object. For more
56 specific families, one should derive from FamilyI.
60 Email bioperl-l@bioperl.org for support and feedback.
64 User feedback is an integral part of the evolution of this and other
65 Bioperl modules. Send your comments and suggestions preferably to one
66 of the Bioperl mailing lists. Your participation is much appreciated.
68 bioperl-l@bioperl.org - General discussion
69 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
73 Please direct usage questions or support issues to the mailing list:
75 I<bioperl-l@bioperl.org>
77 rather than to the module maintainer directly. Many experienced and
78 reponsive experts will be able look at the problem and quickly
79 address it. Please include a thorough description of the problem
80 with code and data examples if at all possible.
84 Report bugs to the Bioperl bug tracking system to help us keep track
85 the bugs and their resolution. Bug reports can be submitted via the
88 https://github.com/bioperl/bioperl-live/issues
90 =head1 AUTHOR - Shawn Hoon
92 Email shawnh@fugu-sg.org
96 The rest of the documentation details each of the object
97 methods. Internal methods are usually preceded with a "_".
101 # Let the code begin...
104 package Bio
::Cluster
::SequenceFamily
;
108 use base
qw(Bio::Root::Root Bio::Cluster::FamilyI);
113 Usage : my $family = Bio::Cluster::SequenceFamily->new(
114 -family_id=>"Family_1",
115 -description=>"Family Description Here",
116 -annotation_score=>"100",
118 Function: Constructor for SequenceFamily object
119 Returns : Bio::Cluster::SequenceFamily object
121 See L<Bio::Cluster::SequenceFamily>.
126 my ($class,@args) = @_;
127 my $self = $class->SUPER::new
(@args);
128 my ($id,$description,$version,$annot_score,
129 $family_score,$members) = $self->_rearrange([qw(FAMILY_ID DESCRIPTION VERSION
131 FAMILY_SCORE MEMBERS)],@args);
132 $self->{'_members'} = [];
133 $id && $self->family_id($id);
134 $description && $self->description($description);
135 $version && $self->version($version);
136 $annot_score && $self->annotation_score($annot_score);
137 $family_score && $self->family_score($family_score);
138 $members && $self->add_members($members);
146 Usage : $family->version("1.0");
147 Function: get/set for version
148 Returns : a string version of the family generated.
153 my ($self,$value) = @_;
155 $self->{'_version'} =$value;
157 return $self->{'_version'};
160 =head2 annotation_score
162 Title : annotation_score
163 Usage : $family->annotation_score(100);
164 Function: get/set for annotation_score which
165 represent the confidence in which the
166 consensus description has been assigned
168 Returns : Bio::SimpleAlign
170 See L<Bio::SimpleAlign>
174 sub annotation_score
{
175 my ($self,$score) = @_;
177 $self->{'_annotation_score'} = $score;
179 return $self->{'_annotation_score'};
185 Usage : $family->alignment($align);
186 Function: get/set for an alignment object representing
187 the multiple alignment of the members of the family.
188 Returns : Bio::SimpleAlign
190 See L<Bio::SimpleAlign>
195 my ($self,$align) = @_;
197 $self->{'_alignment'} = $align;
199 return $self->{'_alignment'};
205 Usage : $family->tree($tree);
206 Function: get/set for an tree object representing
207 the phylogenetic tree of the family.
215 my ($self,$tree) = @_;
217 $self->{'_tree'} = $tree;
219 return $self->{'_tree'};
222 =head1 L<Bio::Cluster::FamilyI> methods
229 Usage : Bio::Cluster::FamilyI->family_score(95);
230 Function: get/set for the score of algorithm used to generate
231 the family if present
233 This is aliased to cluster_score().
241 return shift->cluster_score(@_);
248 Usage : $family->family_id("Family_1");
249 Function: get/set for family id
251 This is aliased to display_id().
253 Returns : a string specifying identifier of the family
258 return shift->display_id(@_);
261 =head1 L<Bio::ClusterI> methods
269 Function: Get/set the display name or identifier for the cluster
271 Args : optional, on set the display ID ( a string)
278 $self->{'_cluster_id'} = $id;
280 return $self->{'_cluster_id'};
286 Usage : $fam->description("POLYUBIQUITIN")
287 Function: get/set for the consensus description of the cluster
288 Returns : the description string
289 Args : Optional the description string
294 my ($self,$desc) = @_;
296 $self->{'_description'} = $desc;
298 return $self->{'_description'};
304 Usage : Valid criteria:
310 $family->get_members(-common_name =>"human");
311 $family->get_members(-species =>"homo sapiens");
312 $family->get_members(-ncbi_taxid => 9606);
313 For now, multiple critieria are ORed.
315 Will return all members if no criteria are provided.
317 Function: get members using methods from L<Bio::Species>
318 the phylogenetic tree of the family.
319 Returns : an array of objects that are member of this family.
325 return @
{$self->{'_members'}} unless @_;
327 ## since the logic behind the checks is OR, we keep the ids in an hash for
328 ## performance (skip the test if it's already there) and to avoid repats
331 foreach my $key (keys %filter) {
332 (my $method = $key) =~ s/^-//;
333 %match = (%match, map { $_ => $_ } grep {
334 ! $match{$_} && $_->species &&
335 ($_->species->can($method) ||
336 $self->throw("$method is an invalid criteria")) &&
337 $_->species->$method() eq $filter{$key}
338 } @
{$self->{'_members'}});
340 return map {$match{$_}} keys (%match);
346 Usage : $fam->size();
347 Function: get/set for the size of the family,
348 calculated from the number of members
349 Returns : the size of the family
356 return scalar(@
{$self->{'_members'}});
361 Title : cluster_score
362 Usage : $fam->cluster_score(100);
363 Function: get/set for cluster_score which
364 represent the score in which the clustering
365 algorithm assigns to this cluster.
371 my ($self,$score) = @_;
373 $self->{'_cluster_score'} = $score;
375 return $self->{'_cluster_score'};
379 =head1 Implementation specific methods
381 These are mostly for adding/removing/changing.
388 Usage : $fam->add_member([$seq1,$seq1]);
389 Function: add members to a family
391 Args : the member(s) to add, as an array or arrayref
396 my ($self,@mems) = @_;
399 my $mem = shift(@mems);
400 if(ref($mem) eq "ARRAY"){
401 push @
{$self->{'_members'}},@
{$mem};
403 push @
{$self->{'_members'}},$mem;
405 push @
{$self->{'_members'}}, @mems;
410 =head2 remove_members
412 Title : remove_members
413 Usage : $fam->remove_members();
414 Function: remove all members from a family
415 Returns : the previous array of members
422 my $mems = $self->{'_members'};
423 $self->{'_members'} = [];
427 #####################################################################
428 # aliases for naming consistency or other reasons #
429 #####################################################################
431 *flush_members
= \
&remove_members
;
432 *add_member
= \
&add_members
;
437 Usage : $members = $fam->members([$seq1,$seq1]);
438 Function: Deprecated. Use add_members() or get_members() instead
445 # this is in set mode
446 $self->warn("setting members() in ".ref($self)." is deprecated.\n".
447 "Use add_members() instead.");
448 return $self->add_members(@_);
451 $self->warn("members() in ".ref($self)." is deprecated.\n".
452 "Use get_members() instead.");
453 return $self->get_members();