Skip to content

Commit

Permalink
Merge pull request #6253 from mvdbeek/mapping_over_from_param_fixes
Browse files Browse the repository at this point in the history
Mapping over from_param fixes
  • Loading branch information
jmchilton committed Jun 4, 2018
2 parents 9cf66df + f690386 commit 2f6c184
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/dataset_collections/subcollections.py
Expand Up @@ -20,6 +20,6 @@ def _split_dataset_collection(dataset_collection, collection_type):
if child_collection.collection_type == collection_type:
split_elements.append(element)
else:
split_elements.extend(_split_dataset_collection(element.child_collection, element.child_collection.collection_type))
split_elements.extend(_split_dataset_collection(element.child_collection, collection_type))

return split_elements
12 changes: 5 additions & 7 deletions lib/galaxy/tools/parser/output_actions.py
Expand Up @@ -11,9 +11,6 @@

log = logging.getLogger(__name__)

# Attributes tool developer may want to query on dataset collections.
COLLECTION_ATTRIBUTES = ["collection_type"]


class ToolOutputActionGroup(object):
"""
Expand Down Expand Up @@ -239,13 +236,14 @@ def get_value(self, other_values):
value = value[0]
elif isinstance(value, dict):
value = value[attr_name]
elif hasattr(value, "collection") and value not in COLLECTION_ATTRIBUTES:
elif hasattr(value, "collection"):
# if this is an HDCA for instance let reverse.ext grab
# the reverse element and then continue for loop to grab
# dataset extension
value = value.collection[attr_name].element_object
elif hasattr(value, "collection") and value in COLLECTION_ATTRIBUTES:
value = getattr(value.collection, attr_name)
try:
value = value.collection[attr_name].element_object
except KeyError:
value = value.child_collection[attr_name].element_object
else:
value = getattr(value, attr_name)
options = [[str(value)]]
Expand Down
17 changes: 17 additions & 0 deletions test/api/test_tools.py
Expand Up @@ -815,6 +815,23 @@ def test_map_over_with_output_format_actions(self):
assert output1_details["file_ext"] == "txt" if (use_action == "do") else "data"
assert output2_details["file_ext"] == "txt" if (use_action == "do") else "data"

@skip_without_tool("output_action_change_format_paired")
def test_map_over_with_nested_paired_output_format_actions(self):
history_id = self.dataset_populator.new_history()
hdca_id = self.__build_nested_list(history_id)
inputs = {
"input": {'batch': True, 'values': [dict(map_over_type='paired', src="hdca", id=hdca_id)]}
}
create = self._run('output_action_change_format_paired', history_id, inputs).json()
outputs = create['outputs']
jobs = create['jobs']
implicit_collections = create['implicit_collections']
self.assertEquals(len(jobs), 2)
self.assertEquals(len(outputs), 2)
self.assertEquals(len(implicit_collections), 1)
for output in outputs:
assert output["file_ext"] == "txt"

@skip_without_tool("output_filter_with_input")
def test_map_over_with_output_filter_no_filtering(self):
with self.dataset_populator.test_history() as history_id:
Expand Down
32 changes: 32 additions & 0 deletions test/functional/tools/output_action_change_format_paired.xml
@@ -0,0 +1,32 @@
<tool id="output_action_change_format_paired" name="output_action_change_paired" version="1.0.0">
<command>
printf "1\t2\n" > out1;
</command>
<inputs>
<param type="data_collection" name="input" format="data" collection_type="paired" />
</inputs>
<outputs>
<data name="out1" from_work_dir="out1">
<actions>
<action type="format">
<option type="from_param" name="input" param_attribute="forward.ext" />
</action>
</actions>
</data>
</outputs>
<tests>
<test>
<param name="input">
<collection type="paired">
<element name="forward" value="simple_line.txt" ftype="txt" />
<element name="reverse" value="simple_line.txt" ftype="txt" />
</collection>
</param>
<output name="out1" ftype="txt">
<assert_contents>
<has_line line="1&#009;2" />
</assert_contents>
</output>
</test>
</tests>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/samples_tool_conf.xml
Expand Up @@ -106,6 +106,7 @@
<tool file="fail_writing_work_dir_file.xml" />
<tool file="tool_directory.xml" />
<tool file="output_action_change_format.xml" />
<tool file="output_action_change_format_paired.xml" />
<tool file="collection_paired_test.xml" />
<tool file="collection_paired_structured_like.xml" />
<tool file="collection_paired_conditional_structured_like.xml" />
Expand Down

0 comments on commit 2f6c184

Please sign in to comment.