Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl
Commits
f55c6b76
Commit
f55c6b76
authored
Apr 15, 2013
by
Andy Yates
Browse files
Registry edge case to deal with mis-spellings which can be common place for Ensembl beginners
parent
259897f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
modules/Bio/EnsEMBL/Registry.pm
modules/Bio/EnsEMBL/Registry.pm
+15
-0
modules/t/registry.t
modules/t/registry.t
+19
-0
No files found.
modules/Bio/EnsEMBL/Registry.pm
View file @
f55c6b76
...
...
@@ -1570,6 +1570,21 @@ sub load_registry_from_db {
$species_suffix
=
"";
}
if
(
!
defined
$db_version
)
{
# Do checking for the -DB_VERSION flag which can be mis-spelt. Regex assembled using:
# perl -MRegexp::Assemble -e '$r=Regexp::Assemble->new(); $r->add($_) for ("-dbversion","-version","-verion","-verison"); print $r->re, "\n";'
my
$db_version_flag_re
=
qr/(?-xism:-(?:ver(?:is?|si)|dbversi)on)/
xism
;
for
(
my
$i
=
0
;
$i
<=
@args
;
$i
=
$i
+
2
)
{
if
(
$args
[
$i
]
=~
$db_version_flag_re
)
{
my
$msg
=
sprintf
(
q{Detected no -DB_VERSION flag but found '%s'; assuming a mis-spelling. Please fix}
,
$args
[
$i
]);
warning
(
$msg
);
$db_version
=
$args
[
$i
+
1
];
last
;
}
}
}
my
$ontology_db
;
my
$ontology_version
;
...
...
modules/t/registry.t
View file @
f55c6b76
...
...
@@ -6,6 +6,7 @@ use Test::More;
use
File::
Temp
qw/tempfile/
;
use
Bio::EnsEMBL::
Registry
;
use
Bio::EnsEMBL::Test::
MultiTestDB
;
use
Bio::EnsEMBL::Test::
TestUtils
qw/warns_like/
;
my
$threads
;
if
(
$Config
{
useithreads
}
&&
!
$ENV
{
ENS_FORCE_NOTHREADS
})
{
...
...
@@ -40,6 +41,7 @@ my $registry_template = <<'TMPL';
1;
TMPL
#Testing threaded re-loads of the registry
{
my
(
$fh
,
$filename
)
=
tempfile
();
my
$final
=
sprintf
(
$registry_template
,
$dbc
->
host
(),
$dbc
->
port
(),
$dbc
->
username
(),
$dbc
->
password
(),
$dbc
->
dbname
());
...
...
@@ -78,4 +80,21 @@ TMPL
}
}
#Testing auto-correction of arguments for common 1st line methods
{
my
$tester
=
sub
{
my
(
$misspelling
)
=
@_
;
my
%params
=
(
-
HOST
=>
$dbc
->
host
(),
-
PORT
=>
$dbc
->
port
(),
-
USER
=>
$dbc
->
username
());
$params
{
-
PASS
}
=
$dbc
->
password
()
if
$dbc
->
password
();
my
$db_version
=
-
2
;
$params
{"
-
${misspelling}
"}
=
$db_version
;
warns_like
(
sub
{
$reg
->
load_registry_from_db
(
%params
)
},
qr/${misspelling}.+mis-spelling/
,
"
Testing that param -
${misspelling}
succeeded
");
return
;
};
$tester
->
('
dbversion
');
$tester
->
('
version
');
$tester
->
('
verion
');
$tester
->
('
verison
');
}
done_testing
();
\ No newline at end of file
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