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
7cf23c3b
Commit
7cf23c3b
authored
21 years ago
by
Web Admin
Browse files
Options
Downloads
Patches
Plain Diff
Ported fixes from blanch-ensembl-15-1
parent
db768d0f
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/External/BlastAdaptor.pm
+143
-1
143 additions, 1 deletion
modules/Bio/EnsEMBL/External/BlastAdaptor.pm
with
143 additions
and
1 deletion
modules/Bio/EnsEMBL/External/BlastAdaptor.pm
+
143
−
1
View file @
7cf23c3b
...
...
@@ -10,11 +10,33 @@ use vars qw(@ISA);
use
Bio::EnsEMBL::DBSQL::
BaseAdaptor
;
use
Bio::EnsEMBL::DBSQL::
DBConnection
;
#
use Bio::Search::HSP::EnsemblHSP; # This is a web module
use
Bio::Search::HSP::
EnsemblHSP
;
# This is a web module
@ISA
=
qw( Bio::EnsEMBL::DBSQL::BaseAdaptor )
;
#@ISA = qw( Bio::EnsEMBL::DBSQL::DBConnection );
#----------------------------------------------------------------------
# Define SQL
our
$SQL_HSP_STORE
=
"
INSERT INTO blast_hsp ( ticket, object, chr_name, chr_start, chr_end )
VALUES ( ? , ? , ? , ? , ? )
";
our
$SQL_HSP_UPDATE
=
"
UPDATE blast_hsp
SET object = ?,
chr_name = ?,
chr_start = ?,
chr_end = ?
WHERE hsp_id = ?
";
our
$SQL_HSP_RETRIEVE
=
"
SELECT object
FROM blast_hsp
WHERE hsp_id = ?
";
#----------------------------------------------------------------------
=head2 new
...
...
@@ -35,6 +57,110 @@ sub new {
return
$self
;
}
#----------------------------------------------------------------------
=head2 store_hsp
Arg [1] : Bio::Search::HSP::EnsemblHSP obj
Function : Stores the ensembl HSP in the database
Returntype:
Exceptions:
Caller :
Example :
=cut
sub
store_hsp
{
my
$self
=
shift
;
my
$hsp
=
shift
||
$self
->
throw
(
"
Need an HSP obj
"
);
my
$dbh
=
$self
->
db
->
db_handle
;
my
$token
=
$hsp
->
token
;
my
(
$rv
);
if
(
$token
){
my
$sth
=
$dbh
->
prepare
(
$SQL_HSP_RETRIEVE
);
$rv
=
$sth
->
execute
(
$token
)
||
$self
->
throw
(
$sth
->
errstr
);
$sth
->
finish
;
}
my
$store_obj
=
$hsp
->
_prepare_storable
;
my
$frozen
=
freeze
(
$store_obj
);
my
$ticket
=
$hsp
->
blast_ticket
;
my
$chr_name
=
'
NULL
';
my
$chr_start
=
'
NULL
';
my
$chr_end
=
'
NULL
';
if
(
my
$genomic
=
$hsp
->
genomic_hit
){
$chr_name
=
$genomic
->
seq_id
;
$chr_start
=
$genomic
->
start
;
$chr_end
=
$genomic
->
end
;
}
if
(
$rv
){
# Update
my
$sth
=
$dbh
->
prepare
(
$SQL_HSP_UPDATE
);
my
@bound
=
(
$frozen
,
$chr_name
,
$chr_start
,
$chr_end
,
$token
);
$sth
->
execute
(
@bound
)
||
$self
->
throw
(
$sth
->
errstr
);
$sth
->
finish
;
}
else
{
# Insert
my
$sth
=
$dbh
->
prepare
(
$SQL_HSP_STORE
);
my
@bound
=
(
$ticket
,
$frozen
,
$chr_name
,
$chr_start
,
$chr_end
);
$sth
->
execute
(
@bound
)
||
$self
->
throw
(
$sth
->
errstr
);
$hsp
->
token
(
$dbh
->
{
mysql_insertid
}
);
$sth
->
finish
;
}
return
$hsp
->
token
();
}
#----------------------------------------------------------------------
=head2 retrieve_hsp
Arg [1] :
Function :
Returntype:
Exceptions:
Caller :
Example :
=cut
sub
retrieve_hsp
{
my
$self
=
shift
;
my
$dbh
=
$self
->
db
->
db_handle
;
my
(
$caller
,
$token
)
=
@_
;
my
$hsp
;
my
$class
=
ref
(
$caller
)
||
$caller
;
# Is this a call on a retrievable object?
if
(
ref
(
$caller
)
){
if
(
$caller
->
retrievable
){
$hsp
=
$caller
;
$token
=
$hsp
->
token
;
}
}
else
{
$hsp
=
bless
(
{},
$caller
)
}
if
(
!
$token
){
$self
->
throw
(
"
Need an HSP token
"
)
}
my
$sth
=
$dbh
->
prepare
(
$SQL_HSP_RETRIEVE
);
my
$rv
=
$sth
->
execute
(
$token
)
||
$self
->
throw
(
$sth
->
errstr
);
if
(
$rv
<
1
){
$self
->
throw
(
"
Token
$token
not found
"
)
}
my
(
$frozen
)
=
$sth
->
fetchrow_array
;
$sth
->
finish
;
my
$stored_obj
=
thaw
(
$frozen
);
if
(
!
ref
(
$stored_obj
)
or
!
$stored_obj
->
isa
(
'
Bio::Root::Storable
'
)
){
$self
->
throw
(
"
Token
$token
returned no data
"
);
}
$stored_obj
->
{
-
retrievable
}
=
0
;
map
{
$hsp
->
{
$_
}
=
$stored_obj
->
{
$_
}
}
keys
%$stored_obj
;
# Copy hasheys
return
bless
(
$hsp
,
ref
(
$stored_obj
)
);
# Maintain class of stored obj
}
#----------------------------------------------------------------------
=head2 get_all_HSPs
...
...
@@ -85,6 +211,7 @@ AND chr_end >= ? );
my
$rv
=
$sth
->
execute
(
@binded
)
||
$self
->
throw
(
$sth
->
errstr
);
my
@hsps
=
map
{
thaw
(
$_
->
[
0
]
)
}
@
{
$sth
->
fetchall_arrayref
()};
$sth
->
finish
;
return
[
@hsps
];
}
...
...
@@ -107,11 +234,26 @@ AND chr_end >= ? );
sub
get_all_SearchFeatures
{
my
$self
=
shift
;
my
$hsps
=
$self
->
get_all_HSPs
(
@
_
);
$self
->
dynamic_use
(
ref
(
$hsps
->
[
0
]
)
);
my
@feats
=
grep
{
$_
}
map
{
$_
->
ens_genomic_align
}
@$hsps
;
return
[
@feats
];
}
#----------------------------------------------------------------------
sub
dynamic_use
{
my
(
$self
,
$classname
)
=
@_
;
my
(
$parent_namespace
,
$module
)
=
$classname
=~
/^(.*::)(.*?)$/
;
no
strict
'
refs
';
return
1
if
$parent_namespace
->
{
$module
.
'
::
'};
# return if already used
eval
"
require
$classname
";
if
(
$@
)
{
warn
"
DrawableContainer: failed to use
$classname
\n
DrawableContainer: $@
";
return
0
;
}
$classname
->
import
();
return
1
;
}
#----------------------------------------------------------------------
...
...
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