Question: Bioblend - Passing a non-datasets parameter in toolClient.run_tool ?
0
gravatar for lindfors.erno
3.9 years ago by
Germany
lindfors.erno30 wrote:

Hi all,

I am trying to pass a non-dataset parameter in toolClient.run_tool.

More specifically, I am running the following code.
from bioblend.galaxy import GalaxyInstance
from bioblend.galaxy.histories import HistoryClient
from bioblend.galaxy.tools import ToolClient
from bioblend.galaxy.datasets import DatasetClient
galaxyInstance = GalaxyInstance(url=GALAXY_URL, key=API_KEY)
historyClient = HistoryClient(galaxyInstance)
toolClient = ToolClient(galaxyInstance)
datasetClient = DatasetClient(galaxyInstance)
history = historyClient.create_history('tmp')
testFile = toolClient.upload_file(PATH_NAME, history['id'], type='txt')
params = {'param': 'cond.choice', 'value': 'yes','cond.test_file':{'src': 'hda', 'id': testFile['outputs'][0]['id']}}
output = toolClient.run_tool(history_id=history['id'], tool_id=TOOL_ID, tool_inputs=params)


I am using the following xml file in Galaxy server:
<tool id="CondTest_R" name="CondTest" version="1.1.0">
  <description>Makes a conditional test</description>
  <command interpreter="Rscript">CondTest.R $out_file1 ${cond.choice} ${cond.te$
  <inputs>
    <conditional name="cond">
      <param name="choice" type="select" label="Do you want to read numbers fro$
        <option value="no">no</option>
        <option value="yes">yes</option>
      </param>
      <when value="no">
        <param name="test_file" type="hidden" value="NULL"/>
      </when>
      <when value="yes">
        <param name="test_file" type="data" format="txt" label="Test file"/>
      </when>
    </conditional>
  </inputs>
  .
  .
  .
</tool>


This does not work properly - I see from Galaxy server log that 'cond.choice' gets 'no' but I assign 'yes' to it in params = {...}.

I am pretty sure I am doing the parameters setting incorrectly in params = {...} since I have tested this tool works properly when I run it directly from Galaxy server's web interface.

Does anyone have an idea what I am doing incorrectly in the parameters settings?
In other words, what is the correct way to assign a non-dataset parameter in toolClient.run_tool?

To me it seems the documentation of toolClient.run_tool in http://bioblend.readthedocs.org/en/latest/api_docs/galaxy/all.html is not very informative but from the documentation of run_workflow I got a hint that it could work something like what I am using it in the code above.

Thanks in advance,
Erno Lindfors

 

bioblend software error galaxy • 1.6k views
ADD COMMENTlink written 3.9 years ago by lindfors.erno30
1
gravatar for ablumenf
3.7 years ago by
ablumenf10
United States
ablumenf10 wrote:

*** Solved ***

I did a bit more searching and found that the solution is to use the | character instead of the . in naming the parameter in the conditional. So in the example above it would be cond|choice . 

 

*** Original comment ***

Hi Erno,

I came across this post while I was researching an issue I'm having and thought you might be able to help. It looks like you were having problems setting a tool parameter that is part of a conditional. I have been having a similar problem, where I can't find the right way to change certain parameters. Specifically, I am trying to set a tool parameter when running a workflow, and can only change some of the parameters in the tool. Changing a parameter outside the conditional works fine, but not inside it. In your example above, dId using the format cond.choice work, or is there a different way to reference that parameter?  My full post is here: Setting clipping sequence as workflow parameter when running FASTX Clipper from BioBlend API. Any help would be appreciated. Thanks!

ADD COMMENTlink modified 3.7 years ago • written 3.7 years ago by ablumenf10
1

Correct - unfortunately the workflow and tool APIs work fairly differently - and the tool API requires parameters in a flat dictionary - so cond|choice would be the key to specify a parameter for the the tools API.

ADD REPLYlink written 3.7 years ago by jmchilton1.1k

Yes the cond|choice indeed solved this, more specifically the follow parameter setting works:
params = {'cond|choice': 'yes', 'cond|test_file':{'src': 'hda', 'id': testFile['outputs'][0]['id']}}

Thanks very much for the help!

ADD REPLYlink written 3.4 years ago by lindfors.erno30
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 96 users visited in the last hour