3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
38 -name =>
'new_biotype,
39 -object_type => 'gene
',
40 -biotype_group => 'a_biotype_group
',
41 -so_acc => 'SO::1234567
',
42 -description => 'New biotype
'
45 my $name = $biotype->name();
46 my $biotype_group = $biotype->biotype_group();
47 my $so_acc = $biotype->so_acc();
51 This is the Biotype object class.
52 Gene and Transcript objects used to have a biotype() method that returned the biotype name
53 (the biotype field in the gene and transcript tables).
54 From e93 a new biotype table was added. However because of legacy code using direct sql
55 queries on the biotype column of gene and transcript tables, that column that contains the
56 biotype name was not replaced by biotype_id containing a foreign key to the new biotype table.
57 Gene and Transcripts can still link to a Biotype through the key (name, object_type).
64 package Bio::EnsEMBL::Biotype;
69 use Bio::EnsEMBL::Storable;
70 use Bio::EnsEMBL::Utils::Exception qw(throw deprecate warning);
71 use Bio::EnsEMBL::Utils::Scalar qw(check_ref assert_ref);
72 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
73 use Scalar::Util qw(weaken isweak);
75 use parent qw(Bio::EnsEMBL::Storable);
80 int - dbID of the biotype
82 string - the name of the biotype (for ensembl)
84 string - the object type this biotype applies to (gene or transcript)
85 Arg [-BIOTYPE_GROUP] :
86 string - the name of the biotype group (for ensembl)
88 string - the Sequence Ontology accession of this biotype
90 string - the Sequence Ontology term for the SO accession of this biotype
92 string - the biotype description
94 string - the database type for this biotype
95 Arg [-ATTRIB_TYPE_ID] :
98 Example : $biotype = Bio::EnsEMBL::Biotype->new(...);
99 Description: Creates a new biotype object
100 Returntype : Bio::EnsEMBL::Biotype
106 my ( $caller, @args ) = @_;
108 my $class = ref($caller) || $caller;
110 my $self = $class->SUPER::new();
112 my($dbID, $name, $object_type, $biotype_group, $so_acc, $so_term, $description, $db_type, $attrib_type_id) =
113 rearrange([qw(BIOTYPE_ID NAME OBJECT_TYPE BIOTYPE_GROUP SO_ACC SO_TERM DESCRIPTION DB_TYPE ATTRIB_TYPE_ID)], @args);
115 $self->{'dbID
'} = $dbID;
116 $self->{'name
'} = $name;
117 $self->{'object_type
'} = $object_type;
118 $self->{'biotype_group
'} = $biotype_group;
119 $self->{'so_acc
'} = $so_acc;
120 $self->{'so_term
'} = $so_term;
121 $self->{'description
'} = $description;
122 $self->{'db_type
'} = $db_type;
123 $self->{'attrib_type_id
'} = $attrib_type_id;
130 Arg [1] : hashref to be blessed
131 Description: Construct a new Bio::EnsEMBL::Biotype using the hashref.
133 Returntype : Bio::EnsEMBL::Biotype
139 my ( $class, $hashref ) = @_;
141 my $self = bless $hashref, $class;
143 if ( !isweak($self->{adaptor}) ) {
144 weaken($self->{adaptor})
152 Arg [1] : (optional) string $name
153 The name of this biotype according to ensembl.
154 Example : $name = $biotype->name()
155 Description: Getter/Setter for the name of this biotype.
162 my ( $self, $name ) = @_;
164 if ( defined($name) ) {
165 $self->{'name
'} = $name;
168 return $self->{'name
'};
173 Arg [1] : (optional) string $biotype_group
174 Example : $biotype_group = $biotype->biotype_group();
175 Description: Getter/Setter for the biotype_group of this biotype.
176 Biotype groups are used internally at ensembl pipelines
177 and consist on few defined categories.
186 my ( $self, $biotype_group ) = @_;
188 if ( defined($biotype_group) ) {
189 $self->{'biotype_group
'} = $biotype_group;
192 return $self->{'biotype_group
'};
197 Arg [1] : (optional) string $so_acc
198 Example : $feat->so_acc();
199 Description: Getter/Setter for the Sequence Ontology accession of this biotype.
200 It must be a SO like accession.
202 Exceptions : thrown if an invalid so_acc argument is passed
207 my ( $self, $so_acc ) = @_;
209 if ( defined($so_acc) ) {
210 # throw an error if setting something that does not look like an SO acc
211 unless ( $so_acc =~ m/\ASO:\d+\z/x ) {
212 throw("so_acc must be a Sequence Ontology accession. '$so_acc
' does not look like one.")
215 $self->{'so_acc
'} = $so_acc;
218 return $self->{'so_acc
'};
223 Arg [1] : (optional) string $so_term
224 Example : $feat->so_term();
225 Description: Getter/Setter for the Sequence Ontology term of this biotype.
232 my ( $self, $so_term ) = @_;
234 if ( defined($so_term) ) {
235 $self->{'so_term
'} = $so_term;
238 return $self->{'so_term
'};
243 Arg [1] : (optional) string $object_type
244 Example : $object_type = $biotype->object_type();
245 Description: Getter/Setter for the object_type of this biotype.
246 Biotypes can be assigned to either genes or transcripts,
247 object_type refers to which of them.
249 Exceptions : thrown if an invalid object_type argument is passed (not gene or transcript)
254 my ( $self, $object_type ) = @_;
256 if ( defined($object_type) ) {
257 $object_type = lc $object_type;
258 # throw an error if setting something that does not look like an SO acc
259 unless ( $object_type eq 'gene
' || $object_type eq 'transcript' ) {
260 throw("object_type must be gene or transcript. Got '$object_type
'.")
263 $self->{'object_type
'} = $object_type;
266 return $self->{'object_type
'};