Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
782cc93
update db script
cdiener Mar 3, 2025
805683a
update db script
cdiener Mar 3, 2025
1d2252c
add the curated IDs
cdiener Mar 17, 2025
010b3dd
add the curated IDs
cdiener Mar 17, 2025
b407a18
swich to single downloads
cdiener Mar 18, 2025
ad31b08
no duplicate matches, switch to single gb downloads
cdiener Mar 18, 2025
9e2c458
fixes from cluster
cdiener Mar 18, 2025
7fa555d
fixes from cluster
cdiener Mar 18, 2025
6ba1d04
several fixes
cdiener Mar 18, 2025
f48bd1b
local fixes
Mar 18, 2025
39c9031
move logs
cdiener Mar 18, 2025
1db29f9
only download unique
Mar 18, 2025
44dd942
fix download script
cdiener Mar 18, 2025
3465218
skip problems
Mar 18, 2025
5090479
fix download
cdiener Mar 18, 2025
9b8e13c
avoid looking for nucleotide sequences for nonredundant genera
cdiener Mar 19, 2025
da5b922
some fixes
Mar 19, 2025
9ac0568
add scores beforehand
cdiener Mar 20, 2025
1f1e4c5
add scores beforehand
cdiener Mar 20, 2025
f536e5b
add scores beforehand
cdiener Mar 20, 2025
36e0d0f
fix nucleoide logger
cdiener Mar 20, 2025
2e46374
fix nucleoide logger
cdiener Mar 20, 2025
9327d03
fix nucleoide logger
cdiener Mar 20, 2025
db0f1ab
add decoys
cdiener Mar 20, 2025
a1126a2
fix decoy add
cdiener Apr 3, 2025
12411d9
major refactor to build_kraken, now cleanly resumable
cdiener Apr 8, 2025
08072e3
major refactor to build_kraken, now cleanly resumable
cdiener Apr 8, 2025
5189543
fixes to merging
Apr 3, 2025
78a24bb
more refactor
cdiener Apr 8, 2025
86af94c
add ftp option to kraken db downloads
Apr 9, 2025
60c4a6e
further improvements to build
Apr 24, 2025
b046ff7
make compatible with new NCBI ranks
cdiener Apr 17, 2025
30447cc
several fixes to pipeline
cdiener May 5, 2025
bb0684f
remove old prefix
cdiener May 5, 2025
759f56e
add rsync option to database download to enable https downloads
cdiener Apr 9, 2025
580a100
fix scoring
cdiener Oct 31, 2025
c98f0a6
changes to matching and downloading
cdiener Nov 3, 2025
52c311d
fix match
cdiener Nov 3, 2025
1a9bd9c
fix match
cdiener Nov 3, 2025
c448541
fix match
cdiener Nov 3, 2025
85a25d4
fix match
cdiener Nov 3, 2025
da68d5a
fix match
cdiener Nov 3, 2025
6e6a3a0
fix match
cdiener Nov 3, 2025
1acbc45
fix match
cdiener Nov 3, 2025
9a825bf
fix summary
cdiener Nov 4, 2025
7bd3aa5
fix summary
cdiener Nov 4, 2025
1b85040
provide more info
cdiener Nov 4, 2025
6758c5d
provide more info
cdiener Nov 4, 2025
e532ddd
provide more info
cdiener Nov 4, 2025
4927ae0
provide more info
cdiener Nov 4, 2025
76021d9
handle missing fields in summary
cdiener Nov 4, 2025
750ace4
handle missing fields in summary
cdiener Nov 4, 2025
b42f778
remove redundant entries
cdiener Nov 4, 2025
16ae788
remove redundant entries
cdiener Nov 4, 2025
133d053
remove redundant entries
cdiener Nov 4, 2025
c27a185
fix redundant entries
cdiener Nov 4, 2025
0333006
fix redundant entries
cdiener Nov 4, 2025
773aaad
add mem
cdiener Oct 31, 2025
c9208e0
some small fixes
cdiener Nov 17, 2025
50ba29c
allow more mem for preprocessing
cdiener Nov 24, 2025
4ea06a5
check for errors too
cdiener Nov 24, 2025
165561d
handle insufficient reads for bracken
cdiener Nov 24, 2025
3592df7
handle insufficient reads for bracken
cdiener Nov 24, 2025
0060d61
add Dockerfile
cdiener Dec 2, 2025
3d30a26
add image build
cdiener Dec 2, 2025
bc7c499
see if this works
cdiener Dec 2, 2025
a0884f4
see if this works
cdiener Dec 2, 2025
8fda5e0
see if this works
cdiener Dec 2, 2025
883e965
see if this works
cdiener Dec 2, 2025
a34fde0
see if this works
cdiener Dec 2, 2025
a5814aa
see if this works
cdiener Dec 2, 2025
9805439
fix paths
cdiener Dec 2, 2025
7c6a011
add patch
cdiener Dec 2, 2025
2f9743d
add patch
cdiener Dec 2, 2025
d9a6a62
add patch
cdiener Dec 2, 2025
954268d
add patch
cdiener Dec 2, 2025
fb850f6
add patch
cdiener Dec 2, 2025
4a9cfeb
add patch
cdiener Dec 2, 2025
c3ea9d6
fix copy
cdiener Dec 2, 2025
33ce339
change entrypoint
cdiener Dec 3, 2025
45d98e9
add install script
cdiener Dec 3, 2025
90b1a84
update quant as well
cdiener Jan 29, 2026
eabc1df
Merge branch 'main' into feature/new_db
cdiener Jan 29, 2026
826991d
switch rsync to datasets CLI
cdiener May 26, 2026
560e641
use ftp for everything else
cdiener May 26, 2026
76b37e8
update docs
cdiener Aug 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and push the MEDI image

on:
push:
branches:
- "**"
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:

env:
IMAGE_NAME: cdiener/medi

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
push: ${{ contains(github.ref, 'tag') }}
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM docker.io/condaforge/miniforge3:latest

RUN mkdir /tmp/medi /tmp/medi/bin

COPY medi.yml Makefile patches/*.patch /tmp/medi

RUN mamba env create -n medi -f /tmp/medi/medi.yml && \
. ${CONDA_PREFIX}/etc/profile.d/conda.sh && conda activate medi && \
cd /tmp/medi && make report && mv /tmp/medi/bin/kraken2-report /bin && \
patch ${CONDA_PREFIX}/envs/medi/share/kraken2-2.1.3-4/libexec/build_kraken2_db.sh /tmp/medi/build.patch && \
patch ${CONDA_PREFIX}/envs/medi/share/kraken2-2.1.3-4/libexec/download_genomic_library.sh /tmp/medi/download_genomic.patch && \
conda clean --tarballs --index-cache --packages --yes && \
find ${CONDA_PREFIX} -follow -type f -name '*.a' -delete && \
find ${CONDA_PREFIX} -follow -type f -name '*.pyc' -delete && \
conda clean --force-pkgs-dirs --all --yes && \
rm -rf /tmp/medi

ENTRYPOINT ["mamba", "run", "-n", "medi"]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ CXX := g++
K2DIR := "src/kraken2"
SRC := ${K2DIR}/src

all: report patch

repo:
rm -rf ${K2DIR}
git clone https://github.com/daydream-boost/kraken2 ${K2DIR}
Expand All @@ -11,5 +13,10 @@ report: repo
${SRC}/mmap_file.cc ${SRC}/reports.cc ${SRC}/taxonomy.cc \
${SRC}/kraken2-report.cpp -o ./bin/kraken2-report

patch:
patch ${CONDA_DIR}/envs/medi/share/kraken2-2.1.3-4/libexec/build_kraken2_db.sh ./patches/build.patch && \
patch ${CONDA_DIR}/envs/medi/share/kraken2-2.1.3-4/libexec/download_genomic_library.sh ./patches/download_genomic.patch

.PHONY: clean
clean:
rm -rf ${K2DIR}
86 changes: 57 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@ It contains capabilities for the following individual functionalities:
> MEDI is built and tested on Linux only which should be the most common configuration
> due to the large resource requirements (500GB RAM).

### Install Nextflow

MEDI is nothing else than a set of Nextflow pipelines. You can install Nextflow by following
any of [the official installation instructions](https://docs.seqera.io/nextflow/install). In
case you want to set up the MEDI conda environment anyway you can also jump directly to the
last step because the MEDI conda environment comes with nextflow.

If you want to use Docker, Apptainer or Singularity we do recommend to install Nextflow
first.

### Docker and other container engines

We do provide a Docker image with a working MEDI installation. If you have Nextflow installed
no additional installation steps are necessary. Simply call the pipeline with the
`-with-docker` argument. For instance:

```bash
nextflow run $MEDI/quant.nf --db=/my/medi_db -with-docker cdiener/medi
```

To use Apptainer or Singularity simply substitute this with `-with-singularity` or `-with-apptainer`.
Nextflow will automatically download and covert the image.

### Conda

> [!WARNING]
> This is the most flexible but also most involved installation.

You will need a working miniforge or miniconda to start. YOu can follow the [installation
instructions here](https://github.com/conda-forge/miniforge?tab=readme-ov-file#install). After
create an environment with the included conda environment file.
Expand All @@ -32,6 +60,8 @@ git clone https://github.com/gibbons-lab/medi
cd medi
```

Create the conda environment.

```bash
conda env create -n medi -f medi.yml
```
Expand All @@ -42,32 +72,32 @@ After that activate the environment.
conda activate medi
```

### Compile the report generator
#### Compile the report generator and apply patches

> [!TIP]
> This will only be necessary if the provided binary does not work.
> You can test this by running `./bin/kraken2-report` if this returns
> "malformed taxonomy file" you are good. If you get errors about the
> ELF class or a missing libc version you will need to recompile.
MEDI requires some manual adjustments for Kraken2, in particular:

1. A custom report generator to process the filtered classifications from architeuthis.
2. Fixes to Kraken2 to correctly download the decoys and support symlinks during build.

Kraken2 does not support generating reports on filtered output files by default.
We provide a pre-compiled report generator from a [Kraken2 fork](https://github.com/daydream-boost/kraken2).
If this does not work you can compile it using the provided Makefile:
All of this is bundled into a Make file. So those steps can be run by activating the MEDI
environment (should aready have done this in the previous step) and running:

```bash
conda activate medi
make report
make .
```

This will compile the report generator for your platform and replace the binary.
After that MEDI can be run locally by calling the commands below. If you run on a computing
cluster you may have to pass in the conda environment, for instance:

```bash
nextflow run $MEDI/quant.nf --db=/my/medi_db -with-conda $CONDA_PREFIX/envs/medi
```

---

And you are done. If you are running this on a HPC cluster or a cloud provider, you
moght need to [adjust your nextflow settings](https://www.nextflow.io/docs/latest/config.html#config-scopes) for your setup.

All pipelines support a `--threads` parameter that defines the maximum number of threads
to use for any single process.

## Calling MEDI steps

Expand Down Expand Up @@ -97,13 +127,17 @@ nextflow run $MEDI/quant.nf --db=/my/medi_db

Both will work the same.

# MEDI steps
# Building the database

Here are the full steps to build the database and run it on your data.
Here are the full steps to build the database.

> [!NOTE]
> You can request personalized download access to the database by sending an E-mail to
> mail◎dienerlab.com that contains a Gmail address from you. I will then share the database
> with you and provide you instructions to download with rclone.
>
> If you are asking yourself why we don't just provide the built database for download
> please [see the comments here](docs/db_download.md).
> in a public repository please [see the comments here](docs/db_download.md).

## (1-2) Matching and downloading

Expand All @@ -125,25 +159,18 @@ Please also the the [troubleshooting guide](docs/db_download.md) in case you enc
After running the previous step continue with

```bash
nextflow run build_kraken.nf --max_db_size=500
nextflow run build_kraken.nf --max_db_size=600
```

Here `--max_db_size` denotes the maximum size of the database in GB. The default
will use no reduction but you can set this to a lower level which will create a
smaller but less accurate hash. Note that for good performance you will need as much
RAM as what you choose here.

Note that this step of the pipeline will not work with the `-resume` option. The `add_*` need
to finish completely or the pipeline needs to be restarted from the beginning. Should this
work and the later steps crash, you can trigger just the hash building using the
`--rebuild` option which will rebuild the database but not attempt to add sequences again.
Here `--max_db_size` denotes the maximum size of the database in GB. Unfortunately it is not
possible to know this number *a priori*, but this default should be close to what is currently needed.

> [!WARNING]
> Do not run this step with the `-resume` Nextflow option as this will result in a
> corrupted database. In case, all adding sequences worked and you only want to run the
> build step again, use the `--rebuild=true` option.

## (4) Quantification for MGS samples
# Quantification for metagenomic sequencing samples

For your own sequencing data create a directory and use either of the setups described above.

Expand Down Expand Up @@ -189,6 +216,7 @@ the taxonomic rank (S - species, G - genus, D - domain).

## TODO

- [] see if we can provide a reduced DB for download
- [x] make execution more flexible
- [x] add resource limits for individual steps for HPC clusters
- [ ] switch decoy downloads to NCBI datasets CLI
- [ ] switch Kraken2 to KunPeng
Loading