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
a38ef046
Commit
a38ef046
authored
Apr 27, 2018
by
Magali Ruffier
Browse files
ENSCORESW-2399
: check perfect match before wildcard
parent
027bb9fa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
15 deletions
+31
-15
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+22
-11
modules/t/slice.t
modules/t/slice.t
+4
-4
modules/t/sliceAdaptor.t
modules/t/sliceAdaptor.t
+3
-0
modules/t/test-genome-DBs/homo_sapiens/core/seq_region_synonym.txt
.../test-genome-DBs/homo_sapiens/core/seq_region_synonym.txt
+2
-0
No files found.
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
View file @
a38ef046
...
...
@@ -302,25 +302,36 @@ sub fetch_by_region {
$syn_sql
.=
"
AND cs.version = '
"
.
$version
.
"
'
";
}
my
$syn_sql_sth
=
$self
->
prepare
(
$syn_sql
);
my
$escaped_seq_region_name
=
$seq_region_name
;
my
$escape_char
=
$self
->
dbc
->
db_handle
->
get_info
(
14
);
$escaped_seq_region_name
=~
s/([_%])/$escape_char$1/g
;
$syn_sql_sth
->
bind_param
(
1
,
"
$escaped_seq_region_name
%
",
SQL_VARCHAR
);
$syn_sql_sth
->
bind_param
(
1
,
$seq_region_name
,
SQL_VARCHAR
);
$syn_sql_sth
->
bind_param
(
2
,
$self
->
species_id
(),
SQL_INTEGER
);
$syn_sql_sth
->
execute
();
my
(
$new_name
,
$new_coord_system
,
$new_version
);
$syn_sql_sth
->
bind_columns
(
\
$new_name
,
\
$new_coord_system
,
\
$new_version
);
if
(
$syn_sql_sth
->
fetch
){
$syn_sql_sth
->
finish
;
if
((
not
defined
(
$cs
))
||
(
$cs
->
name
eq
$new_coord_system
&&
$cs
->
version
eq
$new_version
))
{
return
$self
->
fetch_by_region
(
$new_coord_system
,
$new_name
,
$start
,
$end
,
$strand
,
$new_version
,
$no_fuzz
);
}
elsif
(
$cs
->
name
ne
$new_coord_system
)
{
warning
("
Searched for a known feature on coordinate system:
"
.
$cs
->
dbID
.
"
but found it on:
"
.
$new_coord_system
.
"
\n
No result returned, consider searching without coordinate system or use toplevel.
");
return
;
}
}
else
{
# Try wildcard searching if no exact synonym was found
$syn_sql_sth
=
$self
->
prepare
(
$syn_sql
);
my
$escaped_seq_region_name
=
$seq_region_name
;
my
$escape_char
=
$self
->
dbc
->
db_handle
->
get_info
(
14
);
$escaped_seq_region_name
=~
s/([_%])/$escape_char$1/g
;
$syn_sql_sth
->
bind_param
(
1
,
"
$escaped_seq_region_name
%
",
SQL_VARCHAR
);
$syn_sql_sth
->
bind_param
(
2
,
$self
->
species_id
(),
SQL_INTEGER
);
$syn_sql_sth
->
execute
();
$syn_sql_sth
->
bind_columns
(
\
$new_name
,
\
$new_coord_system
,
\
$new_version
);
if
(
$syn_sql_sth
->
fetch
){
if
((
not
defined
(
$cs
))
||
(
$cs
->
name
eq
$new_coord_system
&&
$cs
->
version
eq
$new_version
))
{
return
$self
->
fetch_by_region
(
$new_coord_system
,
$new_name
,
$start
,
$end
,
$strand
,
$new_version
,
$no_fuzz
);
}
elsif
(
$cs
->
name
ne
$new_coord_system
)
{
warning
("
Searched for a known feature on coordinate system:
"
.
$cs
->
dbID
.
"
but found it on:
"
.
$new_coord_system
.
"
\n
No result returned, consider searching without coordinate system or use toplevel.
");
return
;
}
}
}
$syn_sql_sth
->
finish
;
...
...
modules/t/slice.t
View file @
a38ef046
...
...
@@ -474,14 +474,14 @@ $multi->restore();
$multi
->
save
("
core
",
'
seq_region_synonym
');
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
1
,
1
,
10
);
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
5
,
1
,
10
);
@alt_names
=
@
{
$slice
->
get_all_synonyms
()};
is
(
@alt_names
,
0
,
"
No altnames returned
");
$slice
->
add_synonym
("
1
ish
");
$slice
->
add_synonym
("
5
ish
");
@alt_names
=
@
{
$slice
->
get_all_synonyms
()};
...
...
@@ -492,7 +492,7 @@ foreach my $syn (@alt_names){
}
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
1
,
1
,
10
);
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
5
,
1
,
10
);
@alt_names
=
@
{
$slice
->
get_all_synonyms
()};
...
...
@@ -513,7 +513,7 @@ $multi->restore();
# test fetch_all on synonym adaptor
my
$all_synonyms
=
$syn_adap
->
fetch_all
();
is
(
@$all_synonyms
,
3
,
'
fetch_all on synonym adaptor
');
is
(
@$all_synonyms
,
5
,
'
fetch_all on synonym adaptor
');
#Test assembly exception type on HAP
...
...
modules/t/sliceAdaptor.t
View file @
a38ef046
...
...
@@ -555,6 +555,9 @@ ok($slice->seq_region_name =~ /$clone_name\.\d+/);
is
(
$chr_syn_slice
->
seq_region_name
(),
'
20
',
'
Ensuring slice is Chr20 as expected
');
$chr_syn_slice
=
$slice_adaptor
->
fetch_by_region
('
toplevel
',
'
chrx
');
is
(
$chr_syn_slice
->
seq_region_name
(),
'
X
',
'
Ensuring slice is ChrX as expected
');
$syn_slice
=
$slice_adaptor
->
fetch_by_region
('
toplevel
',
'
chr1
');
is
(
$syn_slice
->
seq_region_name
(),
'
1
',
'
Ensuring chr1 is 1, and not 10
');
}
#{
...
...
modules/t/test-genome-DBs/homo_sapiens/core/seq_region_synonym.txt
View file @
a38ef046
1 469283 alt_20 \N
2 469283 anoth_20 4200
3 469293 chrx 11000
4 469272 chr10 11000
5 469271 chr1 11000
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