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.
20 package Bio::EnsEMBL::IntronSupportingEvidence;
27 Please email comments or questions to the
public Ensembl
28 developers list at <http:
30 Questions may also be sent to the Ensembl help desk at
41 to populate values in
this field from. They are different objects though
42 due to
Intron's non-existence as a DB data structure.
46 #Example setups a ISE from the first two Exons
47 my ($five_prime_exon, $three_prime_exon) = @{$transcript->get_all_Exons()}[0..1];
48 my $intron = Bio::EnsEMBL::Intron->new($five_prime_exon, $three_prime_exon);
57 use base qw/Bio::EnsEMBL::Feature/;
59 use Bio::EnsEMBL::Intron;
60 use Bio::EnsEMBL::Utils::Argument qw/rearrange/;
61 use Bio::EnsEMBL::Utils::Exception qw/throw/;
62 use Bio::EnsEMBL::Utils::Scalar qw/assert_ref/;
64 our %SUPPORTED_TYPES = map { $_ => 1 } qw/NONE DEPTH/;
68 Arg [-ANALYSIS] : Bio::EnsEMBL::Analysis The analysis this intron is linked to
69 Arg [-START] : int - start postion of the IntronSupportingEvidence
70 Arg [-END] : int - end position of the IntronSupportingEvidence
71 Arg [-STRAND] : int - strand the IntronSupportingEvidence is on
72 Arg [-SLICE] : Bio::EnsEMBL::Slice - the slice the IntronSupportingEvidence is on
73 Arg [-INTRON] : Bio::EnsEMBL::Intron Intron the evidence is based
74 on. Useful if you are not specifying the location
75 parameters as we will take them from this
76 Arg [-HIT_NAME] : String The name of the hit
77 Arg [-SCORE] : Double The score associated with the supporting evidence
78 Arg [-SCORE_TYPE] : String The type of score we are representing
79 Example : Bio::EnsEMBL::IntronSupportingEvidence->new(
80 -ANALYSIS => $analysis, -INTRON => $intron,
81 -SCORE => 100, -SCORE_TYPE => 'DEPTH
');
82 Description : Returns a new instance of this object
83 Returntype : Bio::EnsEMBL::IntronSupportEvidence
84 Exceptions : Thrown if data is not as requested
89 my ($class, @args) = @_;
91 my $self = $class->SUPER::new(@args);
93 my ($intron, $hit_name, $score, $score_type, $is_splice_canonical) =
94 rearrange([qw/intron hit_name score score_type is_splice_canonical/], @args);
97 $self->set_values_from_Intron($intron);
99 $self->hit_name($hit_name) if $hit_name;
100 $self->score($score) if $score;
101 $self->score_type($score_type) if $score_type;
102 $self->is_splice_canonical($is_splice_canonical) if $is_splice_canonical;
107 =head2 set_values_from_Intron
109 Arg [1] : Bio::EnsEMBL::Intron The intron to base this object on
110 Example : $ise->set_values_from_Intron($intron);
111 Description : Sets the start, end, strand and slice of this ISE instance
112 using values from the given Intron object.
114 Exceptions : Thrown if data is not as requested
118 sub set_values_from_Intron {
119 my ($self, $intron) = @_;
121 $self->start($intron->start());
122 $self->end($intron->end());
123 $self->strand($intron->strand());
124 $self->slice($intron->slice());
125 $self->is_splice_canonical($intron->is_splice_canonical());
129 =head2 is_splice_canonical
132 Example : $ise->is_splice_canonical(1);
133 Description : Getter/setter for is_splice_canonical. Splice canonical
134 indicates those Introns which have a splice junction which
135 is structured as expected
141 sub is_splice_canonical {
142 my ($self, $is_splice_canonical) = @_;
143 $self->{'is_splice_canonical
'} = $is_splice_canonical if defined $is_splice_canonical;
144 return $self->{'is_splice_canonical
'};
149 Arg [1] : Bio::EnsEMBL::Transcript
150 Example : my $intron = $ise->intron($transcript);
151 Description : Provides access to an Intron object by using a given transcript
152 object and its associcated array of Exons.
153 Returntype : Bio::EnsEMBL::Intron
159 my ($self, $transcript) = @_;
161 my $five_prime = $self->find_previous_Exon($transcript);
162 my $three_prime = $self->find_next_Exon($transcript);
163 return Bio::EnsEMBL::Intron->new($five_prime, $three_prime);
168 Arg [1] : String name of the hit
169 Example : $ise->hit_name('hit
');
170 Description : Getter/setter for hit name i.e. an identifier for the alignments
177 my ($self, $hit_name) = @_;
178 $self->{'hit_name
'} = $hit_name if defined $hit_name;
179 return $self->{'hit_name
'};
184 Arg [1] : Number; the score associated with this feature
185 Example : $ise->score(100);
186 Description : Getter/setter for score
193 my ($self, $score) = @_;
194 $self->{'score
'} = $score if defined $score;
195 return $self->{'score
'};
200 Arg [1] : String the enum type. Currently only allowed NONE or DEPTH
201 Example : $ise->score_type('DEPTH
');
202 Description : Gets and sets the type of score this instance represents
204 Exceptions : Thrown if given an unsupported type of data
209 my ($self, $score_type) = @_;
210 if(defined $score_type) {
211 if(! $SUPPORTED_TYPES{$score_type}) {
212 my $values = join(q{, }, keys %SUPPORTED_TYPES);
213 throw "The score_type '$score_type
' is not allowed. Allowed values are [${values}]";
216 $self->{'score_type
'} = $score_type if defined $score_type;
217 return $self->{'score_type
'};
220 =head2 has_linked_transcripts
222 Example : $ise->has_linked_transcripts();
223 Description : Returns true if we have transcripts linked to this ISE
225 Exceptions : Thrown if we do not have an attached adaptor
229 sub has_linked_transcripts {
231 throw "No attached adaptor. Cannot find linked Transcripts unless this is a persisted object" unless $self->adaptor();
232 my $transcript_ids = $self->adaptor()->list_linked_transcript_ids($self);
233 return scalar(@{$transcript_ids}) ? 1 : 0;
238 Arg [1] : Bio::EnsEMBL::IntronSupportEvidence Object to compare to
239 Example : $ise->equals($another_ise);
240 Description : Asserts if the given IntronSupportEvidence instance was equal to this
247 my ($self, $other) = @_;
248 my $equal = $self->SUPER::equals($other);
249 return 0 if ! $equal;
251 ($self->hit_name()||q{}) eq ($other->hit_name()||q{}) &&
252 ($self->score_type() eq $other->score_type()) &&
253 ($self->score() == $other->score())) ? 1 : 0;
256 =head2 find_previous_Exon
258 Arg [1] : Bio::EnsEMBL::Transcript Transcript to search for the Exons from
259 Example : $ise->find_previous_Exon($transcript);
260 Description : Loops through those Exons available from the Transcript and
261 attempts to find one which was the 5' flanking
exon. If the
262 object has already been persisted we will use dbIDs to
269 sub find_previous_Exon {
270 my ($self, $transcript) = @_;
272 #Use DB IDs if we have them
274 if($self->adaptor()) {
275 my @ids = $self->
adaptor()->fetch_flanking_exon_ids($self, $transcript);
276 $exon_id = $ids[0]
if @ids;
279 my $exons = $transcript->get_all_Exons();
281 my $start = $self->start();
282 my $end = $self->end();
283 foreach my $exon (@{$exons}) {
285 return $exon
if $exon->dbID() == $exon_id;
288 if($self->strand() == 1) {
289 return $exon
if $exon->end() == $start-1;
292 return $exon
if $exon->start() == $end+1;
298 =head2 find_next_Exon
301 Example : $ise->find_next_Exon($transcript);
302 Description : Loops through those Exons available from the
Transcript and
303 attempts to find one which was the 3
' flanking exon. If the
304 object has already been persisted we will use dbIDs to
306 Returntype : Bio::EnsEMBL::Exon
312 my ($self, $transcript) = @_;
314 #Use DB IDs if we have them
316 if($self->adaptor()) {
317 my @ids = $self->adaptor()->fetch_flanking_exon_ids($self, $transcript);
318 $exon_id = $ids[1] if @ids;
321 my $exons = $transcript->get_all_Exons();
322 my $start = $self->start();
323 my $end = $self->end();
324 foreach my $exon (@{$exons}) {
326 return $exon if $exon->dbID() == $exon_id;
329 if($self->strand() == 1) {
330 return $exon if $exon->start() == $end+1;
333 return $exon if $exon->end() == $start-1;