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
fe7dd406
Commit
fe7dd406
authored
Mar 18, 2004
by
Graham McVicker
Browse files
more clever caching to fix a speed problem when fetching a lot of non-duplicate slices
parent
d4f36818
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
21 deletions
+43
-21
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+43
-21
No files found.
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
View file @
fe7dd406
...
...
@@ -626,15 +626,25 @@ sub fetch_all {
-
ADAPTOR
=>
$self
);
if
(
!
defined
(
$include_duplicates
)
or
!
$include_duplicates
){
#do not include duplicates
my
@dup
=
@
{
$self
->
fetch_normalized_slice_projection
(
$slice
)};
foreach
my
$dup_test
(
@dup
){
if
(
$dup_test
->
[
2
]
->
get_seq_region_id
==
$slice
->
get_seq_region_id
){
push
@out
,
$dup_test
->
[
2
];
# test if this slice *could* have a duplicate (exception) region
$self
->
_build_exception_cache
()
if
(
!
exists
$self
->
{'
asm_exc_cache
'});
if
(
exists
$self
->
{
asm_exc_cache
}
->
{
$seq_region_id
})
{
# Dereference symlinked assembly regions. Take out
# any regions which are symlinked because these are duplicates
my
@projection
=
@
{
$self
->
fetch_normalized_slice_projection
(
$slice
)};
foreach
my
$segment
(
@projection
)
{
if
(
$segment
->
[
2
]
->
seq_region_name
()
eq
$slice
->
seq_region_name
()
&&
$segment
->
[
2
]
->
coord_system
->
equals
(
$slice
->
coord_system
))
{
push
@out
,
$segment
->
[
2
];
}
}
}
else
{
# no duplicate regions
push
@out
,
$slice
;
}
}
else
{
}
else
{
# we want duplicates anyway so do not do any checks
push
@out
,
$slice
;
}
}
...
...
@@ -1005,21 +1015,11 @@ sub fetch_normalized_slice_projection {
my
$slice_seq_region_id
=
$self
->
get_seq_region_id
(
$slice
);
my
$result
=
$self
->
{'
asm_exc_cache
'}
->
{
$slice_seq_region_id
}
;
$self
->
_build_exception_cache
()
if
(
!
exists
(
$self
->
{'
asm_exc_cache
'}))
;
if
(
!
defined
(
$result
))
{
my
$sql
=
"
SELECT seq_region_id, seq_region_start, seq_region_end,
exc_type, exc_seq_region_id, exc_seq_region_start,
exc_seq_region_end
FROM assembly_exception
WHERE seq_region_id = ?
";
my
$result
=
$self
->
{'
asm_exc_cache
'}
->
{
$slice_seq_region_id
};
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
(
$slice_seq_region_id
);
$result
=
$sth
->
fetchall_arrayref
();
$self
->
{'
asm_exc_cache
'}
->
{
$slice_seq_region_id
}
=
$result
;
}
$result
||=
[]
;
my
(
@haps
,
@pars
);
...
...
@@ -1276,9 +1276,31 @@ sub prepare {
return
$self
->
db
()
->
dnadb
()
->
prepare
(
$sql
);
}
sub
_build_exception_cache
{
my
$self
=
shift
;
# build up a cache of the entire assembly exception table
# it should be small anyway
my
$sth
=
$self
->
prepare
("
SELECT seq_region_id, seq_region_start, seq_region_end,
exc_type, exc_seq_region_id, exc_seq_region_start,
exc_seq_region_end
FROM assembly_exception
");
$sth
->
execute
();
my
%hash
;
$self
->
{'
asm_exc_cache
'}
=
\
%hash
;
my
$row
;
while
(
$row
=
$sth
->
fetchrow_arrayref
())
{
my
@result
=
@$row
;
$hash
{
$result
[
0
]}
||=
[]
;
push
(
@
{
$hash
{
$result
[
0
]}},
\
@result
);
}
return
;
}
#####################################
...
...
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