Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/Gene.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 =head1 LICENSE | |
2 | |
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
4 Genome Research Limited. All rights reserved. | |
5 | |
6 This software is distributed under a modified Apache license. | |
7 For license details, please see | |
8 | |
9 http://www.ensembl.org/info/about/code_licence.html | |
10 | |
11 =head1 CONTACT | |
12 | |
13 Please email comments or questions to the public Ensembl | |
14 developers list at <dev@ensembl.org>. | |
15 | |
16 Questions may also be sent to the Ensembl help desk at | |
17 <helpdesk@ensembl.org>. | |
18 | |
19 =cut | |
20 | |
21 =head1 NAME | |
22 | |
23 Bio::EnsEMBL::Gene - Object representing a genes | |
24 | |
25 =head1 SYNOPSIS | |
26 | |
27 my $gene = Bio::EnsEMBL::Gene->new( | |
28 -START => 123, | |
29 -END => 1045, | |
30 -STRAND => 1, | |
31 -SLICE => $slice | |
32 ); | |
33 | |
34 # print gene information | |
35 print("gene start:end:strand is " | |
36 . join( ":", map { $gene->$_ } qw(start end strand) ) | |
37 . "\n" ); | |
38 | |
39 # set some additional attributes | |
40 $gene->stable_id('ENSG000001'); | |
41 $gene->description('This is the gene description'); | |
42 | |
43 =head1 DESCRIPTION | |
44 | |
45 A representation of a Gene within the Ensembl system. A gene is a set of one or | |
46 more alternative transcripts. | |
47 | |
48 =head1 METHODS | |
49 | |
50 =cut | |
51 | |
52 package Bio::EnsEMBL::Gene; | |
53 | |
54 use strict; | |
55 | |
56 use POSIX; | |
57 use Bio::EnsEMBL::Feature; | |
58 use Bio::EnsEMBL::Utils::Argument qw(rearrange); | |
59 use Bio::EnsEMBL::Utils::Exception qw(throw warning deprecate); | |
60 use Bio::EnsEMBL::Utils::Scalar qw(assert_ref); | |
61 | |
62 use vars qw(@ISA); | |
63 @ISA = qw(Bio::EnsEMBL::Feature); | |
64 | |
65 | |
66 =head2 new | |
67 | |
68 Arg [-START] : | |
69 int - start postion of the gene | |
70 Arg [-END] : | |
71 int - end position of the gene | |
72 Arg [-STRAND] : | |
73 int - 1,-1 tehe strand the gene is on | |
74 Arg [-SLICE] : | |
75 Bio::EnsEMBL::Slice - the slice the gene is on | |
76 Arg [-STABLE_ID] : | |
77 string - the stable identifier of this gene | |
78 Arg [-VERSION] : | |
79 int - the version of the stable identifier of this gene | |
80 Arg [-EXTERNAL_NAME] : | |
81 string - the external database name associated with this gene | |
82 Arg [-EXTERNAL_DB] : | |
83 string - the name of the database the external name is from | |
84 Arg [-EXTERNAL_STATUS]: | |
85 string - the status of the external identifier | |
86 Arg [-DISPLAY_XREF]: | |
87 Bio::EnsEMBL::DBEntry - The external database entry that is used | |
88 to label this gene when it is displayed. | |
89 Arg [-TRANSCRIPTS]: | |
90 Listref of Bio::EnsEMBL::Transcripts - this gene's transcripts | |
91 Arg [-CREATED_DATE]: | |
92 string - the date the gene was created | |
93 Arg [-MODIFIED_DATE]: | |
94 string - the date the gene was last modified | |
95 Arg [-DESCRIPTION]: | |
96 string - the genes description | |
97 Arg [-BIOTYPE]: | |
98 string - the biotype e.g. "protein_coding" | |
99 Arg [-STATUS]: | |
100 string - the gene status i.e. "KNOWN","NOVEL" | |
101 Arg [-SOURCE]: | |
102 string - the genes source, e.g. "ensembl" | |
103 Arg [-IS_CURRENT]: | |
104 Boolean - specifies if this is the current version of the gene | |
105 Arg [-CANONICAL_TRANSCRIPT]: | |
106 Bio::EnsEMBL::Transcript - the canonical transcript of this gene | |
107 Arg [-CANONICAL_TRANSCRIPT_ID]: | |
108 integer - the canonical transcript dbID of this gene, if the | |
109 transcript object itself is not available. | |
110 Arg [-CANONICAL_ANNOTATION]: | |
111 string - canonical annotation | |
112 | |
113 Example : $gene = Bio::EnsEMBL::Gene->new(...); | |
114 Description: Creates a new gene object | |
115 Returntype : Bio::EnsEMBL::Gene | |
116 Exceptions : none | |
117 Caller : general | |
118 Status : Stable | |
119 | |
120 =cut | |
121 | |
122 sub new { | |
123 my $caller = shift; | |
124 | |
125 my $class = ref($caller) || $caller; | |
126 my $self = $class->SUPER::new(@_); | |
127 my ( | |
128 $stable_id, $version, | |
129 $external_name, $type, | |
130 $external_db, $external_status, | |
131 $display_xref, $description, | |
132 $transcripts, $created_date, | |
133 $modified_date, $confidence, | |
134 $biotype, $source, | |
135 $status, $is_current, | |
136 $canonical_transcript_id, $canonical_transcript, | |
137 $canonical_annotation | |
138 ) | |
139 = rearrange( [ | |
140 'STABLE_ID', 'VERSION', | |
141 'EXTERNAL_NAME', 'TYPE', | |
142 'EXTERNAL_DB', 'EXTERNAL_STATUS', | |
143 'DISPLAY_XREF', 'DESCRIPTION', | |
144 'TRANSCRIPTS', 'CREATED_DATE', | |
145 'MODIFIED_DATE', 'CONFIDENCE', | |
146 'BIOTYPE', 'SOURCE', | |
147 'STATUS', 'IS_CURRENT', | |
148 'CANONICAL_TRANSCRIPT_ID', 'CANONICAL_TRANSCRIPT', | |
149 'CANONICAL_ANNOTATION' | |
150 ], | |
151 @_ | |
152 ); | |
153 | |
154 | |
155 if ($transcripts) { | |
156 $self->{'_transcript_array'} = $transcripts; | |
157 $self->recalculate_coordinates(); | |
158 } | |
159 | |
160 $self->stable_id($stable_id); | |
161 $self->version($version); | |
162 $self->{'created_date'} = $created_date; | |
163 $self->{'modified_date'} = $modified_date; | |
164 | |
165 $self->external_name($external_name) if ( defined $external_name ); | |
166 $self->external_db($external_db) if ( defined $external_db ); | |
167 $self->external_status($external_status) | |
168 if ( defined $external_status ); | |
169 $self->display_xref($display_xref) if ( defined $display_xref ); | |
170 $self->biotype($type) if ( defined $type ); | |
171 $self->biotype($biotype) if ( defined $biotype ); | |
172 $self->description($description); | |
173 $self->status($confidence); # incase old naming is used. | |
174 # kept to ensure routine is backwards compatible. | |
175 $self->status($status); # add new naming | |
176 $self->source($source); | |
177 | |
178 # default to is_current | |
179 $is_current = 1 unless (defined($is_current)); | |
180 $self->{'is_current'} = $is_current; | |
181 | |
182 # Add the canonical transcript if we were given one, otherwise add the | |
183 # canonical transcript internal ID if we were given one. | |
184 if ( defined($canonical_transcript) ) { | |
185 $self->canonical_transcript($canonical_transcript); | |
186 } elsif ( defined($canonical_transcript_id) ) { | |
187 $self->{'canonical_transcript_id'} = $canonical_transcript_id; | |
188 } | |
189 | |
190 $self->canonical_annotation($canonical_annotation) | |
191 if ( defined $canonical_annotation ); | |
192 | |
193 return $self; | |
194 } | |
195 | |
196 | |
197 =head2 is_known | |
198 | |
199 Example : print "Gene ".$gene->stable_id." is KNOWN\n" if $gene->is_known; | |
200 Description: Returns TRUE if this gene has a status of 'KNOWN' | |
201 Returntype : TRUE if known, FALSE otherwise | |
202 Exceptions : none | |
203 Caller : general | |
204 Status : Stable | |
205 | |
206 =cut | |
207 | |
208 | |
209 sub is_known{ | |
210 my $self = shift; | |
211 return ( $self->{'status'} eq "KNOWN" || $self->{'status'} eq "KNOWN_BY_PROJECTION" ); | |
212 } | |
213 | |
214 | |
215 =head2 external_name | |
216 | |
217 Arg [1] : (optional) String - the external name to set | |
218 Example : $gene->external_name('BRCA2'); | |
219 Description: Getter/setter for attribute external_name. | |
220 Returntype : String or undef | |
221 Exceptions : none | |
222 Caller : general | |
223 Status : Stable | |
224 | |
225 =cut | |
226 | |
227 sub external_name { | |
228 my $self = shift; | |
229 | |
230 $self->{'external_name'} = shift if (@_); | |
231 | |
232 if (defined $self->{'external_name'}) { | |
233 return $self->{'external_name'}; | |
234 } | |
235 | |
236 my $display_xref = $self->display_xref(); | |
237 | |
238 if (defined $display_xref) { | |
239 return $display_xref->display_id(); | |
240 } else { | |
241 return undef; | |
242 } | |
243 } | |
244 | |
245 | |
246 =head2 status | |
247 | |
248 Arg [1] : (optional) String - status to set | |
249 Example : $gene->status('KNOWN'); | |
250 Description: Getter/setter for attribute status | |
251 Returntype : String | |
252 Exceptions : none | |
253 Caller : general | |
254 Status : Medium Risk | |
255 | |
256 =cut | |
257 | |
258 sub status { | |
259 my $self = shift; | |
260 $self->{'status'} = shift if( @_ ); | |
261 return $self->{'status'}; | |
262 } | |
263 | |
264 | |
265 =head2 source | |
266 | |
267 Arg [1] : (optional) String - the source to set | |
268 Example : $gene->source('ensembl'); | |
269 Description: Getter/setter for attribute source | |
270 Returntype : String | |
271 Exceptions : none | |
272 Caller : general | |
273 Status : Stable | |
274 | |
275 =cut | |
276 | |
277 sub source { | |
278 my $self = shift; | |
279 $self->{'source'} = shift if( @_ ); | |
280 return ( $self->{'source'} || "ensembl" ); | |
281 } | |
282 | |
283 | |
284 =head2 external_db | |
285 | |
286 Arg [1] : (optional) String - name of external db to set | |
287 Example : $gene->external_db('HGNC'); | |
288 Description: Getter/setter for attribute external_db. The db is the one that | |
289 belongs to the external_name. | |
290 Returntype : String | |
291 Exceptions : none | |
292 Caller : general | |
293 Status : Stable | |
294 | |
295 =cut | |
296 | |
297 sub external_db { | |
298 my $self = shift; | |
299 | |
300 $self->{'external_db'} = shift if( @_ ); | |
301 | |
302 if( exists $self->{'external_db'} ) { | |
303 return $self->{'external_db'}; | |
304 } | |
305 | |
306 my $display_xref = $self->display_xref(); | |
307 | |
308 if( defined $display_xref ) { | |
309 return $display_xref->dbname() | |
310 } else { | |
311 return undef; | |
312 } | |
313 } | |
314 | |
315 | |
316 =head2 external_status | |
317 | |
318 Arg [1] : (optional) String - status of the external db | |
319 Example : $gene->external_status('KNOWNXREF'); | |
320 Description: Getter/setter for attribute external_status. The status of | |
321 the external db of the one that belongs to the external_name. | |
322 Returntype : String | |
323 Exceptions : none | |
324 Caller : general | |
325 Status : Stable | |
326 | |
327 =cut | |
328 | |
329 sub external_status { | |
330 my $self = shift; | |
331 | |
332 $self->{'_ext_status'} = shift if ( @_ ); | |
333 return $self->{'_ext_status'} if exists $self->{'_ext_status'}; | |
334 | |
335 my $display_xref = $self->display_xref(); | |
336 | |
337 if( defined $display_xref ) { | |
338 return $display_xref->status() | |
339 } else { | |
340 return undef; | |
341 } | |
342 } | |
343 | |
344 | |
345 =head2 description | |
346 | |
347 Arg [1] : (optional) String - the description to set | |
348 Example : $gene->description('This is the gene\'s description'); | |
349 Description: Getter/setter for gene description | |
350 Returntype : String | |
351 Exceptions : none | |
352 Caller : general | |
353 Status : Stable | |
354 | |
355 =cut | |
356 | |
357 sub description { | |
358 my $self = shift; | |
359 $self->{'description'} = shift if( @_ ); | |
360 return $self->{'description'}; | |
361 } | |
362 | |
363 | |
364 =head2 equals | |
365 | |
366 Arg [1] : Bio::EnsEMBL::Gene gene | |
367 Example : if ($geneA->equals($geneB)) { ... } | |
368 Description : Compares two genes for equality. | |
369 The test for eqality goes through the following list | |
370 and terminates at the first true match: | |
371 | |
372 1. If Bio::EnsEMBL::Feature::equals() returns false, | |
373 then the genes are *not* equal. | |
374 2. If the biotypes differ, then the genes are *not* | |
375 equal. | |
376 3. If both genes have stable IDs: if these are the | |
377 same, the genes are equal, otherwise not. | |
378 4. If both genes have the same number of transcripts | |
379 and if these are (when compared pair-wise sorted by | |
380 start-position and length) the same, then they are | |
381 equal, otherwise not. | |
382 | |
383 Return type : Boolean (0, 1) | |
384 | |
385 Exceptions : Thrown if a non-gene is passed as the argument. | |
386 | |
387 =cut | |
388 | |
389 sub equals { | |
390 my ( $self, $gene ) = @_; | |
391 | |
392 if ( !defined($gene) ) { return 0 } | |
393 if ( $self eq $gene ) { return 1 } | |
394 | |
395 assert_ref( $gene, 'Bio::EnsEMBL::Gene' ); | |
396 | |
397 my $feature_equals = $self->SUPER::equals($gene); | |
398 if ( defined($feature_equals) && $feature_equals == 0 ) { | |
399 return 0; | |
400 } | |
401 | |
402 if ( $self->biotype() ne $gene->biotype() ) { | |
403 return 0; | |
404 } | |
405 | |
406 if ( defined( $self->stable_id() ) && defined( $gene->stable_id() ) ) | |
407 { | |
408 if ( $self->stable_id() eq $gene->stable_id() ) { return 1 } | |
409 else { return 0 } | |
410 } | |
411 | |
412 my @self_transcripts = sort { | |
413 $a->start() <=> $b->start() || | |
414 $a->length() <=> $b->length() | |
415 } @{ $self->get_all_Transcripts() }; | |
416 my @gene_transcripts = sort { | |
417 $a->start() <=> $b->start() || | |
418 $a->length() <=> $b->length() | |
419 } @{ $gene->get_all_Transcripts() }; | |
420 | |
421 if ( scalar(@self_transcripts) != scalar(@gene_transcripts) ) { | |
422 return 0; | |
423 } | |
424 | |
425 while (@self_transcripts) { | |
426 my $self_transcript = shift(@self_transcripts); | |
427 my $gene_transcript = shift(@gene_transcripts); | |
428 | |
429 if ( !$self_transcript->equals($gene_transcript) ) { | |
430 return 0; | |
431 } | |
432 } | |
433 | |
434 return 1; | |
435 } ## end sub equals | |
436 | |
437 =head2 canonical_transcript | |
438 | |
439 Arg [1] : (optional) Bio::EnsEMBL::Transcipt - canonical_transcript object | |
440 Example : $gene->canonical_transcript($canonical_transcript); | |
441 Description: Getter/setter for the canonical_transcript | |
442 Returntype : Bio::EnsEMBL::Transcript | |
443 Exceptions : Throws if argument is not a transcript object. | |
444 Caller : general | |
445 Status : Stable | |
446 | |
447 =cut | |
448 | |
449 sub canonical_transcript { | |
450 my ( $self, $transcript ) = @_; | |
451 | |
452 if ( defined($transcript) ) { | |
453 # We're attaching a new canonical transcript. | |
454 | |
455 assert_ref( $transcript, 'Bio::EnsEMBL::Transcript' ); | |
456 | |
457 # If there's already a canonical transcript, make sure it doesn't | |
458 # think it's still canonical. | |
459 if ( defined( $self->{'canonical_transcript'} ) ) { | |
460 $self->{'canonical_transcript'}->is_canonical(0); | |
461 } | |
462 | |
463 $self->{'canonical_transcript'} = $transcript; | |
464 $self->{'canonical_transcript_id'} = $transcript->dbID(); | |
465 | |
466 $transcript->is_canonical(1); | |
467 | |
468 } elsif ( !defined( $self->{'canonical_transcript'} ) | |
469 && defined( $self->{'canonical_transcript_id'} ) | |
470 && $self->{'canonical_transcript_id'} != 0 ) | |
471 { | |
472 # We have not attached a canoncical transcript, but we have the dbID | |
473 # of one. | |
474 | |
475 if ( defined( $self->adaptor() ) ) { | |
476 my $transcript_adaptor = | |
477 $self->adaptor()->db()->get_TranscriptAdaptor(); | |
478 | |
479 my $canonical_transcript = | |
480 $transcript_adaptor->fetch_by_dbID( | |
481 $self->{'canonical_transcript_id'} ); | |
482 | |
483 if ( defined($canonical_transcript) ) { | |
484 # Recusive call... | |
485 $self->canonical_transcript($canonical_transcript); | |
486 } | |
487 | |
488 } else { | |
489 warning( "Gene has no adaptor " | |
490 . "when trying to fetch canonical transcript." ); | |
491 } | |
492 | |
493 } ## end elsif ( !defined( $self->...)) | |
494 | |
495 return $self->{'canonical_transcript'}; | |
496 } ## end sub canonical_transcript | |
497 | |
498 | |
499 =head2 canonical_annotation | |
500 | |
501 Arg [1] : (optional) String - canonical_annotation | |
502 Example : $gene->canonical_annotation('This is the canonical_annotation'); | |
503 Description: Getter/setter for the canonical_annotation | |
504 Returntype : String | |
505 Exceptions : none | |
506 Caller : general | |
507 Status : Stable | |
508 | |
509 =cut | |
510 | |
511 sub canonical_annotation { | |
512 my $self = shift; | |
513 $self->{'canonical_annotation'} = shift if( @_ ); | |
514 return $self->{'canonical_annotation'}; | |
515 } | |
516 | |
517 =head2 get_all_Attributes | |
518 | |
519 Arg [1] : (optional) String $attrib_code | |
520 The code of the attribute type to retrieve values for | |
521 Example : my ($author) = @{ $gene->get_all_Attributes('author') }; | |
522 my @gene_attributes = @{ $gene->get_all_Attributes }; | |
523 Description: Gets a list of Attributes of this gene. | |
524 Optionally just get Attributes for given code. | |
525 Returntype : Listref of Bio::EnsEMBL::Attribute | |
526 Exceptions : warning if gene does not have attached adaptor and attempts lazy | |
527 load. | |
528 Caller : general | |
529 Status : Stable | |
530 | |
531 =cut | |
532 | |
533 sub get_all_Attributes { | |
534 my $self = shift; | |
535 my $attrib_code = shift; | |
536 | |
537 if ( ! exists $self->{'attributes' } ) { | |
538 if (!$self->adaptor() ) { | |
539 return []; | |
540 } | |
541 | |
542 my $attribute_adaptor = $self->adaptor->db->get_AttributeAdaptor(); | |
543 $self->{'attributes'} = $attribute_adaptor->fetch_all_by_Gene($self); | |
544 } | |
545 | |
546 if ( defined $attrib_code ) { | |
547 my @results = grep { uc($_->code()) eq uc($attrib_code) } | |
548 @{$self->{'attributes'}}; | |
549 return \@results; | |
550 } else { | |
551 return $self->{'attributes'}; | |
552 } | |
553 } | |
554 | |
555 | |
556 =head2 add_Attributes | |
557 | |
558 Arg [1-N] : list of Bio::EnsEMBL::Attribute's @attribs | |
559 Attribute(s) to add | |
560 Example : my $attrib = Bio::EnsEMBL::Attribute->new(...); | |
561 $gene->add_Attributes($attrib); | |
562 Description: Adds an Attribute to the Gene. If you add an attribute before | |
563 you retrieve any from database, lazy loading will be disabled. | |
564 Returntype : none | |
565 Exceptions : throw on incorrect arguments | |
566 Caller : general | |
567 Status : Stable | |
568 | |
569 =cut | |
570 | |
571 sub add_Attributes { | |
572 my $self = shift; | |
573 my @attribs = @_; | |
574 | |
575 if( ! exists $self->{'attributes'} ) { | |
576 $self->{'attributes'} = []; | |
577 } | |
578 | |
579 for my $attrib ( @attribs ) { | |
580 if( ! $attrib->isa( "Bio::EnsEMBL::Attribute" )) { | |
581 throw( "Argument to add_Attribute has to be an Bio::EnsEMBL::Attribute" ); | |
582 } | |
583 push( @{$self->{'attributes'}}, $attrib ); | |
584 } | |
585 | |
586 return; | |
587 } | |
588 | |
589 | |
590 =head2 add_DBEntry | |
591 | |
592 Arg [1] : Bio::EnsEMBL::DBEntry $dbe | |
593 The dbEntry to be added | |
594 Example : my $dbe = Bio::EnsEMBL::DBEntery->new(...); | |
595 $gene->add_DBEntry($dbe); | |
596 Description: Associates a DBEntry with this gene. Note that adding DBEntries | |
597 will prevent future lazy-loading of DBEntries for this gene | |
598 (see get_all_DBEntries). | |
599 Returntype : none | |
600 Exceptions : thrown on incorrect argument type | |
601 Caller : general | |
602 Status : Stable | |
603 | |
604 =cut | |
605 | |
606 sub add_DBEntry { | |
607 my $self = shift; | |
608 my $dbe = shift; | |
609 | |
610 unless($dbe && ref($dbe) && $dbe->isa('Bio::EnsEMBL::DBEntry')) { | |
611 throw('Expected DBEntry argument'); | |
612 } | |
613 | |
614 $self->{'dbentries'} ||= []; | |
615 push @{$self->{'dbentries'}}, $dbe; | |
616 } | |
617 | |
618 | |
619 =head2 get_all_DBEntries | |
620 | |
621 Arg [1] : (optional) String, external database name | |
622 | |
623 Arg [2] : (optional) String, external_db type | |
624 | |
625 Example : @dbentries = @{ $gene->get_all_DBEntries() }; | |
626 | |
627 Description: Retrieves DBEntries (xrefs) for this gene. This does | |
628 *not* include DBEntries that are associated with the | |
629 transcripts and corresponding translations of this | |
630 gene (see get_all_DBLinks()). | |
631 | |
632 This method will attempt to lazy-load DBEntries | |
633 from a database if an adaptor is available and no | |
634 DBEntries are present on the gene (i.e. they have not | |
635 already been added or loaded). | |
636 | |
637 Return type: Listref of Bio::EnsEMBL::DBEntry objects | |
638 Exceptions : none | |
639 Caller : get_all_DBLinks, GeneAdaptor::store | |
640 Status : Stable | |
641 | |
642 =cut | |
643 | |
644 sub get_all_DBEntries { | |
645 my ( $self, $db_name_exp, $ex_db_type ) = @_; | |
646 | |
647 my $cache_name = 'dbentries'; | |
648 | |
649 if ( defined($db_name_exp) ) { | |
650 $cache_name .= $db_name_exp; | |
651 } | |
652 | |
653 if ( defined($ex_db_type) ) { | |
654 $cache_name .= $ex_db_type; | |
655 } | |
656 | |
657 # if not cached, retrieve all of the xrefs for this gene | |
658 if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) ) | |
659 { | |
660 $self->{$cache_name} = | |
661 $self->adaptor()->db()->get_DBEntryAdaptor() | |
662 ->fetch_all_by_Gene( $self, $db_name_exp, $ex_db_type ); | |
663 } | |
664 | |
665 $self->{$cache_name} ||= []; | |
666 | |
667 return $self->{$cache_name}; | |
668 } ## end sub get_all_DBEntries | |
669 | |
670 =head2 get_all_object_xrefs | |
671 | |
672 Arg [1] : (optional) String, external database name | |
673 | |
674 Arg [2] : (optional) String, external_db type | |
675 | |
676 Example : @oxrefs = @{ $gene->get_all_object_xrefs() }; | |
677 | |
678 Description: Retrieves xrefs for this gene. This does *not* | |
679 include xrefs that are associated with the | |
680 transcripts or corresponding translations of this | |
681 gene (see get_all_xrefs()). | |
682 | |
683 This method will attempt to lazy-load xrefs from a | |
684 database if an adaptor is available and no xrefs are | |
685 present on the gene (i.e. they have not already been | |
686 added or loaded). | |
687 | |
688 NB: This method is an alias for the | |
689 get_all_DBentries() method. | |
690 | |
691 Return type: Listref of Bio::EnsEMBL::DBEntry objects | |
692 | |
693 Status : Stable | |
694 | |
695 =cut | |
696 | |
697 sub get_all_object_xrefs { | |
698 my $self = shift; | |
699 return $self->get_all_DBEntries(@_); | |
700 } | |
701 | |
702 =head2 get_all_DBLinks | |
703 | |
704 Arg [1] : String database name (optional) | |
705 SQL wildcard characters (_ and %) can be used to | |
706 specify patterns. | |
707 | |
708 Example : @dblinks = @{ $gene->get_all_DBLinks() }; | |
709 @dblinks = @{ $gene->get_all_DBLinks('Uniprot%') }; | |
710 | |
711 Description: Retrieves *all* related DBEntries for this gene. This | |
712 includes all DBEntries that are associated with the | |
713 transcripts and corresponding translations of this | |
714 gene. | |
715 | |
716 If you only want to retrieve the DBEntries | |
717 associated with the gene (and not the transcript | |
718 and translations) then you should use the | |
719 get_all_DBEntries() call instead. | |
720 | |
721 Note: Each entry may be listed more than once. No | |
722 uniqueness checks are done. Also if you put in an | |
723 incorrect external database name no checks are done | |
724 to see if this exists, you will just get an empty | |
725 list. | |
726 | |
727 Return type: Listref of Bio::EnsEMBL::DBEntry objects | |
728 Exceptions : none | |
729 Caller : general | |
730 Status : Stable | |
731 | |
732 =cut | |
733 | |
734 sub get_all_DBLinks { | |
735 my ( $self, $db_name_exp, $ex_db_type ) = @_; | |
736 | |
737 my @links = | |
738 @{ $self->get_all_DBEntries( $db_name_exp, $ex_db_type ) }; | |
739 | |
740 # Add all of the transcript and translation xrefs to the return list. | |
741 foreach my $transcript ( @{ $self->get_all_Transcripts() } ) { | |
742 push( @links, | |
743 @{$transcript->get_all_DBLinks( $db_name_exp, $ex_db_type ) } | |
744 ); | |
745 } | |
746 | |
747 return \@links; | |
748 } | |
749 | |
750 =head2 get_all_xrefs | |
751 | |
752 Arg [1] : String database name (optional) | |
753 SQL wildcard characters (_ and %) can be used to | |
754 specify patterns. | |
755 | |
756 Example : @xrefs = @{ $gene->get_all_xrefs() }; | |
757 @xrefs = @{ $gene->get_all_xrefs('Uniprot%') }; | |
758 | |
759 Description: Retrieves *all* related xrefs for this gene. This | |
760 includes all xrefs that are associated with the | |
761 transcripts and corresponding translations of this | |
762 gene. | |
763 | |
764 If you want to retrieve the xrefs associated | |
765 with only the gene (and not the transcript | |
766 or translations) then you should use the | |
767 get_all_object_xrefs() method instead. | |
768 | |
769 Note: Each entry may be listed more than once. No | |
770 uniqueness checks are done. Also if you put in an | |
771 incorrect external database name no checks are done | |
772 to see if this exists, you will just get an empty | |
773 list. | |
774 | |
775 NB: This method is an alias for the | |
776 get_all_DBLinks() method. | |
777 | |
778 Return type: Listref of Bio::EnsEMBL::DBEntry objects | |
779 | |
780 Status : Stable | |
781 | |
782 =cut | |
783 | |
784 sub get_all_xrefs { | |
785 my $self = shift; | |
786 return $self->get_all_DBLinks(@_); | |
787 } | |
788 | |
789 =head2 get_all_Exons | |
790 | |
791 Example : my @exons = @{ $gene->get_all_Exons }; | |
792 Description: Returns a set of all the exons associated with this gene. | |
793 Returntype : Listref of Bio::EnsEMBL::Exon objects | |
794 Exceptions : none | |
795 Caller : general | |
796 Status : Stable | |
797 | |
798 =cut | |
799 | |
800 | |
801 sub get_all_Exons { | |
802 my $self = shift; | |
803 | |
804 my %h; | |
805 my @out = (); | |
806 | |
807 foreach my $trans ( @{$self->get_all_Transcripts} ) { | |
808 foreach my $e ( @{$trans->get_all_Exons} ) { | |
809 $h{$e->start()."-".$e->end()."-".$e->strand()."-".$e->phase()."-".$e->end_phase()} = $e; | |
810 } | |
811 } | |
812 | |
813 push @out, values %h; | |
814 | |
815 return \@out; | |
816 } | |
817 | |
818 | |
819 =head2 get_all_homologous_Genes | |
820 | |
821 Description: Queries the Ensembl Compara database and retrieves all | |
822 Genes from other species that are orthologous. | |
823 REQUIRES properly setup Registry conf file. Meaning that | |
824 one of the aliases for each core db has to be "Genus species" | |
825 e.g. "Homo sapiens" (as in the name column in genome_db table | |
826 in the compara database). | |
827 Returntype : listref [ | |
828 Bio::EnsEMBL::Gene, | |
829 Bio::EnsEMBL::Compara::Homology, | |
830 string $species # needed as cannot get spp from Gene | |
831 ] | |
832 Exceptions : none | |
833 Caller : general | |
834 Status : Stable | |
835 | |
836 =cut | |
837 | |
838 sub get_all_homologous_Genes { | |
839 my $self = shift; | |
840 | |
841 if( exists( $self->{'homologues'} ) ){ | |
842 return $self->{'homologues'}; | |
843 } | |
844 $self->{'homologues'} = []; | |
845 | |
846 # TODO: Find a robust way of retrieving compara dba directly. | |
847 # For now look through all DBAs | |
848 my $compara_dba; | |
849 foreach my $dba( @{Bio::EnsEMBL::Registry->get_all_DBAdaptors} ){ | |
850 if( $dba->isa('Bio::EnsEMBL::Compara::DBSQL::DBAdaptor') ){ | |
851 $compara_dba = $dba; | |
852 last; | |
853 } | |
854 } | |
855 unless( $compara_dba ){ | |
856 warning("No compara in Bio::EnsEMBL::Registry"); | |
857 return $self->{'homologues'}; | |
858 } | |
859 | |
860 # Get the compara 'member' corresponding to self | |
861 my $member_adaptor = $compara_dba->get_adaptor('Member'); | |
862 my $query_member = $member_adaptor->fetch_by_source_stable_id | |
863 ("ENSEMBLGENE",$self->stable_id); | |
864 unless( $query_member ){ return $self->{'homologues'} }; | |
865 | |
866 # Get the compara 'homologies' corresponding to 'member' | |
867 my $homology_adaptor = $compara_dba->get_adaptor('Homology'); | |
868 my @homolos = @{$homology_adaptor->fetch_all_by_Member($query_member)}; | |
869 unless( scalar(@homolos) ){ return $self->{'homologues'} }; | |
870 | |
871 # Get the ensembl 'genes' corresponding to 'homologies' | |
872 foreach my $homolo( @homolos ){ | |
873 foreach my $member_attrib( @{$homolo->get_all_Member_Attribute} ){ | |
874 my ($member, $attrib) = @{$member_attrib}; | |
875 my $hstable_id = $member->stable_id; | |
876 next if ($hstable_id eq $query_member->stable_id); # Ignore self | |
877 my $hgene = undef; | |
878 eval { $hgene = $member->get_Gene;} ; | |
879 unless( $hgene ){ | |
880 # Something up with DB. Create a new gene is best we can do | |
881 $hgene = Bio::EnsEMBL::Gene->new | |
882 ( -stable_id=>$hstable_id, | |
883 -description=>$member->description, ); | |
884 } | |
885 my $hspecies = $member->genome_db->name; | |
886 push @{$self->{'homologues'}}, [$hgene,$homolo,$hspecies]; | |
887 } | |
888 } | |
889 return $self->{'homologues'}; | |
890 } | |
891 | |
892 | |
893 =head2 biotype | |
894 | |
895 Arg [1] : (optional) String - the biotype to set | |
896 Example : $gene->biotype("protein_coding"); | |
897 Description: Getter/setter for the attribute biotype | |
898 Returntype : String | |
899 Exceptions : none | |
900 Caller : general | |
901 Status : Stable | |
902 | |
903 =cut | |
904 | |
905 sub biotype { | |
906 my $self = shift; | |
907 | |
908 $self->{'biotype'} = shift if( @_ ); | |
909 return ( $self->{'biotype'} || "protein_coding" ); | |
910 } | |
911 | |
912 | |
913 =head2 add_Transcript | |
914 | |
915 Arg [1] : Bio::EnsEMBL::Transcript $trans | |
916 The transcript to add to the gene | |
917 Example : my $transcript = Bio::EnsEMBL::Transcript->new(...); | |
918 $gene->add_Transcript($transcript); | |
919 Description: Adds another Transcript to the set of alternatively | |
920 spliced Transcripts of this gene. If it shares exons | |
921 with another Transcript, these should be object-identical. | |
922 Returntype : none | |
923 Exceptions : none | |
924 Caller : general | |
925 Status : Stable | |
926 | |
927 =cut | |
928 | |
929 sub add_Transcript { | |
930 my ($self, $trans) = @_; | |
931 | |
932 if( !ref $trans || ! $trans->isa("Bio::EnsEMBL::Transcript") ) { | |
933 throw("$trans is not a Bio::EnsEMBL::Transcript!"); | |
934 } | |
935 | |
936 $self->{'_transcript_array'} ||= []; | |
937 push(@{$self->{'_transcript_array'}},$trans); | |
938 | |
939 $self->recalculate_coordinates(); | |
940 } | |
941 | |
942 | |
943 =head2 get_all_Transcripts | |
944 | |
945 Example : my @transcripts = @{ $gene->get_all_Transcripts }; | |
946 Description: Returns the Transcripts in this gene. | |
947 Returntype : Listref of Bio::EnsEMBL::Transcript objects | |
948 Exceptions : none | |
949 Caller : general | |
950 Status : Stable | |
951 | |
952 =cut | |
953 | |
954 sub get_all_Transcripts { | |
955 my $self = shift; | |
956 | |
957 if( ! exists $self->{'_transcript_array'} ) { | |
958 if( defined $self->adaptor() ) { | |
959 my $ta = $self->adaptor()->db()->get_TranscriptAdaptor(); | |
960 my $transcripts = $ta->fetch_all_by_Gene( $self ); | |
961 $self->{'_transcript_array'} = $transcripts; | |
962 } | |
963 } | |
964 return $self->{'_transcript_array'}; | |
965 } | |
966 | |
967 | |
968 =head2 get_all_alt_alleles | |
969 | |
970 Example : my @alt_genes = @{ $gene->get_all_alt_alleles }; | |
971 foreach my $alt_gene (@alt_genes) { | |
972 print "Alternate allele: " . $alt_gene->stable_id() . "\n"; | |
973 } | |
974 Description: Returns a listref of Gene objects that represent this Gene on | |
975 an alternative haplotype. Empty list if there is no such | |
976 Gene (eg there is no overlapping haplotype). | |
977 Returntype : listref of Bio::EnsEMBL::Gene objects | |
978 Exceptions : none | |
979 Caller : general | |
980 Status : Stable | |
981 | |
982 =cut | |
983 | |
984 sub get_all_alt_alleles { | |
985 my $self = shift; | |
986 my $result = $self->adaptor()->fetch_all_alt_alleles( $self ); | |
987 return $result; | |
988 } | |
989 | |
990 | |
991 =head2 version | |
992 | |
993 Arg [1] : (optional) Int | |
994 A version number for the stable_id | |
995 Example : $gene->version(2); | |
996 Description: Getter/setter for version number | |
997 Returntype : Int | |
998 Exceptions : none | |
999 Caller : general | |
1000 Status : Stable | |
1001 | |
1002 =cut | |
1003 | |
1004 sub version { | |
1005 my $self = shift; | |
1006 $self->{'version'} = shift if(@_); | |
1007 return $self->{'version'}; | |
1008 } | |
1009 | |
1010 | |
1011 =head2 stable_id | |
1012 | |
1013 Arg [1] : (optional) String - the stable ID to set | |
1014 Example : $gene->stable_id("ENSG0000000001"); | |
1015 Description: Getter/setter for stable id for this gene. | |
1016 Returntype : String | |
1017 Exceptions : none | |
1018 Caller : general | |
1019 Status : Stable | |
1020 | |
1021 =cut | |
1022 | |
1023 sub stable_id { | |
1024 my $self = shift; | |
1025 $self->{'stable_id'} = shift if(@_); | |
1026 return $self->{'stable_id'}; | |
1027 } | |
1028 | |
1029 | |
1030 =head2 is_current | |
1031 | |
1032 Arg [1] : Boolean $is_current | |
1033 Example : $gene->is_current(1) | |
1034 Description: Getter/setter for is_current state of this gene. | |
1035 Returntype : Int | |
1036 Exceptions : none | |
1037 Caller : general | |
1038 Status : Stable | |
1039 | |
1040 =cut | |
1041 | |
1042 sub is_current { | |
1043 my $self = shift; | |
1044 $self->{'is_current'} = shift if (@_); | |
1045 return $self->{'is_current'}; | |
1046 } | |
1047 | |
1048 | |
1049 =head2 created_date | |
1050 | |
1051 Arg [1] : (optional) String - created date to set (as a UNIX time int) | |
1052 Example : $gene->created_date('1141948800'); | |
1053 Description: Getter/setter for attribute created_date | |
1054 Returntype : String | |
1055 Exceptions : none | |
1056 Caller : general | |
1057 Status : Stable | |
1058 | |
1059 =cut | |
1060 | |
1061 sub created_date { | |
1062 my $self = shift; | |
1063 $self->{'created_date'} = shift if ( @_ ); | |
1064 return $self->{'created_date'}; | |
1065 } | |
1066 | |
1067 | |
1068 =head2 modified_date | |
1069 | |
1070 Arg [1] : (optional) String - modified date to set (as a UNIX time int) | |
1071 Example : $gene->modified_date('1141948800'); | |
1072 Description: Getter/setter for attribute modified_date | |
1073 Returntype : String | |
1074 Exceptions : none | |
1075 Caller : general | |
1076 Status : Stable | |
1077 | |
1078 =cut | |
1079 | |
1080 sub modified_date { | |
1081 my $self = shift; | |
1082 $self->{'modified_date'} = shift if ( @_ ); | |
1083 return $self->{'modified_date'}; | |
1084 } | |
1085 | |
1086 | |
1087 =head2 transform | |
1088 | |
1089 Arg [1] : String - coordinate system name to transform to | |
1090 Arg [2] : String - coordinate system version | |
1091 Example : my $new_gene = $gene->transform('supercontig'); | |
1092 Description: Moves this gene to the given coordinate system. If this gene has | |
1093 Transcripts attached, they move as well. | |
1094 Returntype : Bio::EnsEMBL::Gene | |
1095 Exceptions : throw on wrong parameters | |
1096 Caller : general | |
1097 Status : Stable | |
1098 | |
1099 =cut | |
1100 | |
1101 sub transform { | |
1102 my $self = shift; | |
1103 | |
1104 # catch for old style transform calls | |
1105 if( !@_ || ( ref $_[0] && ($_[0]->isa( "Bio::EnsEMBL::Slice" ) or $_[0]->isa( "Bio::EnsEMBL::LRGSlice" )) )) { | |
1106 deprecate('Calling transform without a coord system name is deprecated.'); | |
1107 return $self->_deprecated_transform(@_); | |
1108 } | |
1109 | |
1110 my $new_gene = $self->SUPER::transform(@_); | |
1111 | |
1112 if ( !defined($new_gene) ) { | |
1113 # check if this gene projects at all to requested coord system, | |
1114 # if not we are done. | |
1115 my @segments = @{ $self->project(@_) }; | |
1116 if ( !@segments ) { | |
1117 return undef; | |
1118 } | |
1119 } | |
1120 | |
1121 # | |
1122 # If you are transforming the gene then make sure the transcripts and exons are loaded | |
1123 # | |
1124 | |
1125 foreach my $tran (@{$self->get_all_Transcripts}){ | |
1126 $tran->get_all_Exons(); | |
1127 } | |
1128 | |
1129 if( exists $self->{'_transcript_array'} ) { | |
1130 my @new_transcripts; | |
1131 my ( $strand, $slice ); | |
1132 my $low_start = POSIX::INT_MAX; | |
1133 my $hi_end = POSIX::INT_MIN; | |
1134 for my $old_transcript ( @{$self->{'_transcript_array'}} ) { | |
1135 my $new_transcript = $old_transcript->transform( @_ ); | |
1136 # this can fail if gene transform failed | |
1137 | |
1138 return undef unless $new_transcript; | |
1139 | |
1140 if( ! defined $new_gene ) { | |
1141 if( $new_transcript->start() < $low_start ) { | |
1142 $low_start = $new_transcript->start(); | |
1143 } | |
1144 if( $new_transcript->end() > $hi_end ) { | |
1145 $hi_end = $new_transcript->end(); | |
1146 } | |
1147 $slice = $new_transcript->slice(); | |
1148 $strand = $new_transcript->strand(); | |
1149 } | |
1150 push( @new_transcripts, $new_transcript ); | |
1151 } | |
1152 | |
1153 if( ! defined $new_gene ) { | |
1154 %$new_gene = %$self; | |
1155 bless $new_gene, ref( $self ); | |
1156 | |
1157 $new_gene->start( $low_start ); | |
1158 $new_gene->end( $hi_end ); | |
1159 $new_gene->strand( $strand ); | |
1160 $new_gene->slice( $slice ); | |
1161 } | |
1162 | |
1163 $new_gene->{'_transcript_array'} = \@new_transcripts; | |
1164 } | |
1165 return $new_gene; | |
1166 } | |
1167 | |
1168 | |
1169 =head2 transfer | |
1170 | |
1171 Arg [1] : Bio::EnsEMBL::Slice $destination_slice | |
1172 Example : my $new_gene = $gene->transfer($slice); | |
1173 Description: Moves this Gene to given target slice coordinates. If Transcripts | |
1174 are attached they are moved as well. Returns a new gene. | |
1175 Returntype : Bio::EnsEMBL::Gene | |
1176 Exceptions : none | |
1177 Caller : general | |
1178 Status : Stable | |
1179 | |
1180 =cut | |
1181 | |
1182 sub transfer { | |
1183 my $self = shift; | |
1184 | |
1185 my $new_gene = $self->SUPER::transfer( @_ ); | |
1186 return undef unless $new_gene; | |
1187 | |
1188 if( exists $self->{'_transcript_array'} ) { | |
1189 my @new_transcripts; | |
1190 for my $old_transcript ( @{$self->{'_transcript_array'}} ) { | |
1191 my $new_transcript = $old_transcript->transfer( @_ ); | |
1192 push( @new_transcripts, $new_transcript ); | |
1193 } | |
1194 $new_gene->{'_transcript_array'} = \@new_transcripts; | |
1195 } | |
1196 return $new_gene; | |
1197 } | |
1198 | |
1199 | |
1200 =head2 display_xref | |
1201 | |
1202 Arg [1] : (optional) Bio::EnsEMBL::DBEntry - the display xref to set | |
1203 Example : $gene->display_xref($db_entry); | |
1204 Description: Getter/setter display_xref for this gene. | |
1205 Returntype : Bio::EnsEMBL::DBEntry | |
1206 Exceptions : none | |
1207 Caller : general | |
1208 Status : Stable | |
1209 | |
1210 =cut | |
1211 | |
1212 sub display_xref { | |
1213 my $self = shift; | |
1214 $self->{'display_xref'} = shift if(@_); | |
1215 return $self->{'display_xref'}; | |
1216 } | |
1217 | |
1218 | |
1219 =head2 display_id | |
1220 | |
1221 Example : print $gene->display_id(); | |
1222 Description: This method returns a string that is considered to be | |
1223 the 'display' identifier. For genes this is (depending on | |
1224 availability and in this order) the stable Id, the dbID or an | |
1225 empty string. | |
1226 Returntype : String | |
1227 Exceptions : none | |
1228 Caller : web drawing code | |
1229 Status : Stable | |
1230 | |
1231 =cut | |
1232 | |
1233 sub display_id { | |
1234 my $self = shift; | |
1235 return $self->{'stable_id'} || $self->dbID || ''; | |
1236 } | |
1237 | |
1238 | |
1239 =head2 recalculate_coordinates | |
1240 | |
1241 Example : $gene->recalculate_coordinates; | |
1242 Description: Called when transcript added to the gene, tries to adapt the | |
1243 coords for the gene. | |
1244 Returntype : none | |
1245 Exceptions : none | |
1246 Caller : internal | |
1247 Status : Stable | |
1248 | |
1249 =cut | |
1250 | |
1251 sub recalculate_coordinates { | |
1252 my $self = shift; | |
1253 | |
1254 my $transcripts = $self->get_all_Transcripts(); | |
1255 | |
1256 return if(!$transcripts || !@$transcripts); | |
1257 | |
1258 my ( $slice, $start, $end, $strand ); | |
1259 $slice = $transcripts->[0]->slice(); | |
1260 $strand = $transcripts->[0]->strand(); | |
1261 $start = $transcripts->[0]->start(); | |
1262 $end = $transcripts->[0]->end(); | |
1263 | |
1264 my $transsplicing = 0; | |
1265 | |
1266 for my $t ( @$transcripts ) { | |
1267 if( $t->start() < $start ) { | |
1268 $start = $t->start(); | |
1269 } | |
1270 | |
1271 if( $t->end() > $end ) { | |
1272 $end = $t->end(); | |
1273 } | |
1274 | |
1275 if( $t->slice()->name() ne $slice->name() ) { | |
1276 throw( "Transcripts with different slices not allowed on one Gene" ); | |
1277 } | |
1278 | |
1279 if( $t->strand() != $strand ) { | |
1280 $transsplicing = 1; | |
1281 } | |
1282 } | |
1283 if( $transsplicing ) { | |
1284 warning( "Gene contained trans splicing event" ); | |
1285 } | |
1286 | |
1287 $self->start( $start ); | |
1288 $self->end( $end ); | |
1289 $self->strand( $strand ); | |
1290 $self->slice( $slice ); | |
1291 } | |
1292 | |
1293 | |
1294 =head2 get_all_DASFactories | |
1295 | |
1296 Example : $dasref = $prot->get_all_DASFactories | |
1297 Description: Retrieves a listref of registered DAS objects | |
1298 TODO: Abstract to a DBLinkContainer obj | |
1299 Returntype : [ DAS_objects ] | |
1300 Exceptions : none | |
1301 Caller : general | |
1302 Status : Stable | |
1303 | |
1304 =cut | |
1305 | |
1306 sub get_all_DASFactories { | |
1307 my $self = shift; | |
1308 return [ $self->adaptor()->db()->_each_DASFeatureFactory ]; | |
1309 } | |
1310 | |
1311 | |
1312 =head2 get_all_DAS_Features | |
1313 | |
1314 Example : $features = $prot->get_all_DAS_Features; | |
1315 Description: Retreives a hash reference to a hash of DAS feature | |
1316 sets, keyed by the DNS, NOTE the values of this hash | |
1317 are an anonymous array containing: | |
1318 (1) a pointer to an array of features | |
1319 (2) a pointer to the DAS stylesheet | |
1320 Returntype : hashref of Bio::SeqFeatures | |
1321 Exceptions : none | |
1322 Caller : webcode | |
1323 Status : Stable | |
1324 | |
1325 =cut | |
1326 | |
1327 sub get_all_DAS_Features{ | |
1328 my ($self, @args) = @_; | |
1329 my $slice = $self->feature_Slice; | |
1330 return $self->SUPER::get_all_DAS_Features($slice); | |
1331 } | |
1332 | |
1333 | |
1334 | |
1335 | |
1336 =head2 add_unconventional_transcript_association | |
1337 | |
1338 Arg [1] : Bio::EnsEMBL::Transcript $trans | |
1339 The transcript to associate with the gene, in an unconventional manner. | |
1340 Arg [2] : String $type | |
1341 The type of association between this gene and this transcript, e.g. | |
1342 "antisense","sense_intronic","sense_overlaping_exonic","chimeric_sense_exonic" | |
1343 Example : my $transcript = Bio::EnsEMBL::Transcript->new(...); | |
1344 $gene->add_unconventional_transcript_association($transcript, "antisense"); | |
1345 Description: Associate a transcript with this gene in a way that is | |
1346 non-conventional. | |
1347 Returntype : none | |
1348 Exceptions : none | |
1349 Caller : general | |
1350 Status : At Risk. | |
1351 | |
1352 =cut | |
1353 | |
1354 sub add_unconventional_transcript_association { | |
1355 | |
1356 my ($self, $transcript, $type) = @_; | |
1357 | |
1358 if( !ref $transcript || ! $transcript->isa("Bio::EnsEMBL::Transcript") ) { | |
1359 throw("$transcript is not a Bio::EnsEMBL::Transcript!"); | |
1360 } | |
1361 | |
1362 my $uta = Bio::EnsEMBL::UnconventionalTranscriptAssociation->new($transcript, $self, $type); | |
1363 $self->{'_unconventional_transcript_array'} ||= []; | |
1364 push(@{$self->{'_unconventional_transcript_array'}}, $uta); | |
1365 | |
1366 } | |
1367 | |
1368 | |
1369 =head2 get_all_unconventional_transcript_associations | |
1370 | |
1371 Arg [1] : (optional) String - Only get transcripts where the association | |
1372 between this gene and the transcripts is of a certain type. | |
1373 Example : my @transcripts = @{ $gene->get_all_unconventional_transcript_associations, "antisense" }; | |
1374 Description: Returns the unconventional transcripts associated with this gene. | |
1375 Returntype : Listref of Bio::EnsEMBL::UnconventionalTranscriptAssociation objects | |
1376 Exceptions : none | |
1377 Caller : general | |
1378 Status : At risk. | |
1379 | |
1380 =cut | |
1381 | |
1382 sub get_all_unconventional_transcript_associations { | |
1383 | |
1384 my ($self, $type) = @_; | |
1385 | |
1386 if( ! exists $self->{'_unconventional_transcript_array'} ) { | |
1387 $self->{'_unconventional_transcript_array'} = []; | |
1388 if( defined $self->adaptor() ) { | |
1389 my $utaa = $self->adaptor()->db()->get_UnconventionalTranscriptAssociationAdaptor(); | |
1390 my $utas = $utaa->fetch_all_by_gene( $self, $type ); | |
1391 $self->{'_unconventional_transcript_array'} = $utas; | |
1392 } | |
1393 } | |
1394 | |
1395 return $self->{'_unconventional_transcript_array'}; | |
1396 } | |
1397 | |
1398 =head2 remove_unconventional_transcript_associations | |
1399 | |
1400 Args : None | |
1401 Example : $gene->remove_unconventional_transcript_associations(); | |
1402 Description: Returns the unconventional transcripts associated with this gene. | |
1403 Returntype : Listref of Bio::EnsEMBL::UnconventionalTranscriptAssociation objects | |
1404 Exceptions : none | |
1405 Caller : general | |
1406 Status : At risk. | |
1407 | |
1408 =cut | |
1409 | |
1410 sub remove_unconventional_transcript_associations { | |
1411 | |
1412 my $self = shift; | |
1413 | |
1414 $self->{'_unconventional_transcript_array'} = []; | |
1415 | |
1416 } | |
1417 | |
1418 =head2 load | |
1419 | |
1420 Arg [1] : Boolean $load_xrefs | |
1421 Load (or don't load) xrefs. Default is to load xrefs. | |
1422 Example : $gene->load(); | |
1423 Description : The Ensembl API makes extensive use of | |
1424 lazy-loading. Under some circumstances (e.g., | |
1425 when copying genes between databases), all data of | |
1426 an object needs to be fully loaded. This method | |
1427 loads the parts of the object that are usually | |
1428 lazy-loaded. It will also call the equivalent | |
1429 method on all the transcripts of the gene. | |
1430 Returns : | |
1431 | |
1432 =cut | |
1433 | |
1434 sub load { | |
1435 my ( $self, $load_xrefs ) = @_; | |
1436 | |
1437 if ( !defined($load_xrefs) ) { $load_xrefs = 1 } | |
1438 | |
1439 foreach my $transcript ( @{ $self->get_all_Transcripts() } ) { | |
1440 $transcript->load($load_xrefs); | |
1441 } | |
1442 | |
1443 $self->analysis(); | |
1444 $self->get_all_Attributes(); | |
1445 $self->stable_id(); | |
1446 $self->canonical_transcript(); | |
1447 | |
1448 if ($load_xrefs) { | |
1449 $self->get_all_DBEntries(); | |
1450 } | |
1451 } | |
1452 | |
1453 =head2 is_ref | |
1454 | |
1455 Description: getter setter for the gene attribute is_ref | |
1456 Arg [1] : (optional) 1 or 0 | |
1457 return : boolean | |
1458 | |
1459 =cut | |
1460 | |
1461 sub is_reference{ | |
1462 my ( $self, $is_ref) = @_; | |
1463 | |
1464 if(defined($is_ref)){ | |
1465 $self->{'is_ref'} = $is_ref; | |
1466 } | |
1467 else{ | |
1468 $self->{'is_ref'} = $self->adaptor->is_ref($self->dbID); | |
1469 } | |
1470 return $self->{'is_ref'}; | |
1471 } | |
1472 | |
1473 =head2 summary_as_hash | |
1474 | |
1475 Example : $gene_summary = $gene->summary_as_hash(); | |
1476 Description : Extends Feature::summary_as_hash | |
1477 Retrieves a summary of this Gene object. | |
1478 | |
1479 Returns : hashref of arrays of descriptive strings | |
1480 Status : Intended for internal use | |
1481 =cut | |
1482 | |
1483 sub summary_as_hash { | |
1484 my $self = shift; | |
1485 my $summary_ref = $self->SUPER::summary_as_hash; | |
1486 $summary_ref->{'description'} = $self->description; | |
1487 $summary_ref->{'biotype'} = $self->biotype; | |
1488 $summary_ref->{'external_name'} = $self->external_name; | |
1489 return $summary_ref; | |
1490 } | |
1491 | |
1492 | |
1493 ########################### | |
1494 # DEPRECATED METHODS FOLLOW | |
1495 ########################### | |
1496 | |
1497 =head2 DEPRECATED add_DBLink | |
1498 | |
1499 Description: DEPRECATED This method has been deprecated in favour of the | |
1500 add_DBEntry method. Objects are responible for holding only | |
1501 xrefs directly associated with themselves now. | |
1502 | |
1503 =cut | |
1504 | |
1505 | |
1506 sub add_DBLink{ | |
1507 my ($self,$value) = @_; | |
1508 | |
1509 throw("add_DBLink is deprecated. You probably want add_DBEntry."); | |
1510 | |
1511 # unless(defined $value && ref $value | |
1512 # && $value->isa('Bio::Annotation::DBLink') ) { | |
1513 # throw("This [$value] is not a DBLink"); | |
1514 # } | |
1515 | |
1516 # if( !defined $self->{'_db_link'} ) { | |
1517 # $self->{'_db_link'} = []; | |
1518 # } | |
1519 | |
1520 # push(@{$self->{'_db_link'}},$value); | |
1521 } | |
1522 | |
1523 | |
1524 =head2 temporary_id | |
1525 | |
1526 Function: DEPRECATED: Use dbID or stable_id or something else instead | |
1527 | |
1528 =cut | |
1529 | |
1530 sub temporary_id { | |
1531 my ($obj,$value) = @_; | |
1532 deprecate( "I cant see what a temporary_id is good for, please use " . | |
1533 "dbID or stableID or\n try without an id." ); | |
1534 if( defined $value) { | |
1535 $obj->{'temporary_id'} = $value; | |
1536 } | |
1537 return $obj->{'temporary_id'}; | |
1538 } | |
1539 | |
1540 | |
1541 =head2 chr_name | |
1542 | |
1543 Description: DEPRECATED. Use project, tranform, or transfer to obtain this | |
1544 gene in another coord system. Use $gene->slice->seq_region_name | |
1545 to get the name of the underlying coord system. Or | |
1546 $gene->slice->name(). | |
1547 | |
1548 =cut | |
1549 | |
1550 sub chr_name { | |
1551 my $self = shift; | |
1552 | |
1553 deprecate( "Use project() to obtain other coordinate systems" ); | |
1554 | |
1555 my $gene_slice = $self->slice(); | |
1556 if( $gene_slice->coord_system()->name eq "chromosome" ) { | |
1557 return $gene_slice->seq_region_name(); | |
1558 } | |
1559 | |
1560 my $coords = $self->project( "toplevel" ); | |
1561 | |
1562 if( @$coords ) { | |
1563 return $coords->[0]->[2]->seq_region_name(); | |
1564 } | |
1565 } | |
1566 | |
1567 | |
1568 =head2 fetch_coded_for_regulatory_factors | |
1569 | |
1570 Arg [1] : none | |
1571 Example : $gene->fetch_coded_for_regualtory_factors() | |
1572 Description: DEPRECATED: Fetches any regulatory_factors that are coded for by | |
1573 this gene. | |
1574 Returntype : Listref of Bio::Ensembl::RegulatoryFactor | |
1575 Exceptions : | |
1576 Caller : ? | |
1577 Status : At Risk | |
1578 : under development | |
1579 | |
1580 =cut | |
1581 | |
1582 sub fetch_coded_for_regulatory_factors { | |
1583 | |
1584 my ($self) = @_; | |
1585 | |
1586 my $rfa = $self->adaptor->db->get_RegulatoryFactorAdaptor(); | |
1587 | |
1588 return $rfa->fetch_factors_coded_for_by_gene($self); | |
1589 | |
1590 } | |
1591 | |
1592 | |
1593 =head2 type | |
1594 | |
1595 Description: DEPRECATED. Use biotype() instead. | |
1596 | |
1597 =cut | |
1598 | |
1599 sub type { | |
1600 deprecate("Use biotype() instead"); | |
1601 biotype(@_); | |
1602 } | |
1603 | |
1604 | |
1605 =head2 confidence | |
1606 | |
1607 Description: DEPRECATED. Use status() instead. | |
1608 | |
1609 =cut | |
1610 | |
1611 sub confidence { | |
1612 deprecate("Use status() instead"); | |
1613 status(@_); | |
1614 } | |
1615 | |
1616 | |
1617 1; | |
1618 |