From c70cc95128394538e6b2e259edec70f37705b806 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 25 Dec 2014 12:24:23 -0500 Subject: [PATCH] Expose datatype converter information via datatype API. With test case. --- lib/galaxy/webapps/galaxy/api/datatypes.py | 13 +++++++++++++ lib/galaxy/webapps/galaxy/buildapp.py | 2 +- test/api/test_datatypes.py | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/webapps/galaxy/api/datatypes.py b/lib/galaxy/webapps/galaxy/api/datatypes.py index e1846fcc7cd..486111a4907 100644 --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -101,6 +101,19 @@ class DatatypesController( BaseAPIController ): else: raise + @expose_api_anonymous + def converters( self, trans, **kwd ): + converters = [] + for (source_type, targets) in self._datatypes_registry.datatype_converters.iteritems(): + for target_type in targets: + converters.append( { + 'source': source_type, + 'target': target_type, + 'tool_id': targets[ target_type ].id, + } ) + + return converters + @property def _datatypes_registry( self ): return self.app.datatypes_registry diff --git a/lib/galaxy/webapps/galaxy/buildapp.py b/lib/galaxy/webapps/galaxy/buildapp.py index 7015b23627a..c8bae37dd8e 100644 --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -198,7 +198,7 @@ def populate_api_routes( webapp, app ): webapp.mapper.resource( 'datatype', 'datatypes', path_prefix='/api', - collection={ 'sniffers': 'GET', 'mapping' : 'GET' }, + collection={ 'sniffers': 'GET', 'mapping' : 'GET', 'converters': 'GET' }, parent_resources=dict( member_name='datatype', collection_name='datatypes' ) ) #webapp.mapper.connect( 'run_workflow', '/api/workflow/{workflow_id}/library/{library_id}', controller='workflows', action='run', workflow_id=None, library_id=None, conditions=dict(method=["GET"]) ) webapp.mapper.resource( 'search', 'search', path_prefix='/api' ) diff --git a/test/api/test_datatypes.py b/test/api/test_datatypes.py index 140a6421b3b..2f560b69fb4 100644 --- a/test/api/test_datatypes.py +++ b/test/api/test_datatypes.py @@ -43,6 +43,19 @@ class DatatypesApiTestCase( api.ApiTestCase ): xml_index = sniffer_list.index( "galaxy.datatypes.xml:GenericXml" ) assert owl_index < xml_index + def test_converters( self ): + response = self._get( "datatypes/converters" ) + self._assert_status_code_is( response, 200 ) + converters_list = response.json() + found_fasta_to_tabular = False + + for converter in converters_list: + self._assert_has_key( converter, "source", "target", "tool_id" ) + if converter["source"] == "fasta" and converter["target"] == "tabular": + found_fasta_to_tabular = True + + assert found_fasta_to_tabular + def _index_datatypes( self, data={} ): response = self._get( "datatypes", data=data ) self._assert_status_code_is( response, 200 )