From a1b72d5bf02501cc764257f630bc64fd22d40092 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 16 Sep 2014 11:57:48 -0400 Subject: [PATCH] Redo API for subcollection mapping steps in tools. Like the reductions - was previously constrained by sequeezing these values into simple strings - now the tool form will target the API I think this expanded version is a little more straight-forward (though verbose). Adds consistency with rest of the tool form API changes. --- lib/galaxy/tools/parameters/meta.py | 3 ++- test/api/test_tools.py | 40 +++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/parameters/meta.py b/lib/galaxy/tools/parameters/meta.py index c8790bfbcd3..3c320820105 100644 --- a/lib/galaxy/tools/parameters/meta.py +++ b/lib/galaxy/tools/parameters/meta.py @@ -106,9 +106,10 @@ def __expand_collection_parameter( trans, input_key, incoming_val, collections_t if src != "hdca": raise exceptions.ToolMetaParameterException( "Invalid dataset collection source type %s" % src ) encoded_hdc_id = incoming_val[ "id" ] + subcollection_type = incoming_val.get( 'map_over_type', None ) except TypeError: encoded_hdc_id = incoming_val - subcollection_type = None + subcollection_type = None hdc_id = trans.app.security.decode_id( encoded_hdc_id ) hdc = trans.sa_session.query( model.HistoryDatasetCollectionAssociation ).get( hdc_id ) collections_to_match.add( input_key, hdc, subcollection_type=subcollection_type ) diff --git a/test/api/test_tools.py b/test/api/test_tools.py index 99b52996f62..64800c9e45c 100644 --- a/test/api/test_tools.py +++ b/test/api/test_tools.py @@ -492,12 +492,27 @@ class ToolsTestCase( api.ApiTestCase ): assert len( output2_content.strip().split("\n") ) == 3, output2_content @skip_without_tool( "collection_paired_test" ) - def test_subcollection_mapping( self ): + def test_subcollection_mapping_legacy( self ): history_id = self.dataset_populator.new_history() hdca_list_id = self.__build_nested_list( history_id ) inputs = { "f1|__collection_multirun__": "%s|paired" % hdca_list_id } + self._check_simple_subcollection_mapping( history_id, inputs ) + + @skip_without_tool( "collection_paired_test" ) + def test_subcollection_mapping( self ): + history_id = self.dataset_populator.new_history() + hdca_list_id = self.__build_nested_list( history_id ) + inputs = { + "f1": { + 'batch': True, + 'values': [ { 'src': 'hdca', 'map_over_type': 'paired', 'id': hdca_list_id }], + } + } + self._check_simple_subcollection_mapping( history_id, inputs ) + + def _check_simple_subcollection_mapping( self, history_id, inputs ): # Following wait not really needed - just getting so many database # locked errors with sqlite. self.dataset_populator.wait_for_history( history_id, assert_ok=True ) @@ -511,7 +526,7 @@ class ToolsTestCase( api.ApiTestCase ): assert output2_content.strip() == "789\n0ab", output2_content @skip_without_tool( "collection_mixed_param" ) - def test_combined_mapping_and_subcollection_mapping( self ): + def test_combined_mapping_and_subcollection_mapping_legacy( self ): history_id = self.dataset_populator.new_history() nested_list_id = self.__build_nested_list( history_id ) create_response = self.dataset_collection_populator.create_list_in_history( history_id, contents=["xxx", "yyy"] ) @@ -520,6 +535,27 @@ class ToolsTestCase( api.ApiTestCase ): "f1|__collection_multirun__": "%s|paired" % nested_list_id, "f2|__collection_multirun__": list_id, } + self._check_combined_mapping_and_subcollection_mapping( history_id, inputs ) + + @skip_without_tool( "collection_mixed_param" ) + def test_combined_mapping_and_subcollection_mapping( self ): + history_id = self.dataset_populator.new_history() + nested_list_id = self.__build_nested_list( history_id ) + create_response = self.dataset_collection_populator.create_list_in_history( history_id, contents=["xxx", "yyy"] ) + list_id = create_response.json()[ "id" ] + inputs = { + "f1": { + 'batch': True, + 'values': [ { 'src': 'hdca', 'map_over_type': 'paired', 'id': nested_list_id }], + }, + "f2": { + 'batch': True, + 'values': [ { 'src': 'hdca', 'id': list_id }], + }, + } + self._check_combined_mapping_and_subcollection_mapping( history_id, inputs ) + + def _check_combined_mapping_and_subcollection_mapping( self, history_id, inputs ): self.dataset_populator.wait_for_history( history_id, assert_ok=True ) outputs = self._run_and_get_outputs( "collection_mixed_param", history_id, inputs ) assert len( outputs ), 2