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