On 08/15/2012 08:59 PM, Dan Tenenbaum wrote:
Hi all,

I'm trying to wrap my head around what the <conditional> tag does...it
looks like it doesn't do what I would like.

I want to create a tool that allows the user to upload a data file and
then have it run through one or more filters. Each filter takes one or
more parameters.

I was thinking I could do something like this:


   <inputs>
      <conditional name="mycond">
          <param name="checktest" type="boolean" label="foo" value="yessir">
          </param>
          <when value="yessir">
              <param name="param1" type="text" label="bar" value="twunk">
              </param>
          </when>
      </conditional>
   </inputs>

The idea being, if the user checks the box labeled "foo", a text box
labeled "bar" will appear.
And I would have several such checkboxes and their accompanying parameters.
But what I get is just the checkbox, and nothing happens when I click it.

Is it possible to do what I have in mind, and if so, how?

Also note that these conditions are not mutually exclusive. A user can
select one *or more* filters. So I'm not sure how the body of my
<command> tag should look. Is there a way I can just pass every
possible parameter to my script like this:
myscript.py param1=foo param2=bar
If a parameter is not defined (because the user didn't click its
associated checkbox), then the script will receive e.g.
param1= param2=bar
but it can deal with that.

I realize I can make several tools and chain them together in a
workflow, but that seems like overkill for this use case, and it would
be nice if the user could set up their desired filters on one screen.

Is this possible?
Thanks!
Dan
___________________________________________________________
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/
Hello Dan,

The easiest way to go about this, since you said that none of your filters are mutually exclusive, is to use the "select" datatype. I don't think you even need the conditional tags. Galaxy says that you need <when> tag sets when you use conditionals, but this is not true, as I have similar code as I have written below. Use type="select" in your parameter. This gives you a button that can have a multitude of options, but most of mine are simply used like booleans. Something like this:

<inputs>
    <param name="param1" type="select" label="filterName" help="helpful tips">
        <option value="yes">yes</option>
        <option value="no">no</option>
     </param>
     <param name="param2" type="select" label="filter2Name" help="more helpful 
tips">
        <option value="yes">yes</option>
        <option value="no">no</option>
     </param>
</inputs>

I had certain options that WERE mutually exclusive, and required nested conditional statements, where I had an outer conditional for the extra options, and an inner conditional around each parameter.

As for the command tag, the select type parameters make it easy because you can just check the string values with an if statement, like so:
(assuming python)
<command interpreter="python">
    tool.py
    #if $param1 == "yes":
        --YourGetOptFlag
    #else:
        ##dont even need an else, just ignore
    #end if

</command>

If I am not mistaken, this should be sufficient if all you need to pass is a flag indicating your program to use the filter. If you need to pass a flag AND integer values, you are going to have to wrap your parameters in conditional tags and use a set of <when>:

<inputs>
  <conditional name="firstConditional">
    <param name="param1" type="select" label="filterName" help="helpful tips">
        <option value="yes">yes</option>
        <option value="no">no</option>
     </param>
     <when value="yes">
       <param name="IntegerBox" type="integer" value="[default value]" min="(optional)" 
max="(optional)" label="UseParamName" help="helpful text" />
     </when>
     <when value="no" /> <!--Doesnt show integer text box when no is chosen in the 
select-->
  </conditional>
</inputs>

Rinse and repeat, adding conditionals around each select. I think this is actually what you want to do, as you say you want a box to appear after a user selects whether or not to use the filter. Also, quick note, the text between the option tags are what appear on the select buttons, so they can be whatever you want. The value="" is the important thing, as this is what you will evaluate the "if/else" to in the <command> tag. One last thing, The cheetah command is really no different.

<command interpreter="python">
  tool.py
  #if $firstConditional.param1 == "yes":
     --testGetOpt $firstConditional.IntegerBox
  #end if

</command>

The second command tag is how I pass a few parameters into my command line tool.


Anyway, I hope this helped a little bit. If you need anything else, let me know and I will see If I can help. A lot of this was trial and error and I am sure there are trickier ways to doing it, but this worked for the scope of my program.

-John



___________________________________________________________
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/

Reply via email to