-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathSingularity.def
More file actions
142 lines (123 loc) · 7.65 KB
/
Copy pathSingularity.def
File metadata and controls
142 lines (123 loc) · 7.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Bootstrap: docker
From: ubuntu:22.04
# ============================================================================
# RaPDTool v2.3.2 - Rapid Profiling and Deconvolution Tool for metagenomes
# ----------------------------------------------------------------------------
# Reproducible build recipe. Build with:
# apptainer build --fakeroot rapdtool.sif Singularity.def
#
# NOTE: neither database is bundled, to keep the image small. Provide them at
# run time (see README):
# - mash reference -> -d $RTMASHDB
# - FOCUS k-mer db -> --focus-db $RTFOCUSDB (a dir containing db/k6)
# ============================================================================
%files
# pipeline code (paths relative to this .def)
bin/rapdtool.py /usr/local/bin/rapdtool.py
bin/rapdtool_split_bins.py /usr/local/bin/rapdtool_split_bins.py
bin/rapdtool_results.pl /usr/local/bin/rapdtool_results.pl
%post
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y --no-install-recommends \
wget ca-certificates git make gcc bzip2 procps
rm -rf /var/lib/apt/lists/*
# ---- Miniforge in /opt/miniconda3 -------------------------------------
# Miniforge (community conda-forge installer): its base env has no Anaconda
# 'defaults' channel and no conda-anaconda-tos package (avoids the defaults ToS
# gate and the base-env python 3.14 conflict of the latest Miniconda).
wget -q https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O /tmp/mc.sh
bash /tmp/mc.sh -b -p /opt/miniconda3 && rm /tmp/mc.sh
export PATH=/opt/miniconda3/bin:$PATH
# ---- Tools in a DEDICATED env (isolated from base conda/mamba lib pins) ----
# The 2024-era tool builds fail to install into base because Miniforge's base
# mamba pins modern libcurl/xz/zlib that conflict with metabat2=2.15. A fresh
# env lets the solver pick the known-good combination.
# NOTE: setuptools<81 keeps pkg_resources, which focus_app imports (removed in 81+).
conda create -y -n rt --override-channels -c conda-forge -c bioconda \
python=3.12 'setuptools<81' focus=1.8 metabat2=2.15 mash=2.3 hmmer=3.4 \
prodigal=2.6.3 entrez-direct=21.6 perl-app-cpanminus
ENV=/opt/miniconda3/envs/rt
export PATH=$ENV/bin:$PATH
# python tools into the env
$ENV/bin/pip install --no-cache-dir miComplete==1.1.1 Binning_refiner==1.4.3
# Patch miComplete for modern Biopython: Bio.SeqUtils.GC was removed in Biopython
# 1.80+ (this env has newer), replaced by gc_fraction. Without this, miComplete
# crashes on import and full mode leaves Completeness/Redundancy empty.
PSEQ=$(find $ENV/lib -path '*/micomplete/parseseqs.py' | head -1)
sed -i 's/from Bio.SeqUtils import GC/from Bio.SeqUtils import gc_fraction/; s/round(GC(/round(gc_fraction(/' "$PSEQ"
# FOCUS ships a ~216 MB k-mer database (db/k6) inside its package; remove it
# so it can be provided externally via --focus-db/$RTFOCUSDB.
find $ENV -type d -path '*/focus_app/db' -exec rm -rf {} + 2>/dev/null || true
# ---- KronaTools (text import; no taxonomy DB needed) -------------------
git clone https://github.com/marbl/Krona /opt/Krona || true
if [ -d /opt/Krona/KronaTools ]; then
cd /opt/Krona/KronaTools && ./install.pl --prefix /opt/KronaTools || true
fi
# ---- Perl reporting module into the env's perl -----------------------
# Not on conda; installed from CPAN via cpanm (needs 'make', installed above).
# Version pinned for reproducibility. NO '|| true' here — a failure must abort.
# rapdtool_results.pl sizes its own columns since v2.3.2, so plain
# Text::SimpleTable suffices (::AutoWidth also pulled Moo and Type::Tiny).
$ENV/bin/cpanm --notest Text::SimpleTable@2.07
chmod +x /usr/local/bin/rapdtool.py /usr/local/bin/rapdtool_split_bins.py \
/usr/local/bin/rapdtool_results.pl
# ---- Self-check: FAIL the build if any essential component is missing --
# (the install steps above tolerate transient issues; this gate ensures we never
# ship a "successful" but broken image — missing Krona / Perl module / focus_app)
export PATH=/opt/KronaTools/bin:$PATH # KronaTools installs here (mirrors runtime %environment)
command -v ktImportText >/dev/null || { echo 'BUILD ERROR: KronaTools (ktImportText) missing'; exit 1; }
$ENV/bin/perl -MText::SimpleTable -e1 || { echo 'BUILD ERROR: Perl module Text::SimpleTable missing'; exit 1; }
$ENV/bin/python -c 'import focus_app.focus' || { echo 'BUILD ERROR: focus_app import failed (pkg_resources?)'; exit 1; }
for t in focus metabat2 mash miComplete Binning_refiner esearch; do
command -v "$t" >/dev/null || { echo "BUILD ERROR: $t missing"; exit 1; }
done
# miComplete/Binning_refiner must actually import & run (not just be on PATH)
miComplete --help >/dev/null 2>&1 || { echo 'BUILD ERROR: miComplete not runnable (Biopython GC/gc_fraction?)'; exit 1; }
Binning_refiner --help >/dev/null 2>&1 || { echo 'BUILD ERROR: Binning_refiner not runnable'; exit 1; }
# ---- Slim the image (safe, runtime-only footprint) --------------------
conda clean -a -y || true
MC=/opt/miniconda3
SP=$ENV/lib/python3.12/site-packages
rm -rf $MC/pkgs /tmp/mc.sh
find $ENV -name '*.a' -delete 2>/dev/null || true
find $ENV -name '*.o' -delete 2>/dev/null || true
find $MC -name '__pycache__' -type d -prune -exec rm -rf {} + 2>/dev/null || true
# test suites, type stubs and sample data of heavy python pkgs (scipy/numpy/matplotlib/Bio...)
find $SP -type d -name tests -prune -exec rm -rf {} + 2>/dev/null || true
find $SP/numpy $SP/scipy -name '*.pyi' -delete 2>/dev/null || true
rm -rf $SP/matplotlib/mpl-data/sample_data $SP/pip $SP/pip-*.dist-info
# HMMER easel source tree, conda docs/man/info/locale
rm -rf $ENV/share/easel $ENV/share/doc $ENV/share/man $MC/share/doc $MC/share/man $MC/share/info
# unused stdlib + tkinter/tcl-tk (matplotlib runs headless via MPLBACKEND=Agg)
rm -rf $ENV/lib/python3.12/idlelib $ENV/lib/python3.12/ensurepip \
$ENV/lib/python3.12/lib2to3 $ENV/lib/python3.12/test \
$ENV/lib/python3.12/tkinter $ENV/lib/python3.12/lib-dynload/_tkinter*.so \
$ENV/lib/tcl8 $ENV/lib/tcl8.6 $ENV/lib/tk8.6 $ENV/lib/libtcl8.6.so $ENV/lib/libtk8.6.so
apt-get clean
rm -rf /var/lib/apt/lists/* /var/cache/apt/* /usr/share/doc/* /var/log/*
%environment
export PATH=/opt/miniconda3/envs/rt/bin:/opt/KronaTools/bin:/usr/local/bin:$PATH
export LC_ALL=C
export MPLBACKEND=Agg # headless matplotlib (no Tk/X); lets tkinter/tcl-tk be dropped
%runscript
if [ "$#" -eq 0 ]; then
exec rapdtool.py --help
fi
exec rapdtool.py "$@"
%labels
Author Karel Estrada and Ayixon Sanchez-Reyes; pipeline maintained by the RaPDTool team
Version 2.3.2
Description RaPDTool metagenome profiling/binning/classification pipeline
%help
RaPDTool v2.3.2
Usage inside the container:
rapdtool.py -i assembly.fasta --focus-db $RTFOCUSDB [-d $RTMASHDB]
[-o out_dir] [-m full|profile|screen] [-t threads]
[-a coverage.txt] [--no-split-bins]
(full/screen need -d/$RTMASHDB; profile uses it only if given)
The databases are NOT included. Provide them via environment variables:
export RTMASHDB=/path/to/mash_database.msh
export RTFOCUSDB=/path/to/focus # a directory containing db/k6
# ----------------------------------------------------------------------------
# A prebuilt image is also attached to the GitHub Releases page; see the README.
# ----------------------------------------------------------------------------