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