changeset 0:adc887a1a6de draft

planemo upload commit 927c4ee71df7d19ceb10446a04618af22c99d839
author galaxytrakr
date Fri, 11 Sep 2026 21:58:43 +0000
parents
children e6b5e7a0d7e7
files Dockerfile mitokmer.xml tool-data/mitokmer_probe_db.loc.sample tool_data_table_conf.xml.sample
diffstat 4 files changed, 267 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dockerfile	Fri Sep 11 21:58:43 2026 +0000
@@ -0,0 +1,91 @@
+# =============================================================
+#   Dockerfile for mitokmer2 (compatible with Galaxy/AWS Batch)
+# =============================================================
+
+# ---------- Build Stage ----------
+FROM ubuntu:focal AS build
+
+ARG DEBIAN_FRONTEND=noninteractive
+ARG PYTHON_VER="3.8"
+
+WORKDIR /workspace
+
+# Build dependencies: compiler, zlib dev headers, git, Python
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    build-essential \
+    g++ \
+    git \
+    wget \
+    zlib1g-dev \
+    ca-certificates \
+    python${PYTHON_VER} \
+    python${PYTHON_VER}-dev \
+    python${PYTHON_VER}-venv \
+    && rm -rf /var/lib/apt/lists/*
+
+# Create Python virtual environment using --copies so symlinks
+# do not break when the venv is copied to the runtime stage
+RUN python${PYTHON_VER} -m venv --copies /opt/venv
+ENV PATH="/opt/venv/bin:${PATH}"
+
+# Install Python dependencies
+RUN pip install --no-cache-dir -U pip && \
+    pip install --no-cache-dir pandas
+
+# Clone mitokmer2 source code from GitHub
+RUN git clone https://github.com/mmammel8/mitokmer2.git /opt/mitokmer2
+
+WORKDIR /opt/mitokmer2
+
+# Compile the C++ read-screening program
+# kmer_read_1.cpp -> kmerread
+RUN g++ -O3 kmer_read_1.cpp -o kmerread -lz && \
+    chmod +x kmerread
+
+# Install any Python requirements declared in the repo
+RUN if [ -f requirements.txt ]; then \
+        pip install --no-cache-dir -r requirements.txt; \
+    fi
+
+
+# ---------- Runtime Stage ----------
+FROM ubuntu:focal AS runtime
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+# Lean runtime: zlib shared library + Python runtime only
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    zlib1g \
+    libbz2-1.0 \
+    ca-certificates \
+    python3.8 \
+    python3.8-venv \
+    python3.8-distutils \
+    && rm -rf /var/lib/apt/lists/*
+
+# Copy compiled binary from build stage
+COPY --from=build /opt/mitokmer2/kmerread /usr/local/bin/kmerread
+
+# Copy Python scripts and supporting files from build stage
+COPY --from=build /opt/mitokmer2 /opt/mitokmer2
+
+# Copy Python virtual environment from build stage
+# --copies in the build stage ensures no broken symlinks here
+COPY --from=build /opt/venv /opt/venv
+
+# Refresh the dynamic linker cache so zlib and other shared
+# libraries are found at runtime
+RUN ldconfig || true
+
+# Ensure all users (including arbitrary Galaxy UIDs) can
+# read and execute binaries, scripts, and the venv
+RUN chmod a+rx  /usr/local/bin/kmerread && \
+    chmod -R a+rX /opt/mitokmer2 && \
+    chmod -R a+rX /opt/venv
+
+# Runtime environment
+ENV PATH="/opt/venv/bin:/opt/mitokmer2:/usr/local/bin:${PATH}" \
+    LC_ALL=C
+
+# IMPORTANT: No ENTRYPOINT for Galaxy/AWS Batch. Neutral CMD.
+CMD ["/bin/bash"]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mitokmer.xml	Fri Sep 11 21:58:43 2026 +0000
@@ -0,0 +1,151 @@
+<tool id="mitokmer" name="mitoKmer" version="2.0+galaxy0.1" python_template_version="3.5" profile="21.05">
+    <description>Identify metagenomic mitochondrial reads by k-mer database matching</description>
+    <requirements>
+        <container type="docker">quay.io/galaxytrakr/mitokmer2:latest</container>
+    </requirements>
+
+    <command detect_errors="exit_code"><![CDATA[
+        ## ── kmerread expects files at specific relative paths ─────────────────
+        ## ./mitoch/mitoch_probes.txt.gz  - probe database
+        ## ./jobs1/jobs1.txt              - jobs file listing sample reads
+        ## It is invoked with no arguments: ./kmerread
+        mkdir -p ./mitoch ./jobs1 ./reads &&
+
+        ## ── Link probe database to the path kmerread expects ─────────────────
+        ln -sf '${probe_db.fields.path}' ./mitoch/mitoch_probes.txt.gz &&
+
+        ## ── Stage input reads ─────────────────────────────────────────────────
+        #for read in $reads
+            ln -sf '${read}' ./reads/${read.element_identifier.replace(' ', '_')} &&
+        #end for
+
+        ## ── Write the jobs file in the format kmerread expects ───────────────
+        ## Line 1: <sample_name> <number_of_files>
+        ## Lines 2+: absolute path to each read file, one per line
+        #set sample_name = $reads[0].element_identifier.replace(' ', '_').split('_')[:-1] | join('_')
+        echo "${sample_name} ${reads|length}" > ./jobs1/jobs1.txt &&
+        #for read in $reads
+            echo "\$PWD/reads/${read.element_identifier.replace(' ', '_')}" >> ./jobs1/jobs1.txt &&
+        #end for
+
+        ## ── Run kmerread (reads jobs1/jobs1.txt and mitoch/mitoch_probes.txt.gz
+        ##    by convention; no CLI arguments) ──────────────────────────────────
+        kmerread &&
+
+        ## ── Summarise results into CSV ────────────────────────────────────────
+        python3 /opt/mitokmer2/kmer_read_m7.py
+            -i ./jobs1
+            -o '${results_csv}'
+    ]]></command>
+
+    <inputs>
+        <!-- Probe database selected from Galaxy data table -->
+        <param name="probe_db"
+               type="select"
+               label="Mitochondrial k-mer probe database"
+               help="Select a pre-installed mitochondrial k-mer probe database.
+                     Databases are managed by your Galaxy administrator via the
+                     mitokmer_probe_db data table.">
+            <options from_data_table="mitokmer_probe_db">
+                <filter type="sort_by" column="1" />
+                <validator type="no_options"
+                           message="No mitochondrial k-mer probe databases are
+                                    currently installed. Please contact your
+                                    Galaxy administrator." />
+            </options>
+        </param>
+
+        <!-- One or more FASTQ/FASTA files for a single sample -->
+        <param name="reads"
+               type="data_collection"
+               collection_type="list"
+               format="fastq,fastq.gz,fasta,fasta.gz"
+               label="Input reads (FASTQ or FASTA, gzipped or plain)"
+               help="Provide one or more read files for a single sample as a Galaxy
+                     list collection.  Paired-end files (R1 + R2) should both be
+                     included in the same collection.  Light quality trimming of
+                     read ends is performed internally; pre-trimming is optional." />
+    </inputs>
+
+    <outputs>
+        <data name="results_csv"
+              format="csv"
+              label="mitoKmer results for ${on_string}" />
+    </outputs>
+
+    <tests>
+        <test>
+            <param name="probe_db" value="mitoch_probes_sample" />
+            <param name="reads">
+                <collection type="list">
+                    <element name="Plodia_R1" value="test/Plodia_R1.fastq.gz" />
+                    <element name="Plodia_R2" value="test/Plodia_R2.fastq.gz" />
+                </collection>
+            </param>
+            <output name="results_csv">
+                <assert_contents>
+                    <has_text text="Plodia" />
+                </assert_contents>
+            </output>
+        </test>
+    </tests>
+
+    <help><![CDATA[
+**mitoKmer** — Metagenomic Mitochondrial Read Identification by K-mer Database
+===============================================================================
+
+Overview
+--------
+mitoKmer identifies the taxonomic origin of short-read shotgun sequencing data
+by matching reads against a database of species-specific mitochondrial k-mer
+probes.  It reports the relative abundance of taxa at multiple taxonomic ranks
+(e.g. order, species) along with the number of matching reads and supporting
+unique k-mers.
+
+Inputs
+------
+**Mitochondrial k-mer probe database**
+    Select a pre-installed probe database from the dropdown.  Databases are
+    managed by your Galaxy administrator and registered in the
+    ``mitokmer_probe_db`` data table.
+
+**Input reads**
+    One or more FASTQ or FASTA files (gzipped or plain) for a single sample,
+    supplied as a Galaxy list collection.  Both paired-end files (R1 and R2)
+    should be included in the same collection.
+
+    * Pre-trimming is optional — the tool performs simple window-based quality
+      trimming of read ends internally.
+
+Output
+------
+**Results CSV**
+    A comma-separated file summarising the relative abundance of each taxon
+    detected in the sample.  Columns include taxon name, taxonomic rank, number
+    of reads assigned, relative abundance (%), and the number of unique k-mers
+    supporting the assignment.
+
+    Example output for the "Plodia" test sample::
+
+        Rank    Taxon                   Reads   Rel_Abund(%)   Unique_kmers
+        Order   Lepidoptera             10      0.1            329
+        Species Plodia interpunctella   462     99.9           466
+
+Citation
+--------
+Please cite the mitoKmer GitHub repository if you use this tool in published work.
+    ]]></help>
+
+    <citations>
+        <citation type="bibtex">
+@misc{githubmitokmer2,
+  author    = {Mammel, Mark},
+  title     = {mitoKmer2},
+  year      = {2024},
+  publisher = {GitHub},
+  journal   = {GitHub repository},
+  url       = {https://github.com/mmammel8/mitokmer2},
+}
+        </citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/mitokmer_probe_db.loc.sample	Fri Sep 11 21:58:43 2026 +0000
@@ -0,0 +1,18 @@
+# mitoKmer Probe Database Location File
+# 
+# This file lists the mitochondrial k-mer probe databases available to mitoKmer.
+# Entries are tab-separated; do NOT use spaces as delimiters.
+#
+# Columns (tab-separated):
+#   value  - unique identifier used internally by Galaxy (no spaces)
+#   name   - human-readable label shown in the tool dropdown
+#   path   - absolute path to the gzipped probe file (mitoch_probes.txt.gz)
+#
+# Example entry (remove the leading # to activate):
+#
+# mito_v1	Mitochondrial DB v1	/galaxy/tool-data/mitokmer/mitoch_probes_v1.txt.gz
+#
+# Multiple databases can be listed, one per line:
+#
+# mito_insects_v1	Insect Mitochondrial DB v1	/galaxy/tool-data/mitokmer/mitoch_probes_insects_v1.txt.gz
+# mito_vertebrates_v1	Vertebrate Mitochondrial DB v1	/galaxy/tool-data/mitokmer/mitoch_probes_vertebrates_v1.txt.gz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Fri Sep 11 21:58:43 2026 +0000
@@ -0,0 +1,7 @@
+<!-- Use the file tool_data_table_conf.xml.oldlocstyle if you don't want to update your loc files as changed in revision 4550:535d276c92bc-->
+<tables>
+    <table name="mitokmer_probe_db" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/mitokmer_probe_db.loc" />
+    </table>
+</tables>
\ No newline at end of file