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
3aea6318
Commit
3aea6318
authored
Sep 21, 2011
by
Andy Yates
Browse files
Modifications to ensure that user input is not mis-interpreted as wanting whole chromosomes.
parent
2d8cf48d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+6
-1
modules/t/sliceAdaptor.t
modules/t/sliceAdaptor.t
+9
-1
No files found.
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
View file @
3aea6318
...
...
@@ -439,11 +439,15 @@ sub fetch_by_region {
=head2 fetch_by_toplevel_location
Arg [1] : string $location
Ensembl formatted location. Can be a format like
C<name:start-end>, C<name:start..end>, C<name:start> and
C<name>.
Example : my $slice = $sa->fetch_by_toplevel_location('X:1-10000')
Description : Converts an Ensembl location/region into the sequence region
name, start and end and passes them onto C<fetch_by_region()>.
The code assumes that the required slice is on the top level
coordinate system.
coordinate system. The code assumes that location formatting
is not perfect and will perform basic cleanup before parsing.
Returntype : Bio::EnsEMBL::Slice
Exceptions : If $location is false otherwise see C<fetch_by_region()>
Caller : General
...
...
@@ -455,6 +459,7 @@ sub fetch_by_toplevel_location {
my
(
$self
,
$location
)
=
@_
;
throw
'
You must specify a location
'
if
!
$location
;
my
$regex
=
qr/^(\w+) :? (\d+)? (?:-|[.]{2})? (\d+)?/
xms
;
$location
=~
s/\s+|,//g
;
my
(
$seq_region_name
,
$start
,
$end
)
=
$location
=~
$regex
;
my
$coord_system_name
=
'
toplevel
';
return
$self
->
fetch_by_region
(
$coord_system_name
,
$seq_region_name
,
$start
,
$end
,
undef
,
undef
,
0
);
...
...
modules/t/sliceAdaptor.t
View file @
3aea6318
use
strict
;
use
warnings
;
use
Test::
More
tests
=>
1
2
9
;
use
Test::
More
tests
=>
1
5
9
;
use
Bio::EnsEMBL::Test::
MultiTestDB
;
use
Bio::EnsEMBL::DBSQL::
SliceAdaptor
;
...
...
@@ -458,6 +458,14 @@ test_toplevel_location('1:..10', 'chromosome', '1', 1, 10);
test_toplevel_location
('
1:100
',
'
chromosome
',
'
1
',
100
,
246874334
);
test_toplevel_location
('
1:
',
'
chromosome
',
'
1
',
1
,
246874334
);
test_toplevel_location
('
1
',
'
chromosome
',
'
1
',
1
,
246874334
);
test_toplevel_location
('
1: 1-1,000
',
'
chromosome
',
'
1
',
1
,
1000
);
test_toplevel_location
('
1: 1-1,000,000
',
'
chromosome
',
'
1
',
1
,
1000000
);
test_toplevel_location
('
1: 1-1 000 000
',
'
chromosome
',
'
1
',
1
,
1000000
);
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
);
dies_ok
{
$slice_adaptor
->
fetch_by_toplevel_location
();
}
'
Checking calling without a location fails
';
dies_ok
{
$slice_adaptor
->
fetch_by_toplevel_location
('');
}
'
Checking calling with a blank location fails
';
ok
(
!
defined
$slice_adaptor
->
fetch_by_toplevel_location
('
wibble
'),
'
Checking with a bogus region returns undef
');
...
...
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