From 044f5660380de4409902bd98954f112aff9633e3 Mon Sep 17 00:00:00 2001 From: Kieron Taylor <ktaylor@ebi.ac.uk> Date: Thu, 18 Sep 2014 15:05:34 +0100 Subject: [PATCH] Code tidy in AssemblyExceptionFeatureAdaptor --- .../DBSQL/AssemblyExceptionFeatureAdaptor.pm | 134 +++++++----------- 1 file changed, 54 insertions(+), 80 deletions(-) diff --git a/modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm index 550c4f40de..3006351e15 100644 --- a/modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm @@ -286,7 +286,6 @@ sub _remap { $features->[0]->slice == $slice)) { return $features; } - # remapping has not been done, we have to do our own conversion from # to slice coords @@ -333,14 +332,6 @@ sub _remap { # create new copies of successfully mapped feaatures with shifted start, # end and strand my ($new_start, $new_end); - # if($slice_strand == -1) { - # $new_start = $slice_end - $end + 1; - # $new_end = $slice_end - $start + 1; - # } else { - # $new_start = $start - $slice_start + 1; - # $new_end = $end - $slice_start + 1; - # } - my $seq_region_len = $slice->seq_region_length(); if ($slice_strand == 1) { # Positive strand @@ -349,92 +340,75 @@ sub _remap { $new_end = $end - $slice_start + 1; if ($slice->is_circular()) { - # Handle circular chromosomes. - - if ($new_start > $new_end) { - # Looking at a feature overlapping the chromsome origin. - - if ($new_end > $slice_start) { - - # Looking at the region in the beginning of the - # chromosome. - $new_start -= $seq_region_len; - } - - if ($new_end < 0) { - $new_end += $seq_region_len; - } - - } else { - - if ( $slice_start > $slice_end - && $new_end < 0) { - # Looking at the region overlapping the chromosome - # origin and a feature which is at the beginning of the - # chromosome. - $new_start += $seq_region_len; - $new_end += $seq_region_len; - } - } - - } ## end if ($dest_slice->is_circular...) - - } else { # Negative strand + # Handle circular chromosomes. + + if ($new_start > $new_end) { + # Looking at a feature overlapping the chromsome origin. + if ($new_end > $slice_start) { + # Looking at the region in the beginning of the chromosome. + $new_start -= $seq_region_len; + } + if ($new_end < 0) { + $new_end += $seq_region_len; + } + } else { + if ( $slice_start > $slice_end && $new_end < 0) { + # Looking at the region overlapping the chromosome + # origin and a feature which is at the beginning of the + # chromosome. + $new_start += $seq_region_len; + $new_end += $seq_region_len; + } + } + } ## end if ($dest_slice->is_circular...) + } else { # Negative strand my $new_start = $slice_end - $end + 1; my $new_end = $slice_end - $start + 1; if ($slice->is_circular()) { - if ($slice_start > $slice_end) { - # slice spans origin or replication - - if ($start >= $slice_start) { - $new_end += $seq_region_len; - $new_start += $seq_region_len - if $end > $slice_start; + if ($slice_start > $slice_end) { + # slice spans origin or replication - } elsif ($start <= $slice_end) { - # do nothing - } elsif ($end >= $slice_start) { - $new_start += $seq_region_len; - $new_end += $seq_region_len; + if ($start >= $slice_start) { + $new_end += $seq_region_len; + $new_start += $seq_region_len if $end > $slice_start; - } elsif ($end <= $slice_end) { + } elsif ($start <= $slice_end) { + # do nothing + } elsif ($end >= $slice_start) { + $new_start += $seq_region_len; + $new_end += $seq_region_len; - $new_end += $seq_region_len - if $new_end < 0; + } elsif ($end <= $slice_end) { + $new_end += $seq_region_len if $new_end < 0; + } elsif ($start > $end) { + $new_end += $seq_region_len; + } else { - } elsif ($start > $end) { - - $new_end += $seq_region_len; + } + + } else { - } else { - - } - - } else { + if ($start <= $slice_end and $end >= $slice_start) { + # do nothing + } elsif ($start > $end) { + if ($start <= $slice_end) { + + $new_start -= $seq_region_len; - if ($start <= $slice_end and $end >= $slice_start) { - # do nothing - } elsif ($start > $end) { - if ($start <= $slice_end) { - - $new_start -= $seq_region_len; + } elsif ($end >= $slice_start) { + $new_end += $seq_region_len; + } else { - } elsif ($end >= $slice_start) { - $new_end += $seq_region_len; - - } else { - - } - } - } + } + } + } } - } ## end else [ if ($dest_slice_strand...)] - + } ## end else [ if ($dest_slice_strand...)] push @out, Bio::EnsEMBL::AssemblyExceptionFeature->new( '-dbID' => $f->dbID, '-start' => $new_start, @@ -445,7 +419,7 @@ sub _remap { '-alternate_slice' => $f->alternate_slice, '-type' => $f->type, ); - } + } # end foreach assembly exception return \@out; } -- GitLab