Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
425cd656
Commit
425cd656
authored
Mar 13, 2014
by
Leo Gordon
Browse files
use collections in lazy-evaluation of analyses via _url references
parent
b33e1cde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
38 deletions
+66
-38
modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm
modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm
+34
-17
modules/Bio/EnsEMBL/Hive/DataflowRule.pm
modules/Bio/EnsEMBL/Hive/DataflowRule.pm
+32
-21
No files found.
modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm
View file @
425cd656
...
...
@@ -67,15 +67,34 @@ use base ( 'Bio::EnsEMBL::Hive::Storable' );
=cut
sub
condition_analysis_url
{
my
(
$self
,
$url
)
=
@_
;
if
(
$url
)
{
$self
->
{'
_condition_analysis_url
'}
=
$url
;
$self
->
{'
_condition_analysis
'}
=
undef
;
my
$self
=
shift
@_
;
if
(
@
_
)
{
$self
->
{'
_condition_analysis_url
'}
=
shift
@_
;
if
(
$self
->
{'
_condition_analysis
'}
)
{
# warn "setting condition_analysis_url() in an object that had to_analysis() defined";
$self
->
{'
_condition_analysis
'}
=
undef
;
}
}
elsif
(
!
$self
->
{'
_condition_analysis_url
'}
and
my
$condition_analysis
=
$self
->
{'
_condition_analysis
'}
)
{
# if the 'condition' and 'ctrled' share the same adaptor, then use a simple logic_name
# for the URL rather than a full network distributed URL
# FIXME: the following block could be incapsulated in Analysis->url() and NakedTable->url()
my
$ref_analysis_adaptor
=
$self
->
ctrled_analysis
&&
$self
->
ctrled_analysis
->
adaptor
;
if
(
$ref_analysis_adaptor
and
(
$ref_analysis_adaptor
==
$condition_analysis
->
adaptor
))
{
$self
->
{'
_condition_analysis_url
'}
=
$condition_analysis
->
logic_name
;
}
else
{
$self
->
{'
_condition_analysis_url
'}
=
$condition_analysis
->
url
(
$ref_analysis_adaptor
->
db
);
}
# warn "Lazy-loaded condition_analysis_url\n";
}
return
$self
->
{'
_condition_analysis_url
'};
}
=head2 condition_analysis
Arg[1] : (optional) Bio::EnsEMBL::Hive::Analysis object
...
...
@@ -94,22 +113,20 @@ sub condition_analysis {
throw
(
"
condition_analysis arg must be a [Bio::EnsEMBL::Hive::Analysis] not a [
$analysis
]
");
}
$self
->
{'
_condition_analysis
'}
=
$analysis
;
#if the 'condition' and 'ctrled' share the same adaptor, then use a simple logic_name
#for the URL rather than a full network distributed URL
if
(
$self
->
ctrled_analysis
and
(
$self
->
ctrled_analysis
->
adaptor
==
$analysis
->
adaptor
))
{
$self
->
{'
_condition_analysis_url
'}
=
$analysis
->
logic_name
;
}
else
{
$self
->
{'
_condition_analysis_url
'}
=
$analysis
->
url
;
}
}
# lazy load the analysis object if I can
if
(
!
defined
(
$self
->
{'
_condition_analysis
'})
and
defined
(
$self
->
condition_analysis_url
))
{
$analysis
=
Bio::EnsEMBL::Hive::
URLFactory
->
fetch
(
$self
->
condition_analysis_url
);
unless
(
$analysis
)
{
$analysis
=
$self
->
adaptor
->
db
->
get_AnalysisAdaptor
->
fetch_by_logic_name
(
$self
->
condition_analysis_url
);
if
(
!
$self
->
{'
_condition_analysis
'}
and
my
$condition_analysis_url
=
$self
->
condition_analysis_url
)
{
if
(
$self
->
{'
_condition_analysis
'}
=
Bio::EnsEMBL::
Hive
->
collection
('
Analysis
')
->
find_one_by
('
logic_name
',
$condition_analysis_url
)
)
{
# warn "Lazy-loading object from 'Analysis' collection\n";
}
elsif
(
my
$adaptor
=
$self
->
adaptor
)
{
# warn "Lazy-loading object from AnalysisAdaptor\n";
$self
->
{'
_condition_analysis
'}
=
$adaptor
->
db
->
get_AnalysisAdaptor
->
fetch_by_logic_name_or_url
(
$condition_analysis_url
);
}
else
{
# warn "Lazy-loading object from full URL\n";
$self
->
{'
_condition_analysis
'}
=
Bio::EnsEMBL::Hive::DBSQL::
AnalysisAdaptor
->
fetch_by_logic_name_or_url
(
$condition_analysis_url
);
}
$self
->
{'
_condition_analysis
'}
=
$analysis
;
}
return
$self
->
{'
_condition_analysis
'};
...
...
modules/Bio/EnsEMBL/Hive/DataflowRule.pm
View file @
425cd656
...
...
@@ -112,11 +112,29 @@ sub input_id_template {
=cut
sub
to_analysis_url
{
my
(
$self
,
$url
)
=
@_
;
if
(
$url
)
{
$self
->
{'
_to_analysis_url
'}
=
$url
;
$self
->
{'
_to_analysis
'}
=
undef
;
my
$self
=
shift
@_
;
if
(
@
_
)
{
$self
->
{'
_to_analysis_url
'}
=
shift
@_
;
if
(
$self
->
{'
_to_analysis
'}
)
{
# warn "setting to_analysis_url() in an object that had to_analysis() defined";
$self
->
{'
_to_analysis
'}
=
undef
;
}
}
elsif
(
!
$self
->
{'
_to_analysis_url
'}
and
my
$analysis_or_nt
=
$self
->
{'
_to_analysis
'}
)
{
# if the 'from' and 'to' share the same adaptor, then use a simple logic_name
# for the URL rather than a full network distributed URL
# FIXME: the following block could be incapsulated in Analysis->url() and NakedTable->url()
my
$ref_analysis_adaptor
=
$self
->
from_analysis
&&
$self
->
from_analysis
->
adaptor
;
if
(
$analysis_or_nt
->
can
('
logic_name
')
and
$ref_analysis_adaptor
and
(
$ref_analysis_adaptor
==
$analysis_or_nt
->
adaptor
))
{
$self
->
{'
_to_analysis_url
'}
=
$analysis_or_nt
->
logic_name
;
}
else
{
$self
->
{'
_to_analysis_url
'}
=
$analysis_or_nt
->
url
(
$ref_analysis_adaptor
->
db
);
}
# warn "Lazy-loaded to_analysis_url\n";
}
return
$self
->
{'
_to_analysis_url
'};
}
...
...
@@ -138,29 +156,22 @@ sub to_analysis {
throw
(
"
to_analysis arg must support 'url' method, '
$analysis_or_nt
' does not know how to do it
");
}
$self
->
{'
_to_analysis
'}
=
$analysis_or_nt
;
}
#if the 'from' and 'to' share the same adaptor, then use a simple logic_name
#for the URL rather than a full network distributed URL
my
$ref_rule_adaptor
=
$self
->
from_analysis
&&
$self
->
from_analysis
->
adaptor
;
# lazy load the analysis object if I can
if
(
!
$self
->
{'
_to_analysis
'}
and
my
$to_analysis_url
=
$self
->
to_analysis_url
)
{
if
(
$analysis_or_nt
->
can
('
logic_name
')
and
$ref_rule_adaptor
and
(
$ref_rule_adaptor
==
$analysis_or_nt
->
adaptor
))
{
$self
->
{'
_to_analysis_url
'}
=
$analysis_or_nt
->
logic_name
;
if
(
$self
->
{'
_to_analysis
'}
=
Bio::EnsEMBL::
Hive
->
collection
('
Analysis
')
->
find_one_by
('
logic_name
',
$to_analysis_url
)
)
{
# warn "Lazy-loading object from 'Analysis' collection\n";
}
elsif
(
my
$adaptor
=
$self
->
adaptor
)
{
# warn "Lazy-loading object from AnalysisAdaptor\n";
$self
->
{'
_to_analysis
'}
=
$adaptor
->
db
->
get_AnalysisAdaptor
->
fetch_by_logic_name_or_url
(
$to_analysis_url
);
}
else
{
$self
->
{'
_to_analysis_url
'}
=
$analysis_or_nt
->
url
(
$ref_rule_adaptor
->
db
);
# warn "Lazy-loading object from full URL\n";
$self
->
{'
_to_analysis
'}
=
Bio::EnsEMBL::Hive::DBSQL::
AnalysisAdaptor
->
fetch_by_logic_name_or_url
(
$to_analysis_url
);
}
}
# lazy load the analysis object if I can
if
(
!
defined
(
$self
->
{'
_to_analysis
'})
and
defined
(
$self
->
to_analysis_url
))
{
my
$url
=
$self
->
to_analysis_url
;
$self
->
{'
_to_analysis
'}
=
$self
->
adaptor
?
$self
->
adaptor
->
db
->
get_AnalysisAdaptor
->
fetch_by_logic_name_or_url
(
$url
)
:
Bio::EnsEMBL::Hive::DBSQL::
AnalysisAdaptor
->
fetch_by_logic_name_or_url
(
$url
)
or
die
"
Cannot fetch analysis from logic_name or url '
$url
' for dataflow rule with id='
"
.
$self
->
dbID
.
"
'
\n
";
}
return
$self
->
{'
_to_analysis
'};
}
...
...
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