ensembl-hive  2.7.0
Intron.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
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
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
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.
17 
18 =cut
19 
20 
21 =head1 CONTACT
22 
23  Please email comments or questions to the public Ensembl
24  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25 
26  Questions may also be sent to the Ensembl help desk at
27  <http://www.ensembl.org/Help/Contact>.
28 
29 =cut
30 
31 =head1 NAME Bio::EnsEMBL::Intron - A class representing an Intron
32 
33 =head1 SYNOPSIS
34 
35  $intron = Bio::EnsEMBL::Intron->new( exon1, exon2, $analysis );
36 
37 =cut
38 
39 
40 package Bio::EnsEMBL::Intron;
41 use strict;
42 use warnings;
43 
44 use Bio::EnsEMBL::Utils::Exception qw( warning throw );
45 
46 use base qw(Bio::EnsEMBL::Feature);
47 
48 =head2 new
49 
50  Arg [1] : Bio::EnsEMBL::Exon The 5' exon for the intron; required
51  Arg [2] : Bio::EnsEMBL::Exon The 3' exon for the intron; required
52  Arg [3] : Bio::EnsEMBL::Analysis Analysis to link to this Intron
53  Example : $intron = new Bio::EnsEMBL::Intron($exon1, $exon2)
54  Description: Create an Intron object from two exons and an optional analysis
55  Returntype : Bio::EnsEMBL::Intron
56  Exceptions : exons not on the same strand or slice.
57  Caller : general
58  Status : Stable
59 
60 =cut
61 
62 sub new {
63  my ( $proto, $e1, $e2, $analysis ) = @_;
64 
65  my $class = ref $proto || $proto;
66 
67  my $self = $class->SUPER::new();
68 
69  if ( $e1->strand() == -1 ) {
70  $self->{'end'} = $e1->start() - 1;
71  $self->{'start'} = $e2->end() + 1;
72  } else {
73  $self->{'start'} = $e1->end() + 1;
74  $self->{'end'} = $e2->start() - 1;
75  }
76 
77  if ( $e1->strand() != $e2->strand() ) {
78  # throw("Exons on different strand. Not allowed");
79  } else {
80  $self->{'strand'} = $e1->strand();
81  }
82 
83  if ( $e1->slice() != $e2->slice() ) {
84  if ( ( $e1->slice()->seq_region_name() ne
85  $e2->slice()->seq_region_name() )
86  && ( $e1->slice()->coord_system_name() ne
87  $e2->slice()->coord_system_name() ) )
88  {
89  throw("Exons on different slices. Not allowed");
90  } else {
91  warning("Exons have different slice references to the same seq_region");
92  }
93  } else {
94  $self->{'slice'} = $e1->slice();
95  }
96 
97  if($analysis) {
98  $self->analysis($analysis);
99  }
100 
101  $self->{'prev'} = $e1;
102  $self->{'next'} = $e2;
103 
104  return $self;
105 } ## end sub new
106 
107 =head2 length
108 
109  Args : none
110  Example : $length = $intron->length();
111  Description: Returns the length of this intron
112  Returntype : Integer
113  Exceptions : none
114  Caller : general
115  Status : Stable
116 
117 =cut
118 
119 sub length {
120  my ($self) = @_;
121 
122  # TODO: Introns on circular slices, see Feature.pm but allow for
123  # zero-length introns.
124 
125  return $self->{'end'} - $self->{'start'} + 1;
126 }
127 
128 
129 =head2 prev_Exon
130 
131  Args : none
132  Example : $exon = $intron->prev_Exon
133  Description: Returns the exon before this Intron
134  Returntype : Bio::EnsEMBL::Exon
135  Exceptions : none
136  Caller : general
137  Status : Stable
138 
139 =cut
140 
141 sub prev_Exon {
142  my ($self) = shift;
143 
144  return $self->{'prev'};
145 }
146 
147 
148 =head2 next_Exon
149 
150  Args : none
151  Example : $exon = $intron->next_Exon
152  Description: Returns the exon after this Intron
153  Returntype : Bio::EnsEMBL::Exon
154  Exceptions : none
155  Caller : general
156  Status : Stable
157 
158 =cut
159 
160 sub next_Exon {
161  my ($self) = shift;
162 
163  return $self->{'next'};
164 }
165 
166 =head2 rank
167 
168  Args : none
169  Example : $rank = $intron->rank
170  Description: Returns the rank of this Intron
171  Returntype : Integer
172  Exceptions : none
173  Caller : general
174  Status : Stable
175 
176 =cut
177 
178 sub rank {
179  my ($self, $transcript) = @_;
180 
181  return $self->prev_Exon->rank($transcript);
182 }
183 
184 =head2 is_splice_canonical
185 
186  Example : my $canonical = $intron->is_splice_canonical();
187  Description : Indicates if the splice site is considered normal. This means
188  splice site variants equal to (D == donor, A == acceptor)
189  GT (D) => AG (A)
190  AT (D) => AC (A)
191  GC (D) => AG (A)
192  Returntype : Boolean indicating if the splice was as expected
193  Exceptions : See splice_seq
194 
195 =cut
196 
197 sub is_splice_canonical {
198  my ($self) = @_;
199  my $splice = join q{}, @{$self->splice_seq()};
200  my $canonical = {
201  'GTAG' => 1, 'ATAC' => 1, 'GCAG' => 1
202  }->{$splice};
203  return $canonical || 0;
204 }
205 
206 =head2 splice_seq
207 
208  Example : my ($donor, $acceptor) = @{$intron->splice_seq};
209  Description : Get the donor and acceptor splice sites for this intron
210  Returntype : ArrayRef[String] The donor and acceptor sequences as Strings
211  Exceptions : Thrown if a feature Slice cannot be found
212 
213 =cut
214 
215 sub splice_seq {
216  my ($self) = @_;
217  my $slice = $self->feature_Slice();
218  throw "Cannot retrieve feature_Slice() for this Intron" unless $slice;
219  my $length = $self->length();
220  my $donor_seq = uc($slice->subseq(1,2));
221  my $acceptor_seq = uc($slice->subseq($length - 1, $length));
222  return [$donor_seq, $acceptor_seq];
223 }
224 
225 1;
226 
227 
Bio::EnsEMBL::Feature
Definition: Feature.pm:47
Bio::EnsEMBL::Intron::new
public Bio::EnsEMBL::Intron new()
exon
public exon()
Bio::EnsEMBL::Exon
Definition: Exon.pm:42
Bio::EnsEMBL::Feature::start
public Int start()
Bio::EnsEMBL::Analysis
Definition: PairAlign.pm:3
Bio::EnsEMBL::Intron
Definition: Intron.pm:10
Bio::EnsEMBL::Exon::rank
public Int rank()
Bio::EnsEMBL::Analysis
Definition: Analysis.pm:36
Bio::EnsEMBL::Utils::Exception
Definition: Exception.pm:68