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
f267c523
Commit
f267c523
authored
Mar 15, 2012
by
Andy Yates
Browse files
Module was not parsing our more interesting toplevel locations
parent
63895fd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+10
-4
modules/t/sliceAdaptor.t
modules/t/sliceAdaptor.t
+2
-1
No files found.
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
View file @
f267c523
...
...
@@ -466,23 +466,29 @@ sub fetch_by_region {
sub
fetch_by_toplevel_location
{
my
(
$self
,
$location
,
$no_warnings
)
=
@_
;
throw
'
You must specify a location
'
if
!
$location
;
my
$regex
=
qr/^(\w+) :? (\d+)? (?:-|[.]{2})? (\d+)?$/
xms
;
#cleanup any nomenclature like 1_000 or 1 000 or 1,000
my
$number_seps_regex
=
qr/\s+|,|_/
;
my
$number
=
qr/[0-9,_ E]+/
xms
;
my
$regex
=
qr/^(\w+) \s* :? \s* ($number)? (?:-|[.]{2})? ($number)?$/
xms
;
if
(
my
(
$seq_region_name
,
$start
,
$end
)
=
$location
=~
$regex
)
{
if
(
defined
$start
)
{
$start
=~
s/$number_seps_regex//g
;
if
(
$start
<
1
)
{
warning
"
Start was less than 1 (
${start}
) which is not allowed. Resetting to 1
"
if
!
$no_warnings
;
$start
=
1
;
}
$start
=~
s/$number_seps_regex//g
;
#cleanup any nomenclature like 1_000 or 1 000 or 1,000
}
if
(
defined
$end
)
{
$end
=~
s/$number_seps_regex//g
;
if
(
$end
<
1
)
{
throw
"
Cannot request negative or 0 end indexes through this interface. Given
$end
but expected something greater than 0
";
}
$end
=~
s/$number_seps_regex//g
;
#cleanup any nomenclature like 1_000 or 1 000 or 1,000
}
if
(
defined
$start
&&
defined
$end
&&
$start
>
$end
)
{
throw
"
Cannot request a slice whose start is greater than its end. Start:
$start
. End:
$end
";
}
my
$coord_system_name
=
'
toplevel
';
...
...
modules/t/sliceAdaptor.t
View file @
f267c523
...
...
@@ -466,6 +466,7 @@ test_toplevel_location('1: 1', 'chromosome', '1', 1, 246874334);
test_toplevel_location
('
1: -10
',
'
chromosome
',
'
1
',
1
,
10
);
test_toplevel_location
('
1: 100
',
'
chromosome
',
'
1
',
100
,
246874334
);
test_toplevel_location
('
1:100..2_000_000_000
',
'
chromosome
',
'
1
',
100
,
246874334
);
test_toplevel_location
('
1:100..2E9
',
'
chromosome
',
'
1
',
100
,
246874334
);
dies_ok
{
$slice_adaptor
->
fetch_by_toplevel_location
();
}
'
Checking calling without a location fails
';
dies_ok
{
$slice_adaptor
->
fetch_by_toplevel_location
('',
1
);
}
'
Checking calling with a blank location fails
';
...
...
@@ -476,7 +477,7 @@ ok(!defined $slice_adaptor->fetch_by_toplevel_location('1:-100--50', 1), 'Checki
sub
test_toplevel_location
{
my
(
$location
,
$cs_name
,
$seq_region_name
,
$start
,
$end
)
=
@_
;
my
$incoming_slice
=
$slice_adaptor
->
fetch_by_toplevel_location
(
$location
,
1
);
my
$def
=
ok
(
defined
$incoming_slice
,
"
Slice is defined for
$location
");
my
$def
=
ok
(
defined
$incoming_slice
,
"
We expect a defined Slice for location:
$location
");
SKIP
:
{
skip
'
Incoming slice is undefined
',
5
if
!
$def
;
is
(
$incoming_slice
->
coord_system_name
(),
$cs_name
,
"
Checking coord system name for
$location
");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment