Re: [galaxy-dev] cannot access conditional parameter in command

2012-05-23 Thread Anne Pajon
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:

  
  #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:
> 
>  
>  value, name, path
>  
>  
> 
> Here is the beginning of the xml file:
> 
>  
>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
>  
> 
>  
> help="File containing a list of gene symbols"/>
> label="Column" help="Column containing gene symbols (only available for 
> tabular input file)" />
> 
>
>  
>
>  
> ...
> 
> 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_tag_set
>  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.pa...@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.pa...@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 fro

[galaxy-dev] cannot access conditional parameter in command

2012-05-22 Thread Anne Pajon
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:

  
  value, name, path
  
  

Here is the beginning of the xml file:

  
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
  

  




  

  
...

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_tag_set
 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.pa...@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.

___
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:

  http://lists.bx.psu.edu/