### Dockerfile: Install Tutorials and Set Entrypoint Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/topic This Dockerfile snippet installs all necessary components for tutorials and sets the entrypoint for data library downloads. It involves adding shell scripts for setup and execution. ```dockerfile ADD bin/docker-install-tutorials.sh /setup-tutorials.sh ADD bin/mergeyaml.py /mergeyaml.py ADD bin/data_libarary_download.sh /data_libarary_download.sh RUN /setup-tutorials.sh ENTRYPOINT ["/data_libarary_download.sh"] ``` -------------------------------- ### Install Development Version of Planemo with pip Source: https://planemo.readthedocs.io/en/latest/installation Installs the latest development branch of Planemo directly from its GitHub repository using pip. ```bash pip install -U git+git://github.com/galaxyproject/planemo.git ``` -------------------------------- ### Serve Galaxy Tools with Planemo Source: https://planemo.readthedocs.io/en/latest/readme Serves Galaxy tools in a Galaxy interface. Requires a Galaxy root, which can be specified explicitly or installed dynamically. This command allows viewing tools in a running Galaxy instance. ```bash planemo serve ``` -------------------------------- ### Initialize Project with Template Source: https://planemo.readthedocs.io/en/latest/writing_advanced Initializes a new project directory using a specified template, such as 'seqtk_complete'. This command helps in quickly setting up example projects for testing and development. ```bash $ planemo project_init --template=seqtk_complete seqtk_example $ cd seqtk_example ``` -------------------------------- ### Initialize Example Command Option for Planemo Tool Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/options Defines the '--example_command' option for the `planemo tool init` command. This allows specifying an example command to generate a Cheetah template, used with example inputs and outputs. ```python def tool_init_example_command_option(help=EXAMPLE_COMMAND_HELP): return planemo_option( "--example_command", type=click.STRING, default=None, prompt=False, help=help, ) ``` -------------------------------- ### Install Planemo with pip Source: https://planemo.readthedocs.io/en/latest/readme Installs Planemo using pip within a Python virtual environment. This is the traditional method for installing Planemo and requires Python 3.8 or newer. ```bash python -m venv .venv; . .venv/bin/activate pip install planemo ``` -------------------------------- ### Install Planemo with uv Source: https://planemo.readthedocs.io/en/latest/installation Installs Planemo using the uv package manager. This sets up a global shim for managing the Python environment. ```bash uv tool install planemo ``` -------------------------------- ### Vagrantfile for Planemo Appliance Source: https://planemo.readthedocs.io/en/latest/_sources/appliance An example Vagrantfile to configure and launch the Planemo appliance. This file should be named 'Vagrantfile' and placed in your tool directory. After creating this file, you can start the appliance with 'vagrant up'. ```ruby VAGRANTFILE_API_VERSION = "1" # See more configuration options at # https://docs.vagrantup.com/v2/programming/trusted-plugins.html Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Every Vagrant development environment needs a box config.vm.box = "planemo/interactive" # Share the current directory to the VM at /vagrant config.vm.synced_folder ".", "/vagrant" # Create a public network, which you can access from your host # machine and develop on. config.vm.network "public_network", ip: "192.168.33.10" # Configure port forwarding to the host config.vm.forward_port 8010, 8010 config.vm.forward_port 9009, 9009 # Set the name of the VM config.vm.provider "virtualbox" do |vb| # Display the VirtualBox GUI when the machine is running vb.gui = false end end ``` -------------------------------- ### Initialize Example Output Option for Planemo Tool Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/options Defines the '--example_output' option for the `planemo tool init` command. Used with '--example_command' to specify example output files for placeholder data. ```python def tool_init_example_output_option(): return planemo_option( "--example_output", type=click.STRING, default=None, prompt=False, multiple=True, help=("For use with --example_command, replace input file (e.g. 2.fastq with a tool output)."), ) ``` -------------------------------- ### Initialize Example Input Option for Planemo Tool Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/options Defines the '--example_input' option for the `planemo tool init` command. Used with '--example_command' to specify example input files for placeholder data. ```python def tool_init_example_input_option(): return planemo_option( "--example_input", type=click.STRING, default=None, prompt=False, multiple=True, help=("For use with --example_command, replace input file (e.g. 2.fastq with a data input parameter)."), ) ``` -------------------------------- ### Build BioContainer with Planemo Mull Command Source: https://planemo.readthedocs.io/en/latest/writing_advanced This snippet demonstrates the command-line usage of Planemo's `mull` command to build a BioContainer for a tool with multiple requirements (bwa and samtools). It shows the project initialization, the `mull` command execution, and the detailed output of the container building process, including dependency installation. ```bash $ planemo project_init --template=conda_testing conda_testing $ cd conda_testing/ $ planemo mull bwa_and_samtools.xml /Users/john/.planemo/involucro -v=3 -f /Users/john/workspace/planemo/.venv/lib/python2.7/site-packages/galaxy_lib-17.9.0-py2.7.egg/galaxy/tools/deps/mulled/invfile.lua -set CHANNELS='iuc,conda-forge,bioconda,defaults' -set TEST='true' -set TARGETS='samtools=1.3.1,bwa=0.7.15' -set REPO='quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:03dc1d2818d9de56938078b8b78b82d967c1f820' -set BINDS='build/dist:/usr/local/' -set PREINSTALL='conda install --quiet --yes conda=4.3' build /Users/john/.planemo/involucro -v=3 -f /Users/john/workspace/planemo/.venv/lib/python2.7/site-packages/galaxy_lib-17.9.0-py2.7.egg/galaxy/tools/deps/mulled/invfile.lua -set CHANNELS='iuc,conda-forge,bioconda,defaults' -set TEST='true' -set TARGETS='samtools=1.3.1,bwa=0.7.15' -set REPO='quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:03dc1d2818d9de56938078b8b78b82d967c1f820' -set BINDS='build/dist:/usr/local/' -set PREINSTALL='conda install --quiet --yes conda=4.3' build [Jun 19 11:28:35] DEBU Run file [/Users/john/workspace/planemo/.venv/lib/python2.7/site-packages/galaxy_lib-17.9.0-py2.7.egg/galaxy/tools/deps/mulled/invfile.lua] [Jun 19 11:28:35] STEP Run image [continuumio/miniconda:latest] with command [[rm -rf /data/dist]] [Jun 19 11:28:35] DEBU Creating container [step-730a02d79e] [Jun 19 11:28:35] DEBU Created container [5e4b5f83c455 step-730a02d79e], starting it [Jun 19 11:28:35] DEBU Container [5e4b5f83c455 step-730a02d79e] started, waiting for completion [Jun 19 11:28:36] DEBU Container [5e4b5f83c455 step-730a02d79e] completed with exit code [0] as expected [Jun 19 11:28:36] DEBU Container [5e4b5f83c455 step-730a02d79e] removed [Jun 19 11:28:36] STEP Run image [continuumio/miniconda:latest] with command [[/bin/sh -c conda install --quiet --yes conda=4.3 && conda install -c iuc -c conda-forge -c bioconda -c defaults samtools=1.3.1 bwa=0.7.15 -p /usr/local --copy --yes --quiet]] [Jun 19 11:28:36] DEBU Creating container [step-e95bf001c8] [Jun 19 11:28:36] DEBU Created container [72b9ca0e56f8 step-e95bf001c8], starting it [Jun 19 11:28:37] DEBU Container [72b9ca0e56f8 step-e95bf001c8] started, waiting for completion [Jun 19 11:28:46] SOUT Fetching package metadata ......... [Jun 19 11:28:47] SOUT Solving package specifications: . [Jun 19 11:28:50] SOUT [Jun 19 11:28:50] SOUT Package plan for installation in environment /opt/conda: [Jun 19 11:28:50] SOUT [Jun 19 11:28:50] SOUT The following packages will be UPDATED: [Jun 19 11:28:50] SOUT [Jun 19 11:28:50] SOUT conda: 4.3.11-py27_0 --> 4.3.22-py27_0 [Jun 19 11:28:50] SOUT [Jun 19 11:29:04] SOUT Fetching package metadata ................. [Jun 19 11:29:06] SOUT Solving package specifications: . [Jun 19 11:29:56] SOUT [Jun 19 11:29:56] SOUT Package plan for installation in environment /usr/local: [Jun 19 11:29:56] SOUT [Jun 19 11:29:56] SOUT The following NEW packages will be INSTALLED: [Jun 19 11:29:56] SOUT [Jun 19 11:29:56] SOUT bwa: 0.7.15-1 bioconda [Jun 19 11:29:56] SOUT curl: 7.52.1-0 [Jun 19 11:29:56] SOUT libgcc: 5.2.0-0 [Jun 19 11:29:56] SOUT openssl: 1.0.2l-0 [Jun 19 11:29:56] SOUT pip: 9.0.1-py27_1 [Jun 19 11:29:56] SOUT python: 2.7.13-0 [Jun 19 11:29:56] SOUT readline: 6.2-2 [Jun 19 11:29:56] SOUT samtools: 1.3.1-5 bioconda [Jun 19 11:29:56] SOUT setuptools: 27.2.0-py27_0 [Jun 19 11:29:56] SOUT sqlite: 3.13.0-0 [Jun 19 11:29:56] SOUT tk: 8.5.18-0 [Jun 19 11:29:56] SOUT wheel: 0.29.0-py27_0 [Jun 19 11:29:56] SOUT zlib: 1.2.8-3 [Jun 19 11:29:56] SOUT [Jun 19 11:29:57] DEBU Container [72b9ca0e56f8 step-e95bf001c8] completed with exit code [0] as expected [Jun 19 11:29:57] DEBU Container [72b9ca0e56f8 step-e95bf001c8] removed [Jun 19 11:29:57] STEP Wrap [build/dist] as [quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:03dc1d2818d9de56938078b8b78b82d967c1f820-0] [Jun 19 11:29:57] DEBU Creating container [step-6f1c176372] [Jun 19 11:29:58] DEBU Packing succeeded ``` -------------------------------- ### Prepare Install Arguments (Planemo) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/shed This function prepares the arguments needed for bioblend's install_repository_revision function to install a repository. It gathers information such as the Tool Shed URL, repository name, owner, and changeset revision. ```python def install_args(self, ctx, shed_context): """Arguments for bioblend's install_repository_revision to install this repository against supplied tsi. """ tool_shed_url = shed_context.tsi.base_url return dict( tool_shed_url=tool_shed_url, name=self.name, owner=self.owner, changeset_revision=self.latest_installable_revision(ctx, shed_context), ) ``` -------------------------------- ### Get Latest Installable Revision Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/shed/interface Retrieves the most recent installable revision for a given repository. It first fetches repository details to get the name and owner, then queries for ordered installable revisions and returns the last one in the list. Raises an exception if no installable revisions are found. ```python def latest_installable_revision(tsi, repository_id): info = tsi.repositories.show_repository(repository_id) owner = info["owner"] name = info["name"] revisions = tsi.repositories.get_ordered_installable_revisions(name, owner) if len(revisions) == 0: msg = f"Failed to find installable revisions for [{owner}, {name}]." raise Exception(msg) else: return revisions[-1] ``` -------------------------------- ### Initialize Tutorial from Keywords (Python) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial This method populates a `Tutorial` instance using a dictionary of keywords. It assigns values to tutorial attributes like name, title, Zenodo link, questions, objectives, time estimation, key points, contributors, workflow file path, workflow ID, and flags for hands-on activities and slides. It also ensures the directory name and data library are initialized. ```python def init_from_kwds(self, kwds): """Init a tutorial instance from a kwds dictionary.""" self.name = kwds["tutorial_name"] self.title = kwds["tutorial_title"] self.zenodo_link = kwds["zenodo_link"] if kwds["zenodo_link"] else "" self.questions = [ "Which biological questions are addressed by the tutorial?", "Which bioinformatics techniques are important to know for this type of data?", ] self.objectives = [ "The learning objectives are the goals of the tutorial", "They will be informed by your audience and will communicate to them and to yourself what you should focus on during the course", "They are single sentences describing what a learner should be able to do once they have completed the tutorial", "You can use Bloom's Taxonomy to write effective learning objectives", ] self.time = "3H" self.key_points = ["The take-home messages", "They will appear at the end of the tutorial"] self.contributors = ["contributor1", "contributor2"] self.init_wf_fp = kwds["workflow"] self.init_wf_id = kwds["workflow_id"] self.hands_on = kwds["hands_on"] self.slides = kwds["slides"] self.set_dir_name() self.init_data_lib() ``` -------------------------------- ### Install BWA using Homebrew Source: https://planemo.readthedocs.io/en/latest/writing_advanced Installs the BWA package using the Homebrew package manager on macOS or Linux. This is an alternative to conda installation. ```bash $ brew install homebrew/science/bwa ``` -------------------------------- ### Initialize Tutorial from Existing (Python) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial This method initializes a `Tutorial` instance by loading metadata and content from an existing tutorial file (`tutorial.md`). It parses YAML metadata from the file header, extracts the tutorial title, Zenodo link, questions, objectives, time estimation, key points, and contributors. It also loads the tutorial body and initializes the data library. ```python def init_from_existing_tutorial(self, tuto_name): """Init a tutorial instance from an existing tutorial (data library and tutorial.md).""" self.name = tuto_name self.set_dir_name() if not self.exists(): raise Exception("The tutorial %s does not exists. It should be created" % self.name) # get the metadata information of the tutorial (from the top of the tutorial.md) with open(self.tuto_fp) as tuto_f: tuto_content = tuto_f.read() regex = r"^---\n(?P[\s\S]*)\n---(?P[\s\S]*)" tuto_split_regex = re.search(regex, tuto_content) if not tuto_split_regex: raise Exception("No metadata found at the top of the tutorial") metadata = yaml.safe_load(tuto_split_regex.group("metadata")) self.title = metadata["title"] self.zenodo_link = metadata["zenodo_link"] self.questions = metadata["questions"] self.objectives = metadata["objectives"] self.time_estimation = metadata["time_estimation"] self.key_points = metadata["key_points"] self.contributors = metadata["contributors"] # the tutorial content self.body = tuto_split_regex.group("body") # get the data library self.init_data_lib() ``` -------------------------------- ### Hands-on Section Example Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial Provides a template for a hands-on section in a tutorial, including a title and a list of steps. It utilizes Jinja2 snippets for importing reusable content and demonstrates dataset operations like upload, rename, change datatype, and tagging. ```Markdown > Data Upload > > 1. Create a new history for this tutorial > 2. Import the files from [Zenodo]({{ '{{' }} page.zenodo_link {{ '}}' }}) or from > the shared data library (`GTN - Material` -> `{{ '{{' }} page.topic_name {{ '}}' }}` > -> `{{ '{{' }} page.title {{ '}}' }}`): > > ``` > {{ z_file_links }} > ``` > ***TODO***: *Add the files by the ones on Zenodo here (if not added)* > > ***TODO***: *Remove the useless files (if added)* > > {{ '{%' }} snippet faqs/galaxy/datasets_import_via_link.md {{ '%}' }} > > {{ '{%' }} snippet faqs/galaxy/datasets_import_from_data_library.md {{ '%}' }} > > 3. Rename the datasets > 4. Check that the datatype > > {{ '{%' }} snippet faqs/galaxy/datasets_change_datatype.md datatype="datatypes" {{ '%}' }} > > 5. Add to each database a tag corresponding to ... > > {{ '{%' }} snippet faqs/galaxy/datasets_add_tag.md {{ '%}' }} > > {: .hands_on} ``` -------------------------------- ### Install Planemo with Conda Source: https://planemo.readthedocs.io/en/latest/_sources/installation Installs Planemo using Conda, a package and environment management system. This method is considered experimental and may have issues when running Galaxy. ```shell conda config --add channels bioconda conda config --add channels conda-forge conda install planemo ``` -------------------------------- ### Initialize BWA Project with Planemo Source: https://planemo.readthedocs.io/en/latest/writing_advanced Creates a new mini-project for a BWA-MEM tool using Planemo's `project_init` command. This sets up the basic file structure, including the tool's XML definition. ```bash $ planemo project_init --template bwa bwa $ cd bwa ``` -------------------------------- ### Initialize Tutorial Instance (Python) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial The `Tutorial` class in Python is designed to represent a training tutorial. Its constructor initializes various attributes such as training, topic, name, title, Zenodo link, and placeholders for associated content like questions, objectives, and key points. It also sets up initial workflow and data library configurations. ```python from planemo.training import templates from planemo.training.data_manager import get_empty_input, get_empty_param import os import collections import re import yaml class Tutorial: """Class to describe a training tutorial.""" def __init__(self, training, topic, name="new_tuto", title="The new tutorial", zenodo_link=""): """Init a tutorial instance.""" self.training = training self.topic = topic self.name = name self.title = title self.zenodo_link = zenodo_link self.zenodo_file_links = [] self.questions = [] self.objectives = [] self.time = "" self.key_points = [] self.contributors = [] self.body = "" self.init_wf_fp = None self.init_wf_id = None self.hands_on = True self.slides = False self.set_dir_name() self.init_data_lib() self.body = templates.render( templates.HANDS_ON_TOOL_BOX_TEMPLATE, **{"tool_name": "My Tool", "inputlist": get_empty_input(), "paramlist": get_empty_param()}, ) ``` -------------------------------- ### Install Planemo with uv Source: https://planemo.readthedocs.io/en/latest/_sources/installation Installs or upgrades Planemo using uv, a modern Python package manager. This method simplifies environment management by setting up a global shim. ```shell uv tool install planemo ``` ```shell uv tool upgrade planemo ``` -------------------------------- ### Install Planemo with pip Source: https://planemo.readthedocs.io/en/latest/_sources/installation Installs or upgrades Planemo using pip, the standard Python package installer. Requires pip version 7.0 or newer and Python 3.8 or newer. This method involves setting up a virtual environment. ```shell python -m venv planemo . planemo/bin/activate pip install planemo ``` ```shell . planemo/bin/activate pip install -U planemo ``` ```shell pip install -U git+git://github.com/galaxyproject/planemo.git ``` -------------------------------- ### Clone and Navigate Workflow Repository Source: https://planemo.readthedocs.io/en/latest/running This command sequence clones the workflow testing repository and navigates into the example3 directory, which contains workflow definition and configuration files. ```shell $ git clone https://github.com/usegalaxy-eu/workflow-testing.git $ cd workflow-testing/example3 $ ls data tutorial.ga tutorial-job.yml tutorial-tests.yml ``` -------------------------------- ### Install Planemo with rye Source: https://planemo.readthedocs.io/en/latest/_sources/installation Installs Planemo using rye, another modern Python package manager. Similar to uv, it sets up a global shim for easier environment management. ```shell rye tools install planemo ``` -------------------------------- ### Install Planemo with pip Source: https://planemo.readthedocs.io/en/latest/installation Installs Planemo in a virtual environment using pip. Requires pip version 7.0 or newer. Ensure your PATH does not contain a Conda Python if using this method. ```bash python -m venv planemo . planemo/bin/activate pip install planemo ``` -------------------------------- ### Initialize a Tool Shed Repository Configuration (.shed.yml) Source: https://planemo.readthedocs.io/en/latest/writing_appliance The `shed_init` command bootstraps a `.shed.yml` file for a new Tool Shed repository. This file contains metadata like name, owner, description, and categories. It aids in managing and publishing tools. ```bash $ planemo shed_init --name=seqtk_seq \ --owner=planemo \ --description=seqtk_seq \ --long_description="Tool that converts FASTQ to FASTA files using seqtk" \ --category="Fastq Manipulation" ``` -------------------------------- ### Upgrade Planemo with pip Source: https://planemo.readthedocs.io/en/latest/installation Upgrades an existing Planemo installation to the latest version using pip. Assumes a virtual environment is already active. ```bash . planemo/bin/activate pip install -U planemo ``` -------------------------------- ### Install BWA using Conda Source: https://planemo.readthedocs.io/en/latest/writing_advanced Installs the BWA (Burrows-Wheeler Aligner) package using the conda package manager. This is a common method for bioinformatics tools. ```bash $ conda install --force -c conda-forge -c bioconda bwa ... bwa installation ... $ bwa ``` -------------------------------- ### Download and Convert FASTQ to FASTA with Seqtk Source: https://planemo.readthedocs.io/en/latest/writing_standalone Downloads an example FASTQ file and then uses `seqtk seq -A` to convert it to FASTA format. The resulting FASTA content is then displayed. ```bash $ wget https://raw.githubusercontent.com/galaxyproject/galaxy-test-data/master/2.fastq $ seqtk seq -A 2.fastq > 2.fasta $ cat 2.fasta >EAS54_6_R1_2_1_413_324 CCCTTCTTGTCTTCAGCGTTTCTCC >EAS54_6_R1_2_1_540_792 TTGGCAGGCCAAGGCCGATGGATCA >EAS54_6_R1_2_1_443_348 GTTGCTTCTGGCGTGGGTGGGGGGG ``` -------------------------------- ### Get Latest Installable Revision (Planemo) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/shed This function retrieves the latest installable revision for a given repository in the Tool Shed. It uses the repository ID and the shed context to query the Tool Shed API. ```python def latest_installable_revision(self, ctx: "PlanemoCliContext", shed_context: ShedContext): repository_id = self.find_repository_id(ctx, shed_context) return latest_installable_revision(shed_context.tsi, repository_id) ``` -------------------------------- ### Initialize Conda Exercises Project Source: https://planemo.readthedocs.io/en/latest/writing_advanced Initializes a new Conda exercises project using a specified template and navigates into the exercise directory. This is a command-line operation to set up the environment for building Conda recipes. ```bash $ planemo project_init --template conda_exercises conda_exercises $ cd conda_exercises/exercise_2 ``` -------------------------------- ### Install Conda Requirements for Tool Source: https://planemo.readthedocs.io/en/latest/writing_advanced Installs declared tool requirements using Conda by creating an isolated environment for each. The `conda_install` command processes the tool's XML and sets up the necessary packages. ```bash $ planemo conda_install seqtk_seq.xml Install conda target CondaTarget[seqtk,version=1.2] /home/john/miniconda2/bin/conda create -y --name __seqtk@1.2 seqtk=1.2 Fetching package metadata ............... Solving package specifications: .......... Package plan for installation in environment /home/john/miniconda2/envs/__seqtk@1.2: The following packages will be downloaded: package | build ---------------------------|----------------- seqtk-1.2 | 0 29 KB bioconda The following NEW packages will be INSTALLED: seqtk: 1.2-0 bioconda zlib: 1.2.8-3 Fetching packages ... seqtk-1.2-0.ta 100% |#############################################################| Time: 0:00:00 444.71 kB/s Extracting packages ... [ COMPLETE ]|################################################################################| 100% Linking packages ... [ COMPLETE ]|################################################################################| 100% # # To activate this environment, use: # > source activate __seqtk@1.2 # # To deactivate this environment, use: # > source deactivate __seqtk@1.2 ``` -------------------------------- ### Create Hands-on Tutorial from Workflow (Python) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial This Python function creates a hands-on tutorial structure, loading content from a workflow file. It can fetch content from a running Galaxy instance or a local Galaxy instance, depending on the provided initialization parameters. It requires 'get_hands_on_boxes_from_running_galaxy' and 'get_hands_on_boxes_from_local_galaxy' functions. ```python def create_hands_on_tutorial(self, ctx): """Create tutorial structure from the workflow file (if it is provided).""" # load workflow and get hands-on body from the workflow if self.init_wf_id: if not self.training.galaxy_url: raise ValueError("No Galaxy URL given") self.body = get_hands_on_boxes_from_running_galaxy( self.init_wf_id, self.training.galaxy_url, self.training.galaxy_api_key ) elif self.init_wf_fp: self.body = get_hands_on_boxes_from_local_galaxy(self.training.kwds, self.init_wf_fp, ctx) # write tutorial body self.write_hands_on_tutorial() ``` -------------------------------- ### Setup R Environment Action Python Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/shed2tap/base Provides functionality to set up an R environment. Similar to other environment setup actions, it requires repository information and a list of R packages to install. ```python class SetupREnvironmentAction(BaseAction): action_type = "setup_r_environment" _keys = ["repo", "packages"] def __init__(self, elem): self.parse_action_repo(elem) self.parse_package_elems(elem) ``` -------------------------------- ### Download and Convert FASTQ to FASTA with Seqtk Source: https://planemo.readthedocs.io/en/latest/writing_cwl_appliance Downloads an example FASTQ file and uses `seqtk seq -A` to convert it into FASTA format. The output is then displayed using `cat`. ```bash $ wget https://raw.githubusercontent.com/galaxyproject/galaxy-test-data/master/2.fastq $ seqtk seq -A 2.fastq > 2.fasta $ cat 2.fasta >EAS54_6_R1_2_1_413_324 CCCTTCTTGTCTTCAGCGTTTCTCC >EAS54_6_R1_2_1_540_792 TTGGCAGGCCAAGGCCGATGGATCA >EAS54_6_R1_2_1_443_348 GTTGCTTCTGGCGTGGGTGGGGGGG ``` -------------------------------- ### Upgrade Planemo with uv Source: https://planemo.readthedocs.io/en/latest/installation Upgrades Planemo to the latest version using the uv package manager. ```bash uv tool upgrade planemo ``` -------------------------------- ### Generate Hands-On Boxes from Workflow - Python Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial This function iterates through workflow steps, retrieves tool parameters and descriptions, and formats them into 'hands-on' boxes. It uses a `GalaxyInstance` object (`gi`) to fetch tool details and a template engine to render the output. Dependencies include `GalaxyInstance`, `ToolInput`, and a `templates` module with `HANDS_ON_TOOL_BOX_TEMPLATE`. ```python def format_wf_steps(wf, gi): """Get a string with the hands-on boxes describing the different steps of the worklow.""" body = "" steps = wf["steps"] for s in range(len(steps)): wf_step = steps[str(s)] # get params in workflow wf_param_values = {} if wf_step["tool_state"] and wf_step["input_connections"]: wf_param_values = get_wf_param_values(wf_step["tool_state"], get_wf_inputs(wf_step["input_connections"])) if not wf_param_values: continue # get tool description try: tool_desc = gi.tools.show_tool(wf_step["tool_id"], io_details=True) except Exception: tool_desc = {"inputs": []} # get formatted param description paramlist = "" for inp in tool_desc["inputs"]: if inp["name"].startswith("__"): continue tool_inp = ToolInput(inp, wf_param_values, steps, 1, should_be_there=True) paramlist += tool_inp.get_formatted_desc() # format the hands-on box body += templates.render( HANDS_ON_TOOL_BOX_TEMPLATE, **{"tool_name": wf_step["name"], "tool_id": wf_step["tool_id"], "paramlist": paramlist}, ) return body ``` -------------------------------- ### Initialize Conda with Planemo Source: https://planemo.readthedocs.io/en/latest/writing_advanced_cwl This code snippet demonstrates the command used to initialize Conda with Planemo. It requires a pre-existing Conda installation. The command `planemo conda_init` performs the necessary setup for Conda-related commands within Planemo, including downloading and installing Conda if not already present, and then configuring it to manage software requirements. The output shows the progress of the Conda installation and subsequent package installations. ```bash $ planemo conda_init galaxy.tools.deps.conda_util INFO: Installing conda, this may take several minutes. wget -q --recursive -O /var/folders/78/zxz5mz4d0jn53xf0l06j7ppc0000gp/T/conda_installLW5zn1.sh https://repo.continuum.io/miniconda/Miniconda3-4.3.31-MacOSX-x86_64.sh bash /var/folders/78/zxz5mz4d0jn53xf0l06j7ppc0000gp/T/conda_installLW5zn1.sh -b -p /Users/john/miniconda3 PREFIX=/Users/john/miniconda3 installing: python-3.6.3-h47c878a_7 ... Python 3.6.3 :: Anaconda, Inc. installing: ca-certificates-2017.08.26-ha1e5d58_0 ... installing: conda-env-2.6.0-h36134e3_0 ... installing: libcxxabi-4.0.1-hebd6815_0 ... installing: tk-8.6.7-h35a86e2_3 ... installing: xz-5.2.3-h0278029_2 ... installing: yaml-0.1.7-hc338f04_2 ... installing: zlib-1.2.11-hf3cbc9b_2 ... installing: libcxx-4.0.1-h579ed51_0 ... installing: openssl-1.0.2n-hdbc3d79_0 ... installing: libffi-3.2.1-h475c297_4 ... installing: ncurses-6.0-hd04f020_2 ... installing: libedit-3.1-hb4e282d_0 ... installing: readline-7.0-hc1231fa_4 ... installing: sqlite-3.20.1-h7e4c145_2 ... installing: asn1crypto-0.23.0-py36h782d450_0 ... installing: certifi-2017.11.5-py36ha569be9_0 ... installing: chardet-3.0.4-py36h96c241c_1 ... installing: idna-2.6-py36h8628d0a_1 ... installing: pycosat-0.6.3-py36hee92d8f_0 ... installing: pycparser-2.18-py36h724b2fc_1 ... installing: pysocks-1.6.7-py36hfa33cec_1 ... installing: python.app-2-py36h54569d5_7 ... installing: ruamel_yaml-0.11.14-py36h9d7ade0_2 ... installing: six-1.11.0-py36h0e22d5e_1 ... installing: cffi-1.11.2-py36hd3e6348_0 ... installing: setuptools-36.5.0-py36h2134326_0 ... installing: cryptography-2.1.4-py36h842514c_0 ... installing: wheel-0.30.0-py36h5eb2c71_1 ... installing: pip-9.0.1-py36h1555ced_4 ... installing: pyopenssl-17.5.0-py36h51e4350_0 ... installing: urllib3-1.22-py36h68b9469_0 ... installing: requests-2.18.4-py36h4516966_1 ... installing: conda-4.3.31-py36_0 ... installation finished. /Users/john/miniconda3/bin/conda install -y --override-channels --channel iuc --channel conda-forge --channel bioconda --channel defaults conda=4.3.33 conda-build=2.1.18 Fetching package metadata ................... Solving package specifications: . Package plan for installation in environment /Users/john/miniconda3: The following NEW packages will be INSTALLED: beautifulsoup4: 4.6.0-py36_0 conda-forge conda-build: 2.1.18-py36_0 conda-forge conda-verify: 2.0.0-py36_0 conda-forge filelock: 3.0.4-py36_0 conda-forge jinja2: 2.10-py36_0 conda-forge markupsafe: 1.0-py36_0 conda-forge pkginfo: 1.4.2-py36_0 conda-forge pycrypto: 2.6.1-py36_1 conda-forge pyyaml: 3.12-py36_1 conda-forge The following packages will be UPDATED: conda: 4.3.31-py36_0 --> 4.3.33-py36_0 conda-forge beautifulsoup4 100% |###################################################################| Time: 0:00:00 782.08 kB/s filelock-3.0.4 100% |###################################################################| Time: 0:00:00 7.95 MB/s markupsafe-1.0 100% |###################################################################| Time: 0:00:00 5.82 MB/s pkginfo-1.4.2- 100% |###################################################################| Time: 0:00:00 1.18 MB/s pycrypto-2.6.1 100% |###################################################################| Time: 0:00:00 1.69 MB/s pyyaml-3.12-py 100% |###################################################################| Time: 0:00:00 3.31 MB/s conda-verify-2 100% |###################################################################| Time: 0:00:00 6.91 MB/s jinja2-2.10-py 100% |###################################################################| Time: 0:00:00 2.81 MB/s conda-4.3.33-p 100% |###################################################################| Time: 0:00:00 621.27 kB/s conda-build-2. 100% |###################################################################| Time: 0:00:00 2.16 MB/s Conda installation succeeded - Conda is available at '/Users/john/miniconda3/bin/conda' ``` -------------------------------- ### Write Hands-on Tutorial Content (Python) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/training/tutorial This Python function writes the content of a hands-on tutorial to its corresponding file. It can optionally include Zenodo file links and renders the content using templates. Dependencies include the 'templates' module. ```python def write_hands_on_tutorial(self, add_z_file_links=True): """Write the content of the hands-on tutorial in the corresponding file.""" if add_z_file_links: self.body = templates.render( TUTO_HAND_ON_BODY_TEMPLATE, **{"z_file_links": "\n> ".join(self.zenodo_file_links), "body": self.body}, ) # write in the tutorial file with the metadata on the top metadata = self.get_tuto_metata() with open(self.tuto_fp, "w") as md: md.write(templates.render(TUTO_HAND_ON_TEMPLATE, **{"metadata": metadata, "body": self.body})) # create the bibliography file self.write_bibliography() ``` -------------------------------- ### Setup Development Virtual Environment Source: https://planemo.readthedocs.io/en/latest/contributing This command sets up a virtual environment for local development of Planemo, assuming you have virtualenvwrapper installed. This isolates project dependencies. ```bash $ make setup-venv ``` -------------------------------- ### Convert Install Arguments to Runnables via API (Python) Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/runnable_resolve Takes a list of installation arguments (containing tool shed URL, repository name, owner, and changeset revision) and converts them into a list of Runnable objects. It makes an API call to the Galaxy tool shed to fetch installation information, extracts valid tools from the repository metadata, and then uses `for_runnable_identifier` to resolve each tool's GUID into a Runnable. ```python import requests def install_args_list_to_runnables(ctx, install_args_list, kwds): runnables = [] for repo in install_args_list: base_tool_shed_url = repo["tool_shed_url"].rstrip("/") url = f"{base_tool_shed_url}/api/repositories/get_repository_revision_install_info" response = requests.get( url, params={"name": repo["name"], "owner": repo["owner"], "changeset_revision": repo["changeset_revision"]} ) response.raise_for_status() install_info = response.json() repository_metadata = install_info[1] assert repository_metadata and repository_metadata["model_class"] == "RepositoryMetadata", repository_metadata for tool in repository_metadata.get("valid_tools", []): runnable = for_runnable_identifier(ctx, tool["guid"], kwds) runnables.append(runnable) return runnables ``` -------------------------------- ### Initialize CWL Tool with Example Command and Files Source: https://planemo.readthedocs.io/en/latest/writing_cwl_appliance Generates a CWL tool definition using Planemo, incorporating an example command, input file, and output file. This helps in automatically populating input/output and command structures. ```bash $ planemo tool_init --force \ --cwl \ --id 'seqtk_seq' \ --name 'Convert to FASTA (seqtk)' \ --example_command 'seqtk seq -A 2.fastq > 2.fasta' \ --example_input 2.fastq \ --example_output 2.fasta ``` -------------------------------- ### Initialize Galaxy Tool with `planemo tool_init` Source: https://planemo.readthedocs.io/en/latest/writing_appliance Initializes a new Galaxy tool using `planemo tool_init`. This command can leverage `--help_from_command` to generate tool XML structure and help text from a command-line utility's help message. It also supports adding requirements, example inputs/outputs, and test cases. ```bash $ planemo tool_init --force \ --id 'seqtk_seq' \ --name 'Convert to FASTA (seqtk)' \ --requirement seqtk@1.2 \ --example_command 'seqtk seq -A 2.fastq > 2.fasta' \ --example_input 2.fastq \ --example_output 2.fasta \ --test_case \ --cite_url 'https://github.com/lh3/seqtk' \ --help_from_command 'seqtk seq' ``` -------------------------------- ### Basic Perl Script Example Source: https://planemo.readthedocs.io/en/latest/writing_appliance This is a basic template for a Perl script. It includes a shebang line and the `-w` flag for enabling warnings, indicating a standard starting point for bioinformatics scripts. ```perl #!/usr/bin/perl -w ``` -------------------------------- ### Serve a Tool from the Tool Shed Locally Source: https://planemo.readthedocs.io/en/latest/writing_appliance The `shed_serve` command allows you to install and serve tools from the Tool Shed in a local Galaxy instance. This is useful for testing tools and their dependencies before wider publication. It automates the installation process. ```bash $ planemo shed_serve --shed_target local ``` -------------------------------- ### Setup Perl Environment Action Python Source: https://planemo.readthedocs.io/en/latest/_modules/planemo/shed2tap/base Defines an action to set up a Perl environment. It requires repository information and a list of packages to install. This action is part of the Planemo configuration framework. ```python class SetupPerlEnvironmentAction(BaseAction): action_type = "setup_perl_environment" _keys = ["repo", "packages"] def __init__(self, elem): self.parse_action_repo(elem) self.parse_package_elems(elem) ```