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
b6142799
Commit
b6142799
authored
21 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
added fetch_by_db_accession method
parent
26443da4
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/DBEntryAdaptor.pm
+91
-15
91 additions, 15 deletions
modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm
with
91 additions
and
15 deletions
modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm
+
91
−
15
View file @
b6142799
...
...
@@ -9,7 +9,7 @@
=head1 NAME
Bio::EnsEMBL::DBSQL::DBEntryAdaptor -
Bio::EnsEMBL::DBSQL::DBEntryAdaptor -
MySQL Database queries to load and store external object references.
=head1 SYNOPSIS
...
...
@@ -73,35 +73,111 @@ sub fetch_by_dbID {
$sth
->
execute
(
$dbID
);
my
$exDB
;
my
%duplicate
;
while
(
my
$arrayref
=
$sth
->
fetchrow_arrayref
()){
my
(
$refID
,
$dbprimaryId
,
$displayid
,
$version
,
$desc
,
$dbname
,
$release
,
$synonym
)
=
@$arrayref
;
return
undef
if
(
!
defined
$refID
);
$release
,
$synonym
)
=
@$arrayref
;
unless
(
$duplicate
{
$refID
}){
$duplicate
{
$refID
}
=
1
;
if
(
!
$exDB
)
{
$exDB
=
Bio::EnsEMBL::
DBEntry
->
new
(
-
adaptor
=>
$self
,
-
dbID
=>
$dbID
,
-
primary_id
=>
$dbprimaryId
,
-
display_id
=>
$displayid
,
-
version
=>
$version
,
-
release
=>
$release
,
-
dbname
=>
$dbname
);
$exDB
->
description
(
$desc
)
if
(
$desc
);
}
$exDB
->
add_synonym
(
$synonym
)
if
(
$synonym
);
}
$sth
->
finish
();
return
$exDB
;
}
=head2 fetch_by_db_accession
Arg [1] : string $dbname - The name of the database which the provided
accession is for.
Arg [2] : string $accession - The accesion of the external reference to
retrieve.
Example : my $xref = $dbea->fetch_by_db_accession('Interpro','IPR003439');
print $xref->description(), "\n" if($xref);
Description: Retrieves a DBEntry (xref) via the name of the database it is
from and its primary accession in that database. Undef is
returned if the xref cannot be found in the database.
Returntype : Bio::EnsEMBL::DBSQL::DBEntry
Exceptions : thrown if arguments are incorrect
Caller : general, domainview
=cut
sub
fetch_by_db_accession
{
my
$self
=
shift
;
my
$dbname
=
shift
;
my
$accession
=
shift
;
my
$sth
=
$self
->
prepare
(
"
SELECT xref.xref_id, xref.dbprimary_acc, xref.display_label,
xref.version, xref.description,
exDB.db_name, exDB.release, es.synonym
FROM xref, external_db exDB
LEFT JOIN external_synonym es on es.xref_id = xref.xref_id
WHERE xref.dbprimary_acc = ?
AND exDB.db_name = ?
AND xref.external_db_id = exDB.external_db_id
");
$sth
->
execute
(
$accession
,
$dbname
);
if
(
!
$sth
->
rows
()
&&
lc
(
$dbname
)
eq
'
interpro
')
{
#
# This is a minor hack that means that results still come back even
# when a mistake was made and no interpro accessions were loaded into
# the xref table. This has happened in the past and had the result of
# breaking domainview
#
$sth
->
finish
();
$sth
=
$self
->
prepare
("
SELECT null, i.interpro_ac, i.id, null, null, 'Interpro', null, null
"
.
"
FROM interpro i where i.interpro_ac = ?
");
$sth
->
execute
(
$accession
);
}
my
$exDB
;
while
(
my
$arrayref
=
$sth
->
fetchrow_arrayref
()){
my
(
$dbID
,
$dbprimaryId
,
$displayid
,
$version
,
$desc
,
$dbname
,
$release
,
$synonym
)
=
@$arrayref
;
if
(
!
$exDB
)
{
$exDB
=
Bio::EnsEMBL::
DBEntry
->
new
(
-
adaptor
=>
$self
,
-
dbID
=>
$dbID
,
-
primary_id
=>
$dbprimaryId
,
-
display_id
=>
$displayid
,
-
version
=>
$version
,
-
release
=>
$release
,
-
dbname
=>
$dbname
);
(
-
adaptor
=>
$self
,
-
dbID
=>
$dbID
,
-
primary_id
=>
$dbprimaryId
,
-
display_id
=>
$displayid
,
-
version
=>
$version
,
-
release
=>
$release
,
-
dbname
=>
$dbname
);
$exDB
->
description
(
$desc
)
if
(
$desc
);
}
# end duplicate
}
$exDB
->
add_synonym
(
$synonym
)
if
(
$synonym
);
}
# end while
}
$sth
->
finish
();
return
$exDB
;
}
=head2 store
Arg [1] : Bio::EnsEMBL::DBEntry $exObj
...
...
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