Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/IntronSupportingEvidence.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 package Bio::EnsEMBL::IntronSupportingEvidence; | |
| 2 | |
| 3 =pod | |
| 4 | |
| 5 =head1 LICENSE | |
| 6 | |
| 7 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
| 8 Genome Research Limited. All rights reserved. | |
| 9 | |
| 10 This software is distributed under a modified Apache license. | |
| 11 For license details, please see | |
| 12 | |
| 13 http://www.ensembl.org/info/about/code_licence.html | |
| 14 | |
| 15 =head1 CONTACT | |
| 16 | |
| 17 Please email comments or questions to the public Ensembl | |
| 18 developers list at <dev@ensembl.org>. | |
| 19 | |
| 20 Questions may also be sent to the Ensembl help desk at | |
| 21 <helpdesk@ensembl.org>. | |
| 22 | |
| 23 =head1 NAME | |
| 24 | |
| 25 Bio::EnsEMBL::IntronSupportingEvidence | |
| 26 | |
| 27 =head1 DESCRIPTION | |
| 28 | |
| 29 Formalises an Intron with information about why it is a believed Intron. This | |
| 30 serves as a parallel object to Bio::EnsEMBL::Intron which you can use | |
| 31 to populate values in this field from. They are different objects though | |
| 32 due to Intron's non-existence as a DB data structure. | |
| 33 | |
| 34 =head1 SYNOPSIS | |
| 35 | |
| 36 #Example setups a ISE from the first two Exons | |
| 37 my ($five_prime_exon, $three_prime_exon) = @{$transcript->get_all_Exons()}[0..1]; | |
| 38 my $intron = Bio::EnsEMBL::Intron->new($five_prime_exon, $three_prime_exon); | |
| 39 | |
| 40 =head1 METHODS | |
| 41 | |
| 42 =cut | |
| 43 | |
| 44 | |
| 45 use strict; | |
| 46 use warnings; | |
| 47 use base qw/Bio::EnsEMBL::Feature/; | |
| 48 | |
| 49 use Bio::EnsEMBL::Intron; | |
| 50 use Bio::EnsEMBL::Utils::Argument qw/rearrange/; | |
| 51 use Bio::EnsEMBL::Utils::Exception qw/throw/; | |
| 52 use Bio::EnsEMBL::Utils::Scalar qw/assert_ref/; | |
| 53 | |
| 54 our %SUPPORTED_TYPES = map { $_ => 1 } qw/NONE DEPTH/; | |
| 55 | |
| 56 =head2 new | |
| 57 | |
| 58 Arg [-ANALYSIS] : Bio::EnsEMBL::Analysis The analysis this intron is linked to | |
| 59 Arg [-START] : int - start postion of the IntronSupportingEvidence | |
| 60 Arg [-END] : int - end position of the IntronSupportingEvidence | |
| 61 Arg [-STRAND] : int - strand the IntronSupportingEvidence is on | |
| 62 Arg [-SLICE] : Bio::EnsEMBL::Slice - the slice the IntronSupportingEvidence is on | |
| 63 Arg [-INTRON] : Bio::EnsEMBL::Intron Intron the evidence is based | |
| 64 on. Useful if you are not specifying the location | |
| 65 parameters as we will take them from this | |
| 66 Arg [-HIT_NAME] : String The name of the hit | |
| 67 Arg [-SCORE] : Double The score associated with the supporting evidence | |
| 68 Arg [-SCORE_TYPE] : String The type of score we are representing | |
| 69 Example : Bio::EnsEMBL::IntronSupportingEvidence->new( | |
| 70 -ANALYSIS => $analysis, -INTRON => $intron, | |
| 71 -SCORE => 100, -SCORE_TYPE => 'DEPTH'); | |
| 72 Description : Returns a new instance of this object | |
| 73 Returntype : Bio::EnsEMBL::IntronSupportEvidence | |
| 74 Exceptions : Thrown if data is not as requested | |
| 75 | |
| 76 =cut | |
| 77 | |
| 78 sub new { | |
| 79 my ($class, @args) = @_; | |
| 80 | |
| 81 my $self = $class->SUPER::new(@args); | |
| 82 | |
| 83 my ($intron, $hit_name, $score, $score_type, $is_splice_canonical) = | |
| 84 rearrange([qw/intron hit_name score score_type is_splice_canonical/], @args); | |
| 85 | |
| 86 if($intron) { | |
| 87 $self->set_values_from_Intron($intron); | |
| 88 } | |
| 89 $self->hit_name($hit_name) if $hit_name; | |
| 90 $self->score($score) if $score; | |
| 91 $self->score_type($score_type) if $score_type; | |
| 92 $self->is_splice_canonical($is_splice_canonical) if $is_splice_canonical; | |
| 93 | |
| 94 return $self; | |
| 95 } | |
| 96 | |
| 97 =head2 set_values_from_Intron | |
| 98 | |
| 99 Arg [1] : Bio::EnsEMBL::Intron The intron to base this object on | |
| 100 Example : $ise->set_values_from_Intron($intron); | |
| 101 Description : Sets the start, end, strand and slice of this ISE instance | |
| 102 using values from the given Intron object. | |
| 103 Returntype : None | |
| 104 Exceptions : Thrown if data is not as requested | |
| 105 | |
| 106 =cut | |
| 107 | |
| 108 sub set_values_from_Intron { | |
| 109 my ($self, $intron) = @_; | |
| 110 assert_ref($intron, 'Bio::EnsEMBL::Intron', 'intron'); | |
| 111 $self->start($intron->start()); | |
| 112 $self->end($intron->end()); | |
| 113 $self->strand($intron->strand()); | |
| 114 $self->slice($intron->slice()); | |
| 115 $self->is_splice_canonical($intron->is_splice_canonical()); | |
| 116 return; | |
| 117 } | |
| 118 | |
| 119 =head2 is_splice_canonical | |
| 120 | |
| 121 Arg [1] : Boolean | |
| 122 Example : $ise->is_splice_canonical(1); | |
| 123 Description : Getter/setter for is_splice_canonical. Splice canonical | |
| 124 indicates those Introns which have a splice junction which | |
| 125 is structured as expected | |
| 126 Returntype : Boolean | |
| 127 Exceptions : | |
| 128 | |
| 129 =cut | |
| 130 | |
| 131 sub is_splice_canonical { | |
| 132 my ($self, $is_splice_canonical) = @_; | |
| 133 $self->{'is_splice_canonical'} = $is_splice_canonical if defined $is_splice_canonical; | |
| 134 return $self->{'is_splice_canonical'}; | |
| 135 } | |
| 136 | |
| 137 =head2 get_Intron | |
| 138 | |
| 139 Arg [1] : Bio::EnsEMBL::Transcript | |
| 140 Example : my $intron = $ise->intron($transcript); | |
| 141 Description : Provides access to an Intron object by using a given transcript | |
| 142 object and its associcated array of Exons. | |
| 143 Returntype : Bio::EnsEMBL::Intron | |
| 144 Exceptions : None | |
| 145 | |
| 146 =cut | |
| 147 | |
| 148 sub get_Intron { | |
| 149 my ($self, $transcript) = @_; | |
| 150 assert_ref($transcript, 'Bio::EnsEMBL::Transcript', 'transcript'); | |
| 151 my $five_prime = $self->find_previous_Exon($transcript); | |
| 152 my $three_prime = $self->find_next_Exon($transcript); | |
| 153 return Bio::EnsEMBL::Intron->new($five_prime, $three_prime); | |
| 154 } | |
| 155 | |
| 156 =head2 hit_name | |
| 157 | |
| 158 Arg [1] : String name of the hit | |
| 159 Example : $ise->hit_name('hit'); | |
| 160 Description : Getter/setter for hit name i.e. an identifier for the alignments | |
| 161 Returntype : String | |
| 162 Exceptions : None | |
| 163 | |
| 164 =cut | |
| 165 | |
| 166 sub hit_name { | |
| 167 my ($self, $hit_name) = @_; | |
| 168 $self->{'hit_name'} = $hit_name if defined $hit_name; | |
| 169 return $self->{'hit_name'}; | |
| 170 } | |
| 171 | |
| 172 =head2 score | |
| 173 | |
| 174 Arg [1] : Number; the score associated with this feature | |
| 175 Example : $ise->score(100); | |
| 176 Description : Getter/setter for score | |
| 177 Returntype : Number | |
| 178 Exceptions : None | |
| 179 | |
| 180 =cut | |
| 181 | |
| 182 sub score { | |
| 183 my ($self, $score) = @_; | |
| 184 $self->{'score'} = $score if defined $score; | |
| 185 return $self->{'score'}; | |
| 186 } | |
| 187 | |
| 188 =head2 score_type | |
| 189 | |
| 190 Arg [1] : String the enum type. Currently only allowed NONE or DEPTH | |
| 191 Example : $ise->score_type('DEPTH'); | |
| 192 Description : Gets and sets the type of score this instance represents | |
| 193 Returntype : String | |
| 194 Exceptions : Thrown if given an unsupported type of data | |
| 195 | |
| 196 =cut | |
| 197 | |
| 198 sub score_type { | |
| 199 my ($self, $score_type) = @_; | |
| 200 if(defined $score_type) { | |
| 201 if(! $SUPPORTED_TYPES{$score_type}) { | |
| 202 my $values = join(q{, }, keys %SUPPORTED_TYPES); | |
| 203 throw "The score_type '$score_type' is not allowed. Allowed values are [${values}]"; | |
| 204 } | |
| 205 } | |
| 206 $self->{'score_type'} = $score_type if defined $score_type; | |
| 207 return $self->{'score_type'}; | |
| 208 } | |
| 209 | |
| 210 =head2 has_linked_transcripts | |
| 211 | |
| 212 Example : $ise->has_linked_transcripts(); | |
| 213 Description : Returns true if we have transcripts linked to this ISE | |
| 214 Returntype : Boolean | |
| 215 Exceptions : Thrown if we do not have an attached adaptor | |
| 216 | |
| 217 =cut | |
| 218 | |
| 219 sub has_linked_transcripts { | |
| 220 my ($self) = @_; | |
| 221 throw "No attached adaptor. Cannot find linked Transcripts unless this is a persisted object" unless $self->adaptor(); | |
| 222 my $transcript_ids = $self->adaptor()->list_linked_transcript_ids($self); | |
| 223 return scalar(@{$transcript_ids}) ? 1 : 0; | |
| 224 } | |
| 225 | |
| 226 =head2 equals | |
| 227 | |
| 228 Arg [1] : Bio::EnsEMBL::IntronSupportEvidence Object to compare to | |
| 229 Example : $ise->equals($another_ise); | |
| 230 Description : Asserts if the given IntronSupportEvidence instance was equal to this | |
| 231 Returntype : Boolean | |
| 232 Exceptions : None | |
| 233 | |
| 234 =cut | |
| 235 | |
| 236 sub equals { | |
| 237 my ($self, $other) = @_; | |
| 238 my $equal = $self->SUPER::equals($other); | |
| 239 return 0 if ! $equal; | |
| 240 return ( | |
| 241 ($self->hit_name()||q{}) eq ($other->hit_name()||q{}) && | |
| 242 ($self->score_type() eq $other->score_type()) && | |
| 243 ($self->score() == $other->score())) ? 1 : 0; | |
| 244 } | |
| 245 | |
| 246 =head2 find_previous_Exon | |
| 247 | |
| 248 Arg [1] : Bio::EnsEMBL::Transcript Transcript to search for the Exons from | |
| 249 Example : $ise->find_previous_Exon($transcript); | |
| 250 Description : Loops through those Exons available from the Transcript and | |
| 251 attempts to find one which was the 5' flanking exon. If the | |
| 252 object has already been persisted we will use dbIDs to | |
| 253 find the Exons | |
| 254 Returntype : Bio::EnsEMBL::Exon | |
| 255 Exceptions : None | |
| 256 | |
| 257 =cut | |
| 258 | |
| 259 sub find_previous_Exon { | |
| 260 my ($self, $transcript) = @_; | |
| 261 | |
| 262 #Use DB IDs if we have them | |
| 263 my $exon_id; | |
| 264 if($self->adaptor()) { | |
| 265 my @ids = $self->adaptor()->fetch_flanking_exon_ids($self, $transcript); | |
| 266 $exon_id = $ids[0] if @ids; | |
| 267 } | |
| 268 | |
| 269 my $exons = $transcript->get_all_Exons(); | |
| 270 | |
| 271 my $start = $self->start(); | |
| 272 my $end = $self->end(); | |
| 273 foreach my $exon (@{$exons}) { | |
| 274 if($exon_id) { | |
| 275 return $exon if $exon->dbID() == $exon_id; | |
| 276 next; | |
| 277 } | |
| 278 if($self->strand() == 1) { | |
| 279 return $exon if $exon->end() == $start-1; | |
| 280 } | |
| 281 else { | |
| 282 return $exon if $exon->start() == $end+1; | |
| 283 } | |
| 284 } | |
| 285 return; | |
| 286 } | |
| 287 | |
| 288 =head2 find_next_Exon | |
| 289 | |
| 290 Arg [1] : Bio::EnsEMBL::Transcript Transcript to search for the Exons from | |
| 291 Example : $ise->find_next_Exon($transcript); | |
| 292 Description : Loops through those Exons available from the Transcript and | |
| 293 attempts to find one which was the 3' flanking exon. If the | |
| 294 object has already been persisted we will use dbIDs to | |
| 295 find the Exons | |
| 296 Returntype : Bio::EnsEMBL::Exon | |
| 297 Exceptions : None | |
| 298 | |
| 299 =cut | |
| 300 | |
| 301 sub find_next_Exon { | |
| 302 my ($self, $transcript) = @_; | |
| 303 | |
| 304 #Use DB IDs if we have them | |
| 305 my $exon_id; | |
| 306 if($self->adaptor()) { | |
| 307 my @ids = $self->adaptor()->fetch_flanking_exon_ids($self, $transcript); | |
| 308 $exon_id = $ids[1] if @ids; | |
| 309 } | |
| 310 | |
| 311 my $exons = $transcript->get_all_Exons(); | |
| 312 my $start = $self->start(); | |
| 313 my $end = $self->end(); | |
| 314 foreach my $exon (@{$exons}) { | |
| 315 if($exon_id) { | |
| 316 return $exon if $exon->dbID() == $exon_id; | |
| 317 next; | |
| 318 } | |
| 319 if($self->strand() == 1) { | |
| 320 return $exon if $exon->start() == $end+1; | |
| 321 } | |
| 322 else { | |
| 323 return $exon if $exon->end() == $start-1; | |
| 324 } | |
| 325 } | |
| 326 return; | |
| 327 } | |
| 328 | |
| 329 1; |
