Dynamic Tool UI based on script
Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button. --- Sent from VMware Boxer
Hi Evan, Yes, it is possible. Please note that these will not/may not work in workflows as expected and the use of code files is generally discouraged. (That said, in some cases you care more about user experience than anything else, and here they are useful.) Here's an example from my Apollo tool suite which lets the user interact with a service that lives outside of Galaxy. The user is able to select from a dropdown which dataset they would like to retrieve from that system (filtering on ones that they have permissions for.) Here I define an input with a dynamic_options parameter: https://github.com/galaxy-genome-annotation/galaxy-tools/blob/master/tools/a... I specify at the top of my tool which code file I want to load: https://github.com/galaxy-genome-annotation/galaxy-tools/blob/master/tools/a... Now when this is accessed, it looks at the code file paramater and calls the appropriate function: (There's a bit of unrelated stuff going on in here to handle caching since those calls are called many times and my backend is slow) https://github.com/galaxy-genome-annotation/galaxy-tools/blob/master/tools/a... Eventually this is called whcih shows the expected return format: https://github.com/galaxy-genome-annotation/galaxy-tools/blob/master/tools/a... A list of tuples where the first parameter is what the user sees, the second parameter is what value the option has (that is passed on the command line), and the third is "False". Cheers, On 2017-11-23, Evan Clark wrote:
Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button.
--- Sent from VMware Boxer
___________________________________________________________ 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/
Hi Evan Yes, this is possible with "dynamic_options" e.g.: <tool ... <inputs> <param name="year" type="select" label="from which year" display="radio" refresh_on_change="true" > <option value="/2017" selected="true">2017</option> <option value="/2016">2016</option> <option value="/2015">2015</option> </param> <param name="file" type="select" label="select a run" display="radio" dynamic_options="ds_readFiles(year)"/> </inputs> <outputs> ... </outputs> <help> ... </help> <code file="more_code.py" /> </tool> The python function "ds_readFiles" is defined in a extra code file "more_code.py", which is stored in the same directory as the tool definition file. The function returns all files with a matching file name (i.e.year), and could look like: rDir = "/data/" def ds_readFiles(year): l = os.listdir(rDir) p = re.compile('^%s_[09]{4}_M[09]{5}_[09]'%year) l.sort() path = rDir filesoptions = [(s) for s in l if os.path.exists(path + s)] files = [(s,s,False) for s in filesoptions if p.match(s)] return files a similar case is also described here: http://dev.list.galaxyproject.org/Dynamic-Tool-Parameter-Lists-td4175828.htm... Hope this helps, Hans-Rudolf On 11/23/2017 06:02 PM, Evan Clark wrote:
Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button.
--- Sent from VMware Boxer
___________________________________________________________ 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/
Hi all, this would help in a tool I’m trying to write too but the problem I have implementing this approach is that my script will need an external python module - is there any way that I can list dependencies for the script? As it happens these are the same dependancies that the tool itself will need once executed. Thanks, Steve — Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy On 24 Nov 2017, at 6:52 pm, Hans-Rudolf Hotz <hrh@fmi.ch<mailto:hrh@fmi.ch>> wrote: Hi Evan Yes, this is possible with "dynamic_options" e.g.: <tool ... <inputs> <param name="year" type="select" label="from which year" display="radio" refresh_on_change="true" > <option value="/2017" selected="true">2017</option> <option value="/2016">2016</option> <option value="/2015">2015</option> </param> <param name="file" type="select" label="select a run" display="radio" dynamic_options="ds_readFiles(year)"/> </inputs> <outputs> ... </outputs> <help> ... </help> <code file="more_code.py" /> </tool> The python function "ds_readFiles" is defined in a extra code file "more_code.py", which is stored in the same directory as the tool definition file. The function returns all files with a matching file name (i.e.year), and could look like: rDir = "/data/" def ds_readFiles(year): l = os.listdir(rDir) p = re.compile('^%s_[09]{4}_M[09]{5}_[09]'%year) l.sort() path = rDir filesoptions = [(s) for s in l if os.path.exists(path + s)] files = [(s,s,False) for s in filesoptions if p.match(s)] return files a similar case is also described here: http://dev.list.galaxyproject.org/Dynamic-Tool-Parameter-Lists-td4175828.htm... Hope this helps, Hans-Rudolf On 11/23/2017 06:02 PM, Evan Clark wrote: Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button. --- Sent from VMware Boxer ___________________________________________________________ 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/ ___________________________________________________________ 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/
Hi Steve what happened, when you add this module to the environment the galaxy server is running in? (e.g. by listing the path in the 'run.sh' file) Regards, Hans-Rudolf On 12/07/2017 03:05 AM, Steve Cassidy wrote:
Hi all, this would help in a tool I’m trying to write too but the problem I have implementing this approach is that my script will need an external python module - is there any way that I can list dependencies for the script? As it happens these are the same dependancies that the tool itself will need once executed.
Thanks,
Steve
— Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy
On 24 Nov 2017, at 6:52 pm, Hans-Rudolf Hotz <hrh@fmi.ch <mailto:hrh@fmi.ch>> wrote:
Hi Evan
Yes, this is possible with "dynamic_options"
e.g.:
<tool ...
<inputs>
<param name="year" type="select" label="from which year" display="radio" refresh_on_change="true" > <option value="/2017" selected="true">2017</option> <option value="/2016">2016</option> <option value="/2015">2015</option> </param>
<param name="file" type="select" label="select a run" display="radio" dynamic_options="ds_readFiles(year)"/>
</inputs> <outputs> ... </outputs> <help> ... </help> <code file="more_code.py" />
</tool>
The python function "ds_readFiles" is defined in a extra code file "more_code.py", which is stored in the same directory as the tool definition file. The function returns all files with a matching file name (i.e.year), and could look like:
rDir = "/data/"
def ds_readFiles(year):
l = os.listdir(rDir) p = re.compile('^%s_[09]{4}_M[09]{5}_[09]'%year) l.sort() path = rDir filesoptions = [(s) for s in l if os.path.exists(path + s)] files = [(s,s,False) for s in filesoptions if p.match(s)] return files
a similar case is also described here:
http://dev.list.galaxyproject.org/Dynamic-Tool-Parameter-Lists-td4175828.htm...
Hope this helps, Hans-Rudolf
On 11/23/2017 06:02 PM, Evan Clark wrote:
Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button.
--- Sent from VMware Boxer
___________________________________________________________ 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/
___________________________________________________________ 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/
I could do that but it would mean that no-one could install the tool from the toolshed without also installing this package. Maybe I just need to hack this together. Steve — Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy On 7 Dec 2017, at 6:59 pm, Hans-Rudolf Hotz <hrh@fmi.ch<mailto:hrh@fmi.ch>> wrote: Hi Steve what happened, when you add this module to the environment the galaxy server is running in? (e.g. by listing the path in the 'run.sh' file) Regards, Hans-Rudolf On 12/07/2017 03:05 AM, Steve Cassidy wrote: Hi all, this would help in a tool I’m trying to write too but the problem I have implementing this approach is that my script will need an external python module - is there any way that I can list dependencies for the script? As it happens these are the same dependancies that the tool itself will need once executed. Thanks, Steve — Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy On 24 Nov 2017, at 6:52 pm, Hans-Rudolf Hotz <hrh@fmi.ch <mailto:hrh@fmi.ch>> wrote: Hi Evan Yes, this is possible with "dynamic_options" e.g.: <tool ... <inputs> <param name="year" type="select" label="from which year" display="radio" refresh_on_change="true" > <option value="/2017" selected="true">2017</option> <option value="/2016">2016</option> <option value="/2015">2015</option> </param> <param name="file" type="select" label="select a run" display="radio" dynamic_options="ds_readFiles(year)"/> </inputs> <outputs> ... </outputs> <help> ... </help> <code file="more_code.py" /> </tool> The python function "ds_readFiles" is defined in a extra code file "more_code.py", which is stored in the same directory as the tool definition file. The function returns all files with a matching file name (i.e.year), and could look like: rDir = "/data/" def ds_readFiles(year): l = os.listdir(rDir) p = re.compile('^%s_[09]{4}_M[09]{5}_[09]'%year) l.sort() path = rDir filesoptions = [(s) for s in l if os.path.exists(path + s)] files = [(s,s,False) for s in filesoptions if p.match(s)] return files a similar case is also described here: http://dev.list.galaxyproject.org/Dynamic-Tool-Parameter-Lists-td4175828.htm... Hope this helps, Hans-Rudolf On 11/23/2017 06:02 PM, Evan Clark wrote: Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button. --- Sent from VMware Boxer ___________________________________________________________ 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/ ___________________________________________________________ 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/
Sure However, tools relying on "dynamic_options" and extra "code" scripts are usually 'hacks' for accessing external data/services in a local galaxy installation. And such tools are not intended for the toolshed anyway....IMHO. Hans-Rudolf On 12/07/2017 09:37 AM, Steve Cassidy wrote:
I could do that but it would mean that no-one could install the tool from the toolshed without also installing this package.
Maybe I just need to hack this together.
Steve
— Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy
On 7 Dec 2017, at 6:59 pm, Hans-Rudolf Hotz <hrh@fmi.ch <mailto:hrh@fmi.ch>> wrote:
Hi Steve
what happened, when you add this module to the environment the galaxy server is running in? (e.g. by listing the path in the 'run.sh' file)
Regards, Hans-Rudolf
On 12/07/2017 03:05 AM, Steve Cassidy wrote:
Hi all, this would help in a tool I’m trying to write too but the problem I have implementing this approach is that my script will need an external python module - is there any way that I can list dependencies for the script? As it happens these are the same dependancies that the tool itself will need once executed.
Thanks,
Steve
— Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy
On 24 Nov 2017, at 6:52 pm, Hans-Rudolf Hotz <hrh@fmi.ch <mailto:hrh@fmi.ch>> wrote:
Hi Evan
Yes, this is possible with "dynamic_options"
e.g.:
<tool ...
<inputs>
<param name="year" type="select" label="from which year" display="radio" refresh_on_change="true" > <option value="/2017" selected="true">2017</option> <option value="/2016">2016</option> <option value="/2015">2015</option> </param>
<param name="file" type="select" label="select a run" display="radio" dynamic_options="ds_readFiles(year)"/>
</inputs> <outputs> ... </outputs> <help> ... </help> <code file="more_code.py" />
</tool>
The python function "ds_readFiles" is defined in a extra code file "more_code.py", which is stored in the same directory as the tool definition file. The function returns all files with a matching file name (i.e.year), and could look like:
rDir = "/data/"
def ds_readFiles(year):
l = os.listdir(rDir) p = re.compile('^%s_[09]{4}_M[09]{5}_[09]'%year) l.sort() path = rDir filesoptions = [(s) for s in l if os.path.exists(path + s)] files = [(s,s,False) for s in filesoptions if p.match(s)] return files
a similar case is also described here:
http://dev.list.galaxyproject.org/Dynamic-Tool-Parameter-Lists-td4175828.htm...
Hope this helps, Hans-Rudolf
On 11/23/2017 06:02 PM, Evan Clark wrote:
Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button.
--- Sent from VMware Boxer
___________________________________________________________ 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/
___________________________________________________________ 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/
I don’t like ‘hacks’!! I solved this by pulling the relevant bits of the module into my script so that it runs with no dependencies. It’s basically just making an HTTP GET request with an authentication header, so not too hard to achieve. Should be safe to put in the toolshed. Thanks, this is a big improvement in our UI (and I vote for not deprecating this feature, maybe even making it more robust). Steve — Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy On 7 Dec 2017, at 8:50 pm, Hans-Rudolf Hotz <hrh@fmi.ch<mailto:hrh@fmi.ch>> wrote: Sure However, tools relying on "dynamic_options" and extra "code" scripts are usually 'hacks' for accessing external data/services in a local galaxy installation. And such tools are not intended for the toolshed anyway....IMHO. Hans-Rudolf On 12/07/2017 09:37 AM, Steve Cassidy wrote: I could do that but it would mean that no-one could install the tool from the toolshed without also installing this package. Maybe I just need to hack this together. Steve — Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy On 7 Dec 2017, at 6:59 pm, Hans-Rudolf Hotz <hrh@fmi.ch <mailto:hrh@fmi.ch>> wrote: Hi Steve what happened, when you add this module to the environment the galaxy server is running in? (e.g. by listing the path in the 'run.sh' file) Regards, Hans-Rudolf On 12/07/2017 03:05 AM, Steve Cassidy wrote: Hi all, this would help in a tool I’m trying to write too but the problem I have implementing this approach is that my script will need an external python module - is there any way that I can list dependencies for the script? As it happens these are the same dependancies that the tool itself will need once executed. Thanks, Steve — Department of Computing, Macquarie University http://web.science.mq.edu.au/~cassidy On 24 Nov 2017, at 6:52 pm, Hans-Rudolf Hotz <hrh@fmi.ch <mailto:hrh@fmi.ch>> wrote: Hi Evan Yes, this is possible with "dynamic_options" e.g.: <tool ... <inputs> <param name="year" type="select" label="from which year" display="radio" refresh_on_change="true" > <option value="/2017" selected="true">2017</option> <option value="/2016">2016</option> <option value="/2015">2015</option> </param> <param name="file" type="select" label="select a run" display="radio" dynamic_options="ds_readFiles(year)"/> </inputs> <outputs> ... </outputs> <help> ... </help> <code file="more_code.py" /> </tool> The python function "ds_readFiles" is defined in a extra code file "more_code.py", which is stored in the same directory as the tool definition file. The function returns all files with a matching file name (i.e.year), and could look like: rDir = "/data/" def ds_readFiles(year): l = os.listdir(rDir) p = re.compile('^%s_[09]{4}_M[09]{5}_[09]'%year) l.sort() path = rDir filesoptions = [(s) for s in l if os.path.exists(path + s)] files = [(s,s,False) for s in filesoptions if p.match(s)] return files a similar case is also described here: http://dev.list.galaxyproject.org/Dynamic-Tool-Parameter-Lists-td4175828.htm... Hope this helps, Hans-Rudolf On 11/23/2017 06:02 PM, Evan Clark wrote: Is it possible to execute a script within a tool xml confit to retrieve some data and append to the ui depending on the requested data. I.e if I wanted to get a list of files and provide them as select options before hitting the execute button. --- Sent from VMware Boxer ___________________________________________________________ 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/ ___________________________________________________________ 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/
participants (4)
-
E. Rasche
-
Evan Clark
-
Hans-Rudolf Hotz
-
Steve Cassidy