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
5356af43
Commit
5356af43
authored
20 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
load all Translations at once if immediate loading is specified - slightly faster
parent
82ccd739
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm
+5
-2
5 additions, 2 deletions
modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/TranslationAdaptor.pm
+109
-3
109 additions, 3 deletions
modules/Bio/EnsEMBL/DBSQL/TranslationAdaptor.pm
with
114 additions
and
5 deletions
modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm
+
5
−
2
View file @
5356af43
...
...
@@ -60,8 +60,6 @@ use Bio::EnsEMBL::Translation;
use
Bio::EnsEMBL::Utils::
Exception
qw( deprecate throw warning )
;
use
Time::
HiRes
qw(time)
;
@ISA
=
qw( Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor )
;
...
...
@@ -373,6 +371,11 @@ sub fetch_all_by_Slice {
}
}
my
$tla
=
$self
->
db
()
->
get_TranslationAdaptor
();
# load all of the translations at once
$tla
->
fetch_all_by_Transcript_list
(
$transcripts
);
return
$transcripts
;
}
...
...
This diff is collapsed.
Click to expand it.
modules/Bio/EnsEMBL/DBSQL/TranslationAdaptor.pm
+
109
−
3
View file @
5356af43
...
...
@@ -49,11 +49,9 @@ package Bio::EnsEMBL::DBSQL::TranslationAdaptor;
use
vars
qw(@ISA)
;
use
strict
;
use
Bio::EnsEMBL::DBSQL::
BaseFeatureAdaptor
;
use
Bio::EnsEMBL::
Translation
;
use
Bio::EnsEMBL::Utils::
Exception
qw( throw warning deprecate )
;
@ISA
=
qw( Bio::EnsEMBL::DBSQL::BaseAdaptor )
;
...
...
@@ -134,7 +132,6 @@ sub fetch_by_Transcript {
=head2 fetch_all_by_external_name
Arg [1] : string $external_id
...
...
@@ -425,6 +422,115 @@ sub fetch_by_stable_id {
}
=head2 fetch_all_by_Transcript_list
Arg [1] : reference to list of Bio::EnsEMBL::Transcripts $transcripts
The list of $transcripts to obtain Translation object for.
Example : @translations = @{$tla->fetch_all_by_Transcript_list([$t1,$t2]);
Description: Fetches all translations associated with the list of transcripts
passed to this method. The passed transcripts will also have
their translation set by this method.
Returntype : Reference to list of Bio::EnsEMBL::Translations
Exceptions : None
Caller : general
=cut
sub
fetch_all_by_Transcript_list
{
my
(
$self
,
$transcripts
)
=
@_
;
if
(
!
defined
(
$transcripts
)
||
ref
(
$transcripts
)
ne
'
ARRAY
')
{
throw
("
reference to list of Transcripts argument is required
");
}
return
[]
if
(
!
@$transcripts
);
my
%trans_hash
=
map
{
$_
->
dbID
()
=>
$_
}
@$transcripts
;
my
@id_list
=
keys
%trans_hash
;
my
@out
;
# mysql is faster and we ensure that we do not exceed the max query size by
# splitting large queries into smaller queries of 200 ids
my
$max_size
=
200
;
my
(
$tr_id
,
$tl_id
,
$start_exon_id
,
$end_exon_id
,
$seq_start
,
$seq_end
,
$stable_id
,
$version
);
my
%ex_hash
;
while
(
@id_list
)
{
my
@ids
;
if
(
@id_list
>
$max_size
)
{
@ids
=
splice
(
@id_list
,
0
,
$max_size
);
}
else
{
@ids
=
splice
(
@id_list
,
0
);
}
my
$id_str
;
if
(
@ids
>
1
)
{
$id_str
=
"
IN (
"
.
join
('
,
',
@ids
)
.
"
)
";
}
else
{
$id_str
=
"
=
"
.
$ids
[
0
];
}
my
$sth
=
$self
->
prepare
("
SELECT tl.transcript_id, tl.translation_id, tl.start_exon_id,
tl.end_exon_id, tl.seq_start, tl.seq_end,
tlsi.stable_id, tlsi.version
FROM translation tl
LEFT JOIN translation_stable_id tlsi
ON tlsi.translation_id = tl.translation_id
WHERE tl.transcript_id
$id_str
");
$sth
->
execute
();
$sth
->
bind_columns
(
\
$tr_id
,
\
$tl_id
,
\
$start_exon_id
,
\
$end_exon_id
,
\
$seq_start
,
\
$seq_end
,
\
$stable_id
,
\
$version
);
while
(
$sth
->
fetch
())
{
my
(
$start_exon
,
$end_exon
);
# this will load all the exons whenever we load the translation
# but I guess thats ok ....
my
$tr
=
$trans_hash
{
$tr_id
};
foreach
my
$exon
(
@
{
$tr
->
get_all_Exons
()})
{
if
(
!
$start_exon
&&
$exon
->
dbID
()
==
$start_exon_id
)
{
$start_exon
=
$exon
;
last
if
(
$end_exon
);
}
if
(
!
$end_exon
&&
$exon
->
dbID
()
==
$end_exon_id
)
{
$end_exon
=
$exon
;
last
if
(
$start_exon
);
}
}
unless
(
$start_exon
&&
$end_exon
)
{
throw
("
Could not find start or end exon in transcript
\n
");
}
my
$tl
=
Bio::EnsEMBL::
Translation
->
new
(
-
dbID
=>
$tl_id
,
-
adaptor
=>
$self
,
-
seq_start
=>
$seq_start
,
-
seq_end
=>
$seq_end
,
-
start_exon
=>
$start_exon
,
-
end_exon
=>
$end_exon
,
-
stable_id
=>
$stable_id
,
-
version
=>
$version
);
$tr
->
translation
(
$tl
);
push
@out
,
$tl
;
}
}
return
\
@out
;
}
=head2 fetch_all_by_DBEntry
...
...
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