Brad,

Yes - that environment variable trick is an anti-pattern in my mind
because it is heavy and because it only works for tool shed installed
tools. As of 15.03 you can now just use $__tool_directory__ to refer
to the directory the tool is in. I can point at the patch if you want
to back port this to an older Galaxy (the patch is relatively small).

Planemo's building a tool documentation has a section on writing
wrapper scripts that demonstrates the use of the new
$__tool_directory__ variable -
http://planemo.readthedocs.org/en/latest/writing_standalone.html#wrapping-a-script.

Hope this helps,
-John


On Thu, Mar 26, 2015 at 1:06 PM, Langhorst, Brad <langho...@neb.com> wrote:
> I’m working on a very simple tool.
>
> <tool id="gc_stat" name="GC Stat" version="0.1.0">
>     <requirements>
>         <requirement type="binary">Rscript</requirement>
>         <requirement type="package" version="1.1">samtools</requirement>
> <requirement type="package" version="3.0.3">R</requirement>
>     </requirements>
>     <stdio>
>         <exit_code range="1:" />
>     </stdio>
>
>     <command><![CDATA[
> samtools view $bam | Rscript simple_script.R > $output
> ]]></command>
>     <inputs>
> <param name='bam' type='data' format='bam' label='Mapped reads' help='BAM
> files'/>
>     </inputs>
>     <outputs>
> <data format='tabular' name='output' label='GC Statistic on ${on_string}'/>
>     </outputs>
>     <help><![CDATA[
> Calculates a GC statistic for the specified BAM file.
>     ]]></help>
> </tool>
>
> this won’t work because Rscript is not running in the tool install directory
> and can’t find simple_script.R…
>
> I’ve just been reading
>
> https://trello.com/c/9lQ7Sr8I/636-galaxy-tool-enhancement-to-accommodate-repository-install-dir
>
> and it seems that  I have to add another file…
>
> <?xml version="1.0"?>
> <tool_dependency>
> <set_environment version="1.0">
> <environment_variable name="TOOL_INSTALL_DIR"
> action="set_to">$REPOSITORY_INSTALL_DIR</environment_variable>
> </set_environment>
> </tool_dependency>
>
> and add a set_enviornment dependency to bring it in.
> <requirements>
> ...
> <requirement type="set_environment">TOOL_INSTALL_DIR</requirement>
>  </requirements>
>  <command><![CDATA[
> samtools view $bam | Rscript $TOOL_INSTALL_DIR/simple_script.R > $output
> ]]></command>
>
> I did that but the tool still won’t execute, in fact the .
> Maybe because I have to put this into a toolshed - or maybe I’ve done
> something wrong?
>
>
> I think this complexity could be avoided by setting an TOOL_INSTALL_DIR
> environment var as a tool is executed (though John doesn’t seem to like that
> idea due to a responsibility mixing issue)
>
> I think it’s a worthy goal to make tool development as frictionless as
> possible.
> Is there a simpler way to do this?
>
> Brad
>
>
>
> ___________________________________________________________
> 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/mailinglists/
___________________________________________________________
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/mailinglists/

Reply via email to