Hi, I think I found the solution to my problem by googling it instead of just searching through the dev mailing list. I found this post very useful for debugging tips on cheetah template: http://lists.bx.psu.edu/pipermail/galaxy-dev/2011-March/004817.html Then I read on the galaxy wiki: http://wiki.g2.bx.psu.edu/Admin/Tools/Data%20Tables How to use Data Tables and found this: """ The script or binary will need the actual path in the command, and since the ID is the value, some work will need to be done to extract the path. The following line would do the trick: --ref="${ filter( lambda x: str( x[0] ) == str( $index ), $__app__.tool_data_tables[ 'bowtie_indexes' ].get_fields() )[0][-1] }" In this line, str( x[0] ) refers to the unique ID in column 0 and the -1 in [0][-1] gets the path in the last column. """ I've changed the command to print all available parameters: <command interpreter="sh"> #silent sys.stderr.write("!!!! Cheetah Template Variables !!!!\n") #for k,v in $searchList[2].items() #silent sys.stderr.write(" %s = %s\n" % (str(k), str(v) )) #end for #silent sys.stderr.write("CRI datasets: %s\n" % str($__app__.tool_data_tables[ 'cri_datasets' ].get_fields())) #silent sys.stderr.write("Dataset selected: %s\n" % str($dataset.name)) #silent dataset_path = filter( lambda x: str( x[0] ) == str( $dataset.name ), $__app__.tool_data_tables[ 'cri_datasets' ].get_fields() )[0][-1] #silent sys.stderr.write("Dataset path: %s\n" % str(dataset_path) ) #silent sys.stderr.write("!!!! end-of-list !!!!\n") ... and finally got it to works! To summary, to get the path from the cri_datasets table: dataset_path = filter( lambda x: str( x[0] ) == str( $dataset.name ), $__app__.tool_data_tables[ 'cri_datasets' ].get_fields() )[0][-1] Hope it could be useful to someone else. Anne. On 22 May 2012, at 19:52, Anne Pajon wrote:
Hi,
I'm writing a galaxy tool xml file for an in house existing R script. I have a conditional parameter set for selecting the dataset to work with but I would like to access the path of the file from the data table I've created:
<table name="cri_datasets" comment_char="#"> <columns>value, name, path</columns> <file path="tool-data/cri/datasets.loc" /> </table>
Here is the beginning of the xml file:
<command interpreter="R --vanilla --slave -f"> rp.R --args $dataset.name.fields.name $dataset.name.fields.path $input $column $output_txt $output_html $output_html.files_path $dataset.outcome $dataset.receptor $dataset.treatment $dataset.er $dataset.age $dataset.grade $dataset.signature $dataset.margins $dataset.groups $dataset.gleason $dataset.tstage 2>stderr || cat stderr 1>&2 </command>
<inputs> <param name="input" type="data" format="tabular,txt" label="Source file" help="File containing a list of gene symbols"/> <param name="column" type="data_column" data_ref="input" numerical="False" label="Column" help="Column containing gene symbols (only available for tabular input file)" />
<conditional name="dataset"> <param name="name" type="select" label="Dataset"> <options from_data_table="cri_datasets" /> </param> ...
but when running the tool, here is the error message I get:
Traceback (most recent call last): File "/opt/local/home/webapp/galaxy/lib/galaxy/jobs/runners/local.py", line 59, in run_job job_wrapper.prepare() File "/opt/local/home/webapp/galaxy/lib/galaxy/jobs/__init__.py", line 429, in prepare self.command_line = self.tool.build_command_line( param_dict ) File "/opt/local/home/webapp/galaxy/lib/galaxy/tools/__init__.py", line 1971, in build_command_line command_line = fill_template( self.command, context=param_dict ) File "/opt/local/home/webapp/galaxy/lib/galaxy/util/template.py", line 9, in fill_template return str( Template( source=template_text, searchList=[context] ) ) File "/opt/local/home/webapp/galaxy/eggs/Cheetah-2.2.2-py2.7-linux-x86_64-ucs2.egg/Cheetah/Template.py", line 1004, in __str__ return getattr(self, mainMethName)() File "DynamicallyCompiledCheetahTemplate.py", line 83, in respond NotFound: cannot find 'fields' while searching for 'dataset.name.fields.name'
Is it possible to access the other columns of a loc file? It seems possible based of what I read on the wiki http://wiki.g2.bx.psu.edu/Admin/Tools/Tool%20Config%20Syntax#A.3Coptions.3E_... using from_data_table and syntax of ${param.fields.path} but I could not manage to make it work.
Any help would be very much appreciated. Thanks! Kind regards, Anne.
-- Anne Pajon, Ph.D. Cancer Research UK - Cambridge Research Institute Li Ka Shing Centre, Robinson Way, Cambridge CB2 0RE anne.pajon@cancer.org.uk | +44 (0)1223 404 334
-- Anne Pajon, Ph.D. Cancer Research UK - Cambridge Research Institute Li Ka Shing Centre, Robinson Way, Cambridge CB2 0RE anne.pajon@cancer.org.uk | +44 (0)1223 404 334 NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for the above-named person(s). If you are not the intended recipient, notify the sender immediately, delete this email from your system and do not disclose or use for any purpose. We may monitor all incoming and outgoing emails in line with current legislation. We have taken steps to ensure that this email and attachments are free from any virus, but it remains your responsibility to ensure that viruses do not adversely affect you. Cancer Research UK Registered in England and Wales Company Registered Number: 4325234. Registered Charity Number: 1089464 and Scotland SC041666 Registered Office Address: Angel Building, 407 St John Street, London EC1V 4AD.