Skip to content
Snippets Groups Projects
Unverified Commit f4ca4f04 authored by Premanand Achuthan's avatar Premanand Achuthan Committed by GitHub
Browse files

Merge pull request #229 from Ensembl/bugfix/ENSCORESW-2465

[ENSCORESW-2465] Fix comparisons in Exon::is_coding() to prevent fals…
parents eed00353 47afe3b6
No related branches found
No related tags found
No related merge requests found
...@@ -1302,11 +1302,15 @@ sub is_coding { ...@@ -1302,11 +1302,15 @@ sub is_coding {
my ( $self, $transcript) = @_; my ( $self, $transcript) = @_;
if (!$transcript->translate) { return 0; } if (!$transcript->translate) { return 0; }
if ($transcript->coding_region_start < $self->start && $self->start < $transcript->coding_region_end) { return 1; }
if ($transcript->coding_region_end > $self->end && $self->end > $transcript->coding_region_start) { return 1; } # coding region overlaps start of exon
if ($transcript->coding_region_start <= $self->start && $self->start <= $transcript->coding_region_end) { return 1; }
# coding region overlaps end of exon
if ($transcript->coding_region_end >= $self->end && $self->end >= $transcript->coding_region_start) { return 1; }
# to handle cases where transcript coding region can fall within the exon start and exon end, eg: if it is one exon transcript # to handle cases where transcript coding region can fall within the exon start and exon end, eg: if it is one exon transcript
if ($transcript->coding_region_start > $self->start && $transcript->coding_region_end < $self->end ) { return 1; } if ($transcript->coding_region_start >= $self->start && $transcript->coding_region_end <= $self->end ) { return 1; }
return 0; return 0;
} }
......
...@@ -524,6 +524,77 @@ SKIP: { ...@@ -524,6 +524,77 @@ SKIP: {
$is_coding = $exon_one->is_coding($tr); $is_coding = $exon_one->is_coding($tr);
is($is_coding, 1, "Exon is coding"); is($is_coding, 1, "Exon is coding");
# Create a single-exon transcript that is entirely coding
$tr = Bio::EnsEMBL::Transcript->new(-SLICE => $local_slice, -START => 2000, -END => 2998, -STRAND => -1);
$start_exon = Bio::EnsEMBL::Exon->new(-START => 2000, -END => 2998, -STRAND => -1, -SLICE => $local_slice);
$tr->add_Exon($start_exon);
$tr->translation(Bio::EnsEMBL::Translation->new(
-SEQ_START => 1,
-SEQ_END => 999,
-START_EXON => $start_exon,
-END_EXON => $start_exon,
));
$exon_one = $tr->get_all_Exons()->[0];
$is_coding = $exon_one->is_coding($tr);
is($is_coding, 1, "Exon exactly matching translation is coding");
# Create this transcript structure (- = noncoding, # = coding, ^ = intron)
# 5'------^---###^######3'
$tr = Bio::EnsEMBL::Transcript->new(-SLICE => $local_slice, -START => 2000, -END => 3000, -STRAND => 1);
my @exons = ( Bio::EnsEMBL::Exon->new(-START => 2000, -END => 2100, -STRAND => 1, -SLICE => $local_slice),
Bio::EnsEMBL::Exon->new(-START => 2200, -END => 2600, -STRAND => 1, -SLICE => $local_slice),
Bio::EnsEMBL::Exon->new(-START => 2800, -END => 3000, -STRAND => 1, -SLICE => $local_slice) );
foreach my $component_exon (@exons) {
$tr->add_Exon($component_exon);
}
$tr->translation(Bio::EnsEMBL::Translation->new(
-SEQ_START => 201,
-SEQ_END => 201,
-START_EXON => $exons[1],
-END_EXON => $exons[2],
));
$exon_one = $tr->get_all_Exons()->[0];
$is_coding = $exon_one->is_coding($tr);
is($is_coding, 0, "is_coding returns zero for noncoding exon one");
my $exon_two = $tr->get_all_Exons()->[1];
$is_coding = $exon_two->is_coding($tr);
is($is_coding, 1, "is_coding returns one for partially coding exon two");
my $exon_three = $tr->get_all_Exons()->[2];
$is_coding = $exon_three->is_coding($tr);
is($is_coding, 1, "is_coding returns one for fully coding exon three");
# Repeat the above transcript structure on the reverse strand
$tr = Bio::EnsEMBL::Transcript->new(-SLICE => $local_slice, -START => 2000, -END => 3000, -STRAND => -1);
@exons = ( Bio::EnsEMBL::Exon->new(-START => 2000, -END => 2100, -STRAND => -1, -SLICE => $local_slice),
Bio::EnsEMBL::Exon->new(-START => 2200, -END => 2600, -STRAND => -1, -SLICE => $local_slice),
Bio::EnsEMBL::Exon->new(-START => 2800, -END => 3000, -STRAND => -1, -SLICE => $local_slice) );
foreach my $component_exon (@exons) {
$tr->add_Exon($component_exon);
}
$tr->translation(Bio::EnsEMBL::Translation->new(
-SEQ_START => 200,
-SEQ_END => 101,
-START_EXON => $exons[1],
-END_EXON => $exons[0],
));
$exon_one = $tr->get_all_Exons()->[2];
$is_coding = $exon_one->is_coding($tr);
is($is_coding, 1, "is_coding returns one for fully coding reverse exon one");
$exon_two = $tr->get_all_Exons()->[1];
$is_coding = $exon_two->is_coding($tr);
is($is_coding, 1, "is_coding returns one for partially coding reverse exon two");
$exon_three = $tr->get_all_Exons()->[0];
$is_coding = $exon_three->is_coding($tr);
is($is_coding, 0, "is_coding returns zero for noncoding reverse exon three");
} }
done_testing(); done_testing();
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment