Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
ec4c3d3d
Commit
ec4c3d3d
authored
Mar 04, 2014
by
Leo Gordon
Browse files
implemented searching in collection by a combination of filters
parent
df854397
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
16 deletions
+37
-16
modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm
modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm
+17
-8
modules/Bio/EnsEMBL/Hive/Utils/Collection.pm
modules/Bio/EnsEMBL/Hive/Utils/Collection.pm
+20
-8
No files found.
modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm
View file @
ec4c3d3d
...
...
@@ -486,7 +486,7 @@ sub run {
my
$resource_class
;
if
(
$resource_class
=
$all_rc_coll
->
find_one_by
('
name
',
$rc_name
)
)
{
warn
"
Attempt to re-create and potentially redef
in
e
resource_class '
$rc_name
'.
NB: This may affect already created analyses!
\n
";
warn
"
Found an already exist
in
g
resource_class '
$rc_name
'.
\n
";
}
else
{
warn
"
Creating a new resource_class '
$rc_name
'.
\n
";
$resource_class
=
Bio::EnsEMBL::Hive::
ResourceClass
->
new
(
...
...
@@ -498,13 +498,22 @@ sub run {
while
(
my
(
$meadow_type
,
$resource_param_list
)
=
each
%
{
$resource_classes_hash
->
{
$rc_name
}
}
)
{
$resource_param_list
=
[
$resource_param_list
]
unless
(
ref
(
$resource_param_list
));
# expecting either a scalar or a 2-element array
my
$resource_description
=
Bio::EnsEMBL::Hive::
ResourceDescription
->
new
(
'
resource_class
'
=>
$resource_class
,
'
meadow_type
'
=>
$meadow_type
,
'
submission_cmd_args
'
=>
$resource_param_list
->
[
0
],
'
worker_cmd_args
'
=>
$resource_param_list
->
[
1
],
);
push
@
{
$all_rd_coll
->
listref
},
$resource_description
;
my
$resource_description
;
if
(
$resource_description
=
$all_rd_coll
->
find_one_by
('
resource_class
',
$resource_class
,
'
meadow_type
',
$meadow_type
)
)
{
warn
"
Attempting to redefine an existing description for '
$rc_name
/
$meadow_type
' resource class
\n
";
$resource_description
->
submission_cmd_args
(
$resource_param_list
->
[
0
]
);
$resource_description
->
worker_cmd_args
(
$resource_param_list
->
[
1
]
);
}
else
{
warn
"
Creating a new description for '
$rc_name
/
$meadow_type
' resource class
\n
";
$resource_description
=
Bio::EnsEMBL::Hive::
ResourceDescription
->
new
(
'
resource_class
'
=>
$resource_class
,
'
meadow_type
'
=>
$meadow_type
,
'
submission_cmd_args
'
=>
$resource_param_list
->
[
0
],
'
worker_cmd_args
'
=>
$resource_param_list
->
[
1
],
);
push
@
{
$all_rd_coll
->
listref
},
$resource_description
;
}
}
}
unless
(
my
$default_rc
=
$all_rc_coll
->
find_one_by
('
name
',
'
default
')
)
{
...
...
modules/Bio/EnsEMBL/Hive/Utils/Collection.pm
View file @
ec4c3d3d
...
...
@@ -40,20 +40,32 @@ sub hashed_by_dbID {
sub
find_one_by
{
my
(
$self
,
$method
,
$filter_value
)
=
@_
;
my
@values
=
grep
{
$_
->
$method
()
eq
$filter_value
}
$self
->
list
;
return
$values
[
0
];
my
(
$self
,
%method_to_filter_value
)
=
@_
;
ELEMENT:
foreach
my
$element
(
@
{
$self
->
listref
})
{
keys
%method_to_filter_value
;
# sic! This is to "rewind" the each% operator to the beginning each time
while
(
my
(
$method
,
$filter_value
)
=
each
%method_to_filter_value
)
{
next
ELEMENT
unless
(
$element
->
$method
()
eq
$filter_value
);
}
return
$element
;
}
}
sub
find_all_by
{
my
(
$self
,
$
method
,
$
filter_value
)
=
@_
;
my
(
$self
,
%
method
_to_
filter_value
)
=
@_
;
my
@values
=
grep
{
$_
->
$method
()
eq
$filter_value
}
$self
->
list
;
my
@filtered_elements
=
();
ELEMENT:
foreach
my
$element
(
@
{
$self
->
listref
})
{
keys
%method_to_filter_value
;
# sic! This is to "rewind" the each% operator to the beginning each time
while
(
my
(
$method
,
$filter_value
)
=
each
%method_to_filter_value
)
{
next
ELEMENT
unless
(
$element
->
$method
()
eq
$filter_value
);
}
push
@filtered_elements
,
$element
;
}
return
\
@
value
s
;
return
\
@
filtered_element
s
;
}
...
...
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