Yes, you can still use the framework to create interactive python-only visualizations. The simplest way to do this is form-based interaction. 1. The visualization mako page renders a form that contains the options the user can choose from 2. The user chooses and submits the form 3. Galaxy will re-render the visualization mako and now, since those options are passed as parameters, the chosen visualization can be rendered So you can render the form with your options: %if not query.get( 'param2', None ): ## initial render of form <form> <input name="param2" /> <input name="param3" /> <input name="param4" /> <button type="submit">Draw</button> </form> %else: ## second render drawing with param2 ... Note: this will default to a GET based form whose 'action' url will be the visualization's url. Any html5 form based controls will work: radio buttons, ranges, etc. When the user submits the form, each of the params, will now be part of the query string when the mako renders the second time: /visualization/show/myvis?param2=something¶m3=... You can then use these params to call your python code with the user chosen options: arg2 = query.get( 'param2', default ) arg3 = query.get( 'param3', ... from draw import main returned = main( arg2, arg3, ... ) <svg> ${ returned } </svg> (or something similar) Other things that may help?: - you can use action="post" if you want to post data instead of get - handy for larger parameters - try to not bootstrap/load all your data into the mako file as this will be re-fetched everytime the form is re-submitted - you can add the arg2, arg3, etc. params to the config file and the registry will parse those for you and put them in the template's 'config' variable, e.g.: int_param2 = config.param2 - when using these query/form parameters you can now save/generate urls that will auto-start your visualizations since all the configuration options are sent in the url Let me know if I can give more info or that doesn't end up working. On Wed, Aug 19, 2015 at 9:30 AM, Anne Claire Fouilloux < a.c.fouilloux@geo.uio.no> wrote:
Hi Carl,
Yes I have a python code to manipulate and draw the data (it creates svg files and I wish to add this visualization tool to my galaxy instance:
Let's say my composite datatype contains 3 files:
-file1.dat
-file2.dat
-file3.dat
My python code takes 4 arguments (for instance draw.py arg1 arg2 arg3 arg4).
arg1: The first argument is a path giving the location of these 3 files.
arg2, arg3 and arg4 are list of options. These lists are dynamic as they depend on the content of these 3 files.
Once the user has selected some options, I have a "draw" button and would like the python script draw.py to be executed and generate a plot.
Your answer was very helpful; at least it clarifies a number of things. Now I understood I can access to these files using hda.extra_files_path in my mako file:
<%
composite_file_path=hda.extra_files_path + '/' + date + '/'
%>
Which is helpful to generate my select buttons (for arg2, arg3 and arg4) as I fist need to read the content of these files for the generation of these buttons.
I still need to call my python script with the option chosen by the user. Is it something I can easily do with galaxy?
Thanks,
Anne.
------------------------------ *From:* Carl Eberhard <carlfeberhard@gmail.com> *Sent:* 18 August 2015 18:59 *To:* Anne Claire Fouilloux *Cc:* galaxy-dev@lists.galaxyproject.org *Subject:* Re: [galaxy-dev] new visualization tool for composite datatype?
Hi, Anne
Can you be more specific about how you'd like to visualize the files? It sounds like you've already got a tool that will build an html file which is the classic way to make visualizations with galaxy.
Now you'd like to make it more interactive? Do you already have javascript or python code that will be used to manipulate or draw the data? The visualization registry will help you link a user's data to your visualization code but will not create the code that does the rendering or interaction.
Aside from that, if you know the structure and filenames of your composite's extra files directory, currently you can access those files using: api/histories/{history_id}/contents/{content_id}/display?filename=<some file> The meme type will be guessed based on the extension generally and more complex paths can also be specified using the filename parameter.
So, for example, if I have a FastQC Html composite file with an extra files path of: database/files/000/dataset_83_files
And within that directory, fastqc makes an additional subdirectory: sample1_fastqc/Icons sample1_fastqc/Images sample1_fastqc/summary.txt
I can fetch the summary.txt file (with the 'text/plain' memetype) using:
api/histories/{history_id}/contents/{content_id}/display?filename=sample1_fastqc/summary.txt
Let me know if that wasn't the info you were after or I misunderstood the question. Carl
On Fri, Aug 14, 2015 at 7:50 AM, Anne Claire Fouilloux < a.c.fouilloux@geo.uio.no> wrote:
Hi,
I created a new composite datatype (class derived from Html class) myDatatype and I sucessfully use it in a new created tool.
When I click on "View data" it shows my Html file with a list of binary files and everything is Ok.
Now I would like to Visualize my data. I created a new directory in
galaxy-dist/config/plugins/visualizations/ following instructions given at
https://wiki.galaxyproject.org/VisualizationsRegistry and read
https://wiki.galaxyproject.org/VisualizationsRegistry/Configuration and
https://wiki.galaxyproject.org/DataProviders
However, I still don't understand what I should do to be able to access files from my composite datatype to be able to visualize myDatatype (I mean I need to visualize the files containing in the directory listed by the html file).
Is it possible? Where can I find some information on how to do it?
Thanks,
Anne.
___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at: https://lists.galaxyproject.org/
To search Galaxy mailing lists use the unified search at: http://galaxyproject.org/search/mailinglists/