My goal is to read a JSON file from History into a JS script (for visualization puposes). The mako template where I read in the JSON from hda is as below:
<script src='/plugins/visualizations/igv/static/MutationInspectorWeb.js'></script> <script>
<% datalist = hda.datatype.dataprovider( hda, 'json' ) %> var pipeline_inspector = ${h.to_json_string( datalist, indent=2 )}; readData( pipeline_inspector );
</script>
In galaxy/lib/galaxy/datatypes/text.py:
from galaxy.datatypes import dataproviders from galaxy.datatypes.dataproviders.dataset import JsonDataProvider @dataproviders.decorators.has_dataproviders class Json( Text ): .... @dataproviders.decorators.dataprovider_factory( 'json', JsonDataProvider.settings ) def json_dataprovider( self, dataset, **settings ): dataset_source = dataproviders.dataset.DatasetDataProvider( dataset ) return JsonDataProvider( dataset_source, **settings )
In galaxy/lib/galaxy/datatypes/dataproviders:
class JsonDataProvider( base.DataProvider ): def __init__( self, dataset, **kwards ): self.dataset = dataset def __iter__( self ): if (self.dataset in not None): yield [list(line) for line in self.dataset] else: yield
I end up returning a module and not a list of strings. The traceback is as below:
AttributeError: 'module' object has no attribute 'to_json_string'. MutationInspector.js requires a JSON object to run correctly. Can anyone help me what I can do differently to return a JSON object or string?