diff --git a/lib/galaxy/managers/collections.py b/lib/galaxy/managers/collections.py
index 24dbdff1c13..aadaf226439 100644
--- a/lib/galaxy/managers/collections.py
+++ b/lib/galaxy/managers/collections.py
@@ -126,7 +126,13 @@ class DatasetCollectionManager( object ):
if collection_type_description.has_subcollections( ):
# Nested collection - recursively create collections and update identifiers.
self.__recursively_create_collections( trans, element_identifiers )
- elements = self.__load_elements( trans, element_identifiers )
+ new_collection = False
+ for element_identifier in element_identifiers:
+ if element_identifier.get("src") == "new_collection" and element_identifier.get('collection_type') == '':
+ new_collection = True
+ elements = self.__load_elements(trans, element_identifier['element_identifiers'])
+ if not new_collection:
+ elements = self.__load_elements( trans, element_identifiers )
# else if elements is set, it better be an ordered dict!
if elements is not self.ELEMENTS_UNINITIALIZED:
diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py
index e4ff04a46c2..ddefd7ffe52 100644
--- a/lib/galaxy/tools/actions/__init__.py
+++ b/lib/galaxy/tools/actions/__init__.py
@@ -770,7 +770,15 @@ def determine_output_format(output, parameter_context, input_datasets, input_dat
if collection_name in input_dataset_collections:
try:
input_collection = input_dataset_collections[collection_name][0][0]
- input_dataset = input_collection.collection[element_index].element_object
+ input_collection_collection = input_collection.collection
+ try:
+ input_element = input_collection_collection[element_index]
+ except KeyError:
+ for element in input_collection_collection.dataset_elements:
+ if element.element_identifier == element_index:
+ input_element = element
+ break
+ input_dataset = input_element.element_object
input_extension = input_dataset.ext
ext = input_extension
except Exception as e:
diff --git a/test/api/test_tools.py b/test/api/test_tools.py
index 2db9ed5e2c8..c5db4f6a1d7 100644
--- a/test/api/test_tools.py
+++ b/test/api/test_tools.py
@@ -846,6 +846,24 @@ class ToolsTestCase( api.ApiTestCase ):
}
self._check_simple_cat1_over_nested_collections( history_id, inputs )
+ @skip_without_tool( "paired_collection_map_over_structured_like" )
+ def test_paired_input_map_over_nested_collections( self ):
+ history_id = self.dataset_populator.new_history()
+ hdca_id = self.__build_nested_list( history_id )
+ inputs = {
+ "input1": { 'batch': True, 'values': [ dict( map_over_type='paired', src="hdca", id=hdca_id ) ] },
+ }
+ self.dataset_populator.wait_for_history( history_id, assert_ok=True )
+ create = self._run( "paired_collection_map_over_structured_like", history_id, inputs, assert_ok=True )
+ jobs = create[ 'jobs' ]
+ implicit_collections = create[ 'implicit_collections' ]
+ self.assertEquals( len( jobs ), 2 )
+ self.assertEquals( len( implicit_collections ), 1 )
+ implicit_collection = implicit_collections[ 0 ]
+ assert implicit_collection[ "collection_type" ] == "list:paired", implicit_collection
+ outer_elements = implicit_collection[ "elements" ]
+ assert len( outer_elements ) == 2
+
def _check_simple_cat1_over_nested_collections( self, history_id, inputs ):
create = self._run_cat1( history_id, inputs=inputs, assert_ok=True )
outputs = create[ 'outputs' ]
diff --git a/test/functional/tools/paired_collection_map_over_structured_like.xml b/test/functional/tools/paired_collection_map_over_structured_like.xml
new file mode 100644
index 00000000000..cbd03f31df3
--- /dev/null
+++ b/test/functional/tools/paired_collection_map_over_structured_like.xml
@@ -0,0 +1,32 @@
+
+
+
+ cat '${input1.forward}' > '${list_output.forward}';
+ cat '${input1.reverse}' > '${list_output.reverse}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml
index 62ccfb20b5f..6940f128af5 100644
--- a/test/functional/tools/samples_tool_conf.xml
+++ b/test/functional/tools/samples_tool_conf.xml
@@ -78,6 +78,7 @@
+