Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
3aea6318
Commit
3aea6318
authored
13 years ago
by
Andy Yates
Browse files
Options
Downloads
Patches
Plain Diff
Modifications to ensure that user input is not mis-interpreted as wanting whole chromosomes.
parent
2d8cf48d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+6
-1
6 additions, 1 deletion
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
modules/t/sliceAdaptor.t
+9
-1
9 additions, 1 deletion
modules/t/sliceAdaptor.t
with
15 additions
and
2 deletions
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+
6
−
1
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
);
...
...
This diff is collapsed.
Click to expand it.
modules/t/sliceAdaptor.t
+
9
−
1
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
');
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment