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
fe7dd406
Commit
fe7dd406
authored
21 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
more clever caching to fix a speed problem when fetching a lot of non-duplicate slices
parent
d4f36818
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+43
-21
43 additions, 21 deletions
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
with
43 additions
and
21 deletions
modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+
43
−
21
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
;
}
#####################################
...
...
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