Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl
Commits
448cea7c
Commit
448cea7c
authored
Jul 31, 2013
by
Alessandro Vullo
Browse files
Added circular slice case for positive/negative strands when computing slice relative coordinates
parent
680bb69c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
727 additions
and
78 deletions
+727
-78
modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm
+101
-7
modules/Bio/EnsEMBL/DBSQL/DnaAlignFeatureAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/DnaAlignFeatureAdaptor.pm
+102
-15
modules/Bio/EnsEMBL/DBSQL/MiscFeatureAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/MiscFeatureAdaptor.pm
+99
-12
modules/Bio/EnsEMBL/DBSQL/PredictionTranscriptAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/PredictionTranscriptAdaptor.pm
+96
-12
modules/Bio/EnsEMBL/DBSQL/ProteinAlignFeatureAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/ProteinAlignFeatureAdaptor.pm
+98
-12
modules/Bio/EnsEMBL/Map/DBSQL/DitagFeatureAdaptor.pm
modules/Bio/EnsEMBL/Map/DBSQL/DitagFeatureAdaptor.pm
+132
-8
modules/Bio/EnsEMBL/Map/DBSQL/MarkerFeatureAdaptor.pm
modules/Bio/EnsEMBL/Map/DBSQL/MarkerFeatureAdaptor.pm
+99
-12
No files found.
modules/Bio/EnsEMBL/DBSQL/AssemblyExceptionFeatureAdaptor.pm
View file @
448cea7c
...
...
@@ -324,14 +324,108 @@ 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
;
}
#
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
$new_start
=
$start
-
$slice_start
+
1
;
$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
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
;
}
elsif
(
$start
<=
$slice_end
)
{
# do nothing
}
elsif
(
$end
>=
$slice_start
)
{
$new_start
+=
$seq_region_len
;
$new_end
+=
$seq_region_len
;
}
elsif
(
$end
<=
$slice_end
)
{
$new_end
+=
$seq_region_len
if
$new_end
<
0
;
}
elsif
(
$start
>
$end
)
{
$new_end
+=
$seq_region_len
;
}
else
{
}
}
else
{
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
{
}
}
}
}
}
## end else [ if ($dest_slice_strand...)]
push
@out
,
Bio::EnsEMBL::
AssemblyExceptionFeature
->
new
(
'
-dbID
'
=>
$f
->
dbID
,
'
-start
'
=>
$new_start
,
...
...
modules/Bio/EnsEMBL/DBSQL/DnaAlignFeatureAdaptor.pm
View file @
448cea7c
...
...
@@ -501,25 +501,112 @@ FEATURE:
# If a destination slice was provided, convert the coords. If the
# dest_slice starts at 1 and is forward strand, nothing needs doing.
if
(
defined
(
$dest_slice
)
)
{
if
(
$dest_slice_start
!=
1
||
$dest_slice_strand
!=
1
)
{
if
(
$dest_slice_strand
==
1
)
{
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
}
else
{
my
$tmp_seq_region_start
=
$seq_region_start
;
$seq_region_start
=
$dest_slice_end
-
$seq_region_end
+
1
;
$seq_region_end
=
$dest_slice_end
-
$tmp_seq_region_start
+
1
;
$seq_region_strand
=
-
$seq_region_strand
;
}
my
$seq_region_len
=
$dest_slice
->
seq_region_length
();
if
(
$dest_slice_strand
==
1
)
{
# Positive strand
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
# Handle cicular chromosomes.
if
(
$seq_region_start
>
$seq_region_end
)
{
# Looking at a feature overlapping the chromsome origin.
if
(
$seq_region_end
>
$dest_slice_start
)
{
# Looking at the region in the beginning of the
# chromosome.
$seq_region_start
-=
$seq_region_len
;
}
if
(
$seq_region_end
<
0
)
{
$seq_region_end
+=
$seq_region_len
;
}
}
else
{
if
(
$dest_slice_start
>
$dest_slice_end
&&
$seq_region_end
<
0
)
{
# Looking at the region overlapping the chromosome
# origin and a feature which is at the beginning of the
# chromosome.
$seq_region_start
+=
$seq_region_len
;
$seq_region_end
+=
$seq_region_len
;
}
}
}
## end if ($dest_slice->is_circular...)
}
else
{
# Negative strand
my
$start
=
$dest_slice_end
-
$seq_region_end
+
1
;
my
$end
=
$dest_slice_end
-
$seq_region_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
if
(
$dest_slice_start
>
$dest_slice_end
)
{
# slice spans origin or replication
if
(
$seq_region_start
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
$start
+=
$seq_region_len
if
$seq_region_end
>
$dest_slice_start
;
# Throw away features off the end of the requested slice.
if
(
$seq_region_end
<
1
||
$seq_region_start
>
$dest_slice_length
||
(
$dest_slice_seq_region_id
ne
$seq_region_id
)
)
}
elsif
(
$seq_region_start
<=
$dest_slice_end
)
{
# do nothing
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$start
+=
$seq_region_len
;
$end
+=
$seq_region_len
;
}
elsif
(
$seq_region_end
<=
$dest_slice_end
)
{
$end
+=
$seq_region_len
if
$end
<
0
;
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
else
{
if
(
$seq_region_start
<=
$dest_slice_end
and
$seq_region_end
>=
$dest_slice_start
)
{
# do nothing
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
if
(
$seq_region_start
<=
$dest_slice_end
)
{
$start
-=
$seq_region_len
;
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
}
}
$seq_region_start
=
$start
;
$seq_region_end
=
$end
;
$seq_region_strand
*=
-
1
;
}
## end else [ if ($dest_slice_strand...)]
# Throw away features off the end of the requested slice.
if
(
$seq_region_end
<
1
||
$seq_region_start
>
$dest_slice_length
||
(
$dest_slice_seq_region_id
ne
$seq_region_id
)
)
{
next
FEATURE
;
}
}
$slice
=
$dest_slice
;
}
...
...
modules/Bio/EnsEMBL/DBSQL/MiscFeatureAdaptor.pm
View file @
448cea7c
...
...
@@ -469,20 +469,106 @@ sub _objs_from_sth {
#
# If a destination slice was provided convert the coords
# If the dest_slice starts at 1 and is foward strand, nothing needs doing
#
if
(
$dest_slice
)
{
if
(
$dest_slice_start
!=
1
||
$dest_slice_strand
!=
1
)
{
if
(
$dest_slice_strand
==
1
)
{
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
}
else
{
my
$tmp_seq_region_start
=
$seq_region_start
;
$seq_region_start
=
$dest_slice_end
-
$seq_region_end
+
1
;
$seq_region_end
=
$dest_slice_end
-
$tmp_seq_region_start
+
1
;
$seq_region_strand
*=
-
1
;
}
}
my
$seq_region_len
=
$dest_slice
->
seq_region_length
();
if
(
$dest_slice_strand
==
1
)
{
# Positive strand
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
# Handle cicular chromosomes.
if
(
$seq_region_start
>
$seq_region_end
)
{
# Looking at a feature overlapping the chromsome origin.
if
(
$seq_region_end
>
$dest_slice_start
)
{
# Looking at the region in the beginning of the
# chromosome.
$seq_region_start
-=
$seq_region_len
;
}
if
(
$seq_region_end
<
0
)
{
$seq_region_end
+=
$seq_region_len
;
}
}
else
{
if
(
$dest_slice_start
>
$dest_slice_end
&&
$seq_region_end
<
0
)
{
# Looking at the region overlapping the chromosome
# origin and a feature which is at the beginning of the
# chromosome.
$seq_region_start
+=
$seq_region_len
;
$seq_region_end
+=
$seq_region_len
;
}
}
}
## end if ($dest_slice->is_circular...)
}
else
{
# Negative strand
my
$start
=
$dest_slice_end
-
$seq_region_end
+
1
;
my
$end
=
$dest_slice_end
-
$seq_region_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
if
(
$dest_slice_start
>
$dest_slice_end
)
{
# slice spans origin or replication
if
(
$seq_region_start
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
$start
+=
$seq_region_len
if
$seq_region_end
>
$dest_slice_start
;
}
elsif
(
$seq_region_start
<=
$dest_slice_end
)
{
# do nothing
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$start
+=
$seq_region_len
;
$end
+=
$seq_region_len
;
}
elsif
(
$seq_region_end
<=
$dest_slice_end
)
{
$end
+=
$seq_region_len
if
$end
<
0
;
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
else
{
if
(
$seq_region_start
<=
$dest_slice_end
and
$seq_region_end
>=
$dest_slice_start
)
{
# do nothing
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
if
(
$seq_region_start
<=
$dest_slice_end
)
{
$start
-=
$seq_region_len
;
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
}
}
$seq_region_start
=
$start
;
$seq_region_end
=
$end
;
$seq_region_strand
*=
-
1
;
}
## end else [ if ($dest_slice_strand...)]
#throw away features off the end of the requested slice
if
(
$seq_region_end
<
1
||
$seq_region_start
>
$dest_slice_length
||
(
$dest_slice_sr_id
ne
$seq_region_id
))
{
...
...
@@ -490,6 +576,7 @@ sub _objs_from_sth {
$throw_away
=
$misc_feature_id
;
next
FEATURE
;
}
$slice
=
$dest_slice
;
}
...
...
modules/Bio/EnsEMBL/DBSQL/PredictionTranscriptAdaptor.pm
View file @
448cea7c
...
...
@@ -383,20 +383,105 @@ sub _objs_from_sth {
#
# If a destination slice was provided convert the coords
# If the dest_slice starts at 1 and is foward strand, nothing needs doing
#
if
(
$dest_slice
)
{
if
(
$dest_slice_start
!=
1
||
$dest_slice_strand
!=
1
)
{
if
(
$dest_slice_strand
==
1
)
{
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
}
else
{
my
$tmp_seq_region_start
=
$seq_region_start
;
$seq_region_start
=
$dest_slice_end
-
$seq_region_end
+
1
;
$seq_region_end
=
$dest_slice_end
-
$tmp_seq_region_start
+
1
;
$seq_region_strand
*=
-
1
;
my
$seq_region_len
=
$dest_slice
->
seq_region_length
();
if
(
$dest_slice_strand
==
1
)
{
# Positive strand
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
# Handle cicular chromosomes.
if
(
$seq_region_start
>
$seq_region_end
)
{
# Looking at a feature overlapping the chromsome origin.
if
(
$seq_region_end
>
$dest_slice_start
)
{
# Looking at the region in the beginning of the
# chromosome.
$seq_region_start
-=
$seq_region_len
;
}
if
(
$seq_region_end
<
0
)
{
$seq_region_end
+=
$seq_region_len
;
}
}
else
{
if
(
$dest_slice_start
>
$dest_slice_end
&&
$seq_region_end
<
0
)
{
# Looking at the region overlapping the chromosome
# origin and a feature which is at the beginning of the
# chromosome.
$seq_region_start
+=
$seq_region_len
;
$seq_region_end
+=
$seq_region_len
;
}
}
}
## end if ($dest_slice->is_circular...)
}
else
{
# Negative strand
my
$start
=
$dest_slice_end
-
$seq_region_end
+
1
;
my
$end
=
$dest_slice_end
-
$seq_region_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
if
(
$dest_slice_start
>
$dest_slice_end
)
{
# slice spans origin or replication
if
(
$seq_region_start
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
$start
+=
$seq_region_len
if
$seq_region_end
>
$dest_slice_start
;
}
elsif
(
$seq_region_start
<=
$dest_slice_end
)
{
# do nothing
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$start
+=
$seq_region_len
;
$end
+=
$seq_region_len
;
}
elsif
(
$seq_region_end
<=
$dest_slice_end
)
{
$end
+=
$seq_region_len
if
$end
<
0
;
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
else
{
if
(
$seq_region_start
<=
$dest_slice_end
and
$seq_region_end
>=
$dest_slice_start
)
{
# do nothing
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
if
(
$seq_region_start
<=
$dest_slice_end
)
{
$start
-=
$seq_region_len
;
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
}
}
}
$seq_region_start
=
$start
;
$seq_region_end
=
$end
;
$seq_region_strand
*=
-
1
;
}
## end else [ if ($dest_slice_strand...)]
#throw away features off the end of the requested slice
if
(
$seq_region_end
<
1
||
$seq_region_start
>
$dest_slice_length
||
...
...
@@ -404,7 +489,6 @@ sub _objs_from_sth {
next
FEATURE
;
}
$slice
=
$dest_slice
;
}
...
...
modules/Bio/EnsEMBL/DBSQL/ProteinAlignFeatureAdaptor.pm
View file @
448cea7c
...
...
@@ -287,26 +287,112 @@ sub _objs_from_sth {
#
# If a destination slice was provided convert the coords
# If the dest_slice starts at 1 and is foward strand, nothing needs doing
#
if
(
$dest_slice
)
{
if
(
$dest_slice_start
!=
1
||
$dest_slice_strand
!=
1
)
{
if
(
$dest_slice_strand
==
1
)
{
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
}
else
{
my
$tmp_seq_region_start
=
$seq_region_start
;
$seq_region_start
=
$dest_slice_end
-
$seq_region_end
+
1
;
$seq_region_end
=
$dest_slice_end
-
$tmp_seq_region_start
+
1
;
$seq_region_strand
*=
-
1
;
}
}
my
$seq_region_len
=
$dest_slice
->
seq_region_length
();
if
(
$dest_slice_strand
==
1
)
{
# Positive strand
$seq_region_start
=
$seq_region_start
-
$dest_slice_start
+
1
;
$seq_region_end
=
$seq_region_end
-
$dest_slice_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
# Handle cicular chromosomes.
if
(
$seq_region_start
>
$seq_region_end
)
{
# Looking at a feature overlapping the chromsome origin.
if
(
$seq_region_end
>
$dest_slice_start
)
{
# Looking at the region in the beginning of the
# chromosome.
$seq_region_start
-=
$seq_region_len
;
}
if
(
$seq_region_end
<
0
)
{
$seq_region_end
+=
$seq_region_len
;
}
}
else
{
if
(
$dest_slice_start
>
$dest_slice_end
&&
$seq_region_end
<
0
)
{
# Looking at the region overlapping the chromosome
# origin and a feature which is at the beginning of the
# chromosome.
$seq_region_start
+=
$seq_region_len
;
$seq_region_end
+=
$seq_region_len
;
}
}
}
## end if ($dest_slice->is_circular...)
}
else
{
# Negative strand
my
$start
=
$dest_slice_end
-
$seq_region_end
+
1
;
my
$end
=
$dest_slice_end
-
$seq_region_start
+
1
;
if
(
$dest_slice
->
is_circular
())
{
if
(
$dest_slice_start
>
$dest_slice_end
)
{
# slice spans origin or replication
if
(
$seq_region_start
>=
$dest_slice_start
)
{
$end
+=
$seq_region_len
;
$start
+=
$seq_region_len
if
$seq_region_end
>
$dest_slice_start
;
}
elsif
(
$seq_region_start
<=
$dest_slice_end
)
{
# do nothing
}
elsif
(
$seq_region_end
>=
$dest_slice_start
)
{
$start
+=
$seq_region_len
;
$end
+=
$seq_region_len
;
}
elsif
(
$seq_region_end
<=
$dest_slice_end
)
{
$end
+=
$seq_region_len
if
$end
<
0
;
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
$end
+=
$seq_region_len
;
}
else
{
}
}
else
{
if
(
$seq_region_start
<=
$dest_slice_end
and
$seq_region_end
>=
$dest_slice_start
)
{
# do nothing
}
elsif
(
$seq_region_start
>
$seq_region_end
)
{
if
(
$seq_region_start
<=
$dest_slice_end
)
{
$start
-=
$seq_region_len
;