Mercurial > repos > willmclaren > ensembl_vep
comparison variant_effect_predictor/Bio/EnsEMBL/Compara/SpeciesSet.pm @ 0:21066c0abaf5 draft
Uploaded
author | willmclaren |
---|---|
date | Fri, 03 Aug 2012 10:04:48 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:21066c0abaf5 |
---|---|
1 package Bio::EnsEMBL::Compara::SpeciesSet; | |
2 | |
3 use strict; | |
4 | |
5 use Bio::EnsEMBL::Utils::Exception qw(warning deprecate throw); | |
6 use Bio::EnsEMBL::Utils::Argument qw(rearrange); | |
7 | |
8 # FIXME: add throw not implemented for those not tag related? | |
9 use base ( 'Bio::EnsEMBL::Storable', # inherit dbID(), adaptor() and new() methods | |
10 'Bio::EnsEMBL::Compara::Taggable' # inherit everything related to tagability | |
11 ); | |
12 | |
13 | |
14 =head2 new | |
15 | |
16 Arg [..] : Takes a set of named arguments | |
17 Example : my $my_species_set = Bio::EnsEMBL::Compara::SpeciesSet->new( | |
18 -dbID => $species_set_id, | |
19 -genome_dbs => [$gdb1, $gdb2, $gdb3 ], | |
20 -adaptor => $species_set_adaptor ); | |
21 Description: Creates a new SpeciesSet object | |
22 Returntype : Bio::EnsEMBL::Compara::SpeciesSet | |
23 | |
24 =cut | |
25 | |
26 sub new { | |
27 my $caller = shift @_; | |
28 my $class = ref($caller) || $caller; | |
29 | |
30 my $self = $class->SUPER::new(@_); # deal with Storable stuff | |
31 | |
32 my ($genome_dbs) = rearrange([qw(GENOME_DBS)], @_); | |
33 | |
34 $self->genome_dbs($genome_dbs) if (defined ($genome_dbs)); | |
35 | |
36 return $self; | |
37 } | |
38 | |
39 | |
40 =head2 genome_dbs | |
41 | |
42 Arg [1] : (opt.) list of genome_db objects | |
43 Example : my $genome_dbs = $species_set->genome_dbs(); | |
44 Example : $species_set->genome_dbs( [$gdb1, $gdb2, $gdb3] ); | |
45 Description: Getter/Setter for the genome_dbs of this object in the database | |
46 Returntype : arrayref genome_dbs | |
47 Exceptions : none | |
48 Caller : general | |
49 | |
50 =cut | |
51 | |
52 sub genome_dbs { | |
53 my ($self, $arg) = @_; | |
54 | |
55 if (defined $arg) { | |
56 ## Check content | |
57 my $genome_dbs = {}; | |
58 foreach my $gdb (@$arg) { | |
59 throw("undefined value used as a Bio::EnsEMBL::Compara::GenomeDB\n") | |
60 if (!defined($gdb)); | |
61 throw("$gdb must be a Bio::EnsEMBL::Compara::GenomeDB\n") | |
62 unless UNIVERSAL::isa($gdb, "Bio::EnsEMBL::Compara::GenomeDB"); | |
63 | |
64 unless (defined $genome_dbs->{$gdb->dbID}) { | |
65 $genome_dbs->{$gdb->dbID} = $gdb; | |
66 } else { | |
67 warn("GenomeDB (".$gdb->name."; dbID=".$gdb->dbID . | |
68 ") appears twice in this Bio::EnsEMBL::Compara::SpeciesSet\n"); | |
69 } | |
70 } | |
71 $self->{'genome_dbs'} = [ values %{$genome_dbs} ] ; | |
72 } | |
73 return $self->{'genome_dbs'}; | |
74 } | |
75 | |
76 | |
77 =head2 toString | |
78 | |
79 Args : (none) | |
80 Example : print $species_set->toString()."\n"; | |
81 Description: returns a stringified representation of the species_set | |
82 Returntype : string | |
83 | |
84 =cut | |
85 | |
86 sub toString { | |
87 my $self = shift; | |
88 | |
89 my $name = $self->get_tagvalue('name'); | |
90 return ref($self).": dbID=".($self->dbID || '?').", name='".($name || '?')."', genome_dbs=[".join(', ', map { $_->name.'('.($_->dbID || '?').')'} @{ $self->genome_dbs })."]"; | |
91 } | |
92 | |
93 | |
94 | |
95 1; | |
96 |