Skip to content

Commit

Permalink
Merge pull request #1263 from Kulivox/auto-tool-gen
Browse files Browse the repository at this point in the history
Implement automatic tool generation based on the source code of the tool
  • Loading branch information
mvdbeek authored Sep 14, 2023
2 parents 0b34f34 + 4cb7536 commit 6d6cb43
Show file tree
Hide file tree
Showing 35 changed files with 2,426 additions and 12 deletions.
30 changes: 30 additions & 0 deletions docs/_writing_argparse.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Creating Galaxy tools from python scripts using argparse
========================================================

If a python script should be wrapped that creates its command line interface
using the argparse library, then planemo can generate a good starting point.

All you need to do is to pass the path to the python source file containing
the argparse definition. Lets use ``tests/data/autopygen/autopygen_end_to_end_sub.py``
from the planemo tests as an example:

::

$ planemo tool_init -i e2e -n e2e
--autopygen tests/data/autopygen/autopygen_end_to_end_sub.py
-- tool tool.xml

Here we only provided the ``id`` and ``name`` in addition to the python sources
and planemo creates a pretty tool xml files that can serve as a good starting point
to create a functional Galaxy tool in ``tool.xml``.
Additional information, e.g. requirements, help, etc, can and should be given with
additional parameters to planemo.

There are a few points that need to be edited in any case. Most importantly
since in most cases ``argparse`` does not distinguish between input and output
files all file parameters will be rendered as input parameters of the tool.

Please open an issue if you have ideas on how to improve the generated tools:
https://github.com/galaxyproject/planemo/issues


4 changes: 4 additions & 0 deletions docs/commands/tool_init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ Generate tool outline from given arguments.
'seqtk@1.68').
--container TEXT Add a Docker image identifier for this tool.
--cwl Build a CWL tool instead of a Galaxy tool.
--autopygen TEXT Option for automatic generation of tool file, from
python source code that uses argparse. Parameter is
a path to source file containing definition of the
parser
--help Show this message and exit.
2 changes: 2 additions & 0 deletions docs/writing_standalone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if you have not already installed it.
.. include:: _writing_parameters.rst
.. include:: _writing_scripts.rst
.. include:: _writing_suites.rst
.. include:: _writing_argparse.rst
.. include:: _writing_conclusion.rst

.. _Galaxy: http://galaxyproject.org/
Expand All @@ -21,3 +22,4 @@ if you have not already installed it.
.. _linuxbrew: https://github.com/Homebrew/linuxbrew
.. _Vagrant: https://www.vagrantup.com/
.. _Planemo: http://planemo.readthedocs.org/

Empty file added planemo/autopygen/__init__.py
Empty file.
Loading

0 comments on commit 6d6cb43

Please sign in to comment.