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
016d40c8
Commit
016d40c8
authored
Aug 12, 2004
by
Graham McVicker
Browse files
make use of meta_coord.max_length to further optomize generated feature queries
parent
552faa71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
3 deletions
+56
-3
modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm
+22
-0
modules/Bio/EnsEMBL/DBSQL/MetaCoordContainer.pm
modules/Bio/EnsEMBL/DBSQL/MetaCoordContainer.pm
+34
-3
No files found.
modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm
View file @
016d40c8
...
...
@@ -491,6 +491,10 @@ sub _slice_fetch {
if
(
$feat_cs
->
equals
(
$slice_cs
))
{
# no mapping is required if this is the same coord system
my
$max_len
=
$mcc
->
fetch_max_length_by_CoordSystem_feature_type
(
$feat_cs
,
$tab_name
);
my
$constraint
=
$orig_constraint
;
my
$sr_id
=
$self
->
db
->
get_SliceAdaptor
->
get_seq_region_id
(
$slice
);
...
...
@@ -499,6 +503,13 @@ sub _slice_fetch {
"
${tab_syn}
.seq_region_id =
$sr_id
AND
"
.
"
${tab_syn}
.seq_region_start <=
$slice_end
AND
"
.
"
${tab_syn}
.seq_region_end >=
$slice_start
";
if
(
$max_len
)
{
my
$min_start
=
$slice_start
-
$max_len
;
$constraint
.=
"
AND
${tab_syn}
.seq_region_start >=
$min_start
";
}
my
$fs
=
$self
->
generic_fetch
(
$constraint
,
undef
,
$slice
);
# features may still have to have coordinates made relative to slice
...
...
@@ -540,6 +551,10 @@ sub _slice_fetch {
}
else
{
# do multiple split queries using start / end constraints
my
$max_len
=
$mcc
->
fetch_max_length_by_CoordSystem_feature_type
(
$feat_cs
,
$tab_name
);
my
$len
=
@coords
;
for
(
my
$i
=
0
;
$i
<
$len
;
$i
++
)
{
my
$constraint
=
$orig_constraint
;
...
...
@@ -548,6 +563,13 @@ sub _slice_fetch {
"
${tab_syn}
.seq_region_id =
"
.
$ids
[
$i
]
.
"
AND
"
.
"
${tab_syn}
.seq_region_start <=
"
.
$coords
[
$i
]
->
end
()
.
"
AND
"
.
"
${tab_syn}
.seq_region_end >=
"
.
$coords
[
$i
]
->
start
();
if
(
$max_len
)
{
my
$min_start
=
$coords
[
$i
]
->
start
()
-
$max_len
;
$constraint
.=
"
AND
${tab_syn}
.seq_region_start >=
$min_start
";
}
my
$fs
=
$self
->
generic_fetch
(
$constraint
,
$mapper
,
$slice
);
$fs
=
_remap
(
$fs
,
$mapper
,
$slice
);
...
...
modules/Bio/EnsEMBL/DBSQL/MetaCoordContainer.pm
View file @
016d40c8
...
...
@@ -24,12 +24,13 @@ sub new {
# and cache them
#
my
$sth
=
$self
->
prepare
('
SELECT table_name, coord_system_id FROM meta_coord
');
('
SELECT table_name, coord_system_id
, max_length
FROM meta_coord
');
$sth
->
execute
();
while
(
my
(
$table_name
,
$cs_id
)
=
$sth
->
fetchrow_array
())
{
while
(
my
(
$table_name
,
$cs_id
,
$max_length
)
=
$sth
->
fetchrow_array
())
{
$self
->
{'
_feature_cache
'}
->
{
lc
(
$table_name
)}
||=
[]
;
push
@
{
$self
->
{'
_feature_cache
'}
->
{
lc
(
$table_name
)}},
$cs_id
;
$self
->
{'
_max_len_cache
'}
->
{
$cs_id
}
->
{
lc
(
$table_name
)}
=
$max_length
;
}
$sth
->
finish
();
...
...
@@ -49,7 +50,7 @@ sub new {
the API to perform queries to these tables and to ensure that
features are only stored in appropriate coordinate systems.
Returntype : listref of Bio::EnsEMBL::CoordSystem objects
Exceptions :
none
Exceptions :
throw if name argument not provided
Caller : BaseFeatureAdaptor
=cut
...
...
@@ -84,6 +85,36 @@ sub fetch_all_CoordSystems_by_feature_type {
=head2 fetch_max_length_by_CoordSystem_feature_type
Arg [1] : Bio::EnsEMBL::CoordSystem $cs
Arg [2] : string $table
Example : $max_len =
$mcc->fetch_max_length_by_CoordSystem_feature_type($cs,'gene');
Description: Returns the maximum length of features of a given type in
a given coordinate system.
Returntype : int or undef
Exceptions : throw on incorrect argument
Caller : BaseFeatureAdaptor
=cut
sub
fetch_max_length_by_CoordSystem_feature_type
{
my
$self
=
shift
;
my
$cs
=
shift
;
my
$table
=
shift
;
if
(
!
ref
(
$cs
)
||
!
$cs
->
isa
('
Bio::EnsEMBL::CoordSystem
'))
{
throw
('
Bio::EnsEMBL::CoordSystem argument expected
');
}
throw
("
Table name argument is required
")
unless
$table
;
return
$self
->
{'
_max_len_cache
'}
->
{
$cs
->
dbID
()}
->
{
lc
(
$table
)};
}
=head2 add_feature_type
...
...
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