Skip to content

Quick start

This example runs BacFlux on Illumina paired-end reads. Prepare the required databases, obtain the repository, create the Snakemake environment and edit a copy of the configuration. Check the plan with a dry run before starting the analysis. For other input types, see Choosing a mode.

Terms used on this page

GTDB Genome Taxonomy Database, the reference used for taxonomic placement
QC quality control
# 1. Clone
git clone https://github.com/iLivius/BacFlux.git
cd BacFlux

# 2. Launcher environment (Snakemake only; the analysis tools are installed later,
#    per rule, by conda)
conda create -c conda-forge -c bioconda -n snakemake snakemake=9.27.1
conda activate snakemake

# 3. Make your own copy of the config, then edit the copy
cp config/config.yaml config/config_custom.yaml

# Continue with database preparation and configuration below before running BacFlux.

Run these from the repository root. workflow/Snakefile is found there automatically, which is why it never appears on the command line. Paths inside the config are used as you wrote them, so a relative one resolves against the directory you launched from, not against the config file — use absolute paths. output_dir and the optional database paths are resolved to absolute paths for you.

Steps 1 and 2 in more detail, including which few rules run outside a conda environment: installation.

The config must be named on the command line

BacFlux ships no default configfile:, deliberately: Snakemake merges a hard-coded default with the file you pass, so a missing key in your copy would be quietly filled in from the shipped example — an empty database path, or a download link you did not choose — instead of stopping. Launching without --configfile gives you:

[BacFlux] No configuration supplied. Pass one explicitly, e.g.:
  snakemake --sdm conda --cores N --configfile config/config.yaml

Before step 3 — five databases you supply

Five references are too large, or too tied to one release, for the workflow to fetch for you. You download them once and give BacFlux the path:

Config key Database Required database version
directories.bakta_db Bakta v6.0 (Bakta 1.12.1 refuses older ones)
directories.blast_db NCBI core_nt (or nt_prok, named in parameters.nt_version), plus the taxonomy files —
directories.eggnog_db eggNOG diamond database v5.0.2 (fixed by the eggnog-mapper pin)
directories.gtdbtk_db GTDB R232 (GTDB-Tk 2.7.2 pins itself to one release)
directories.platon_db Platon v1.5.0 (versioned separately from Platon 1.8)

Everything else — PhiX, CARD, CheckV, dbCAN, VirSorter2, antiSMASH — is downloaded by the workflow into output_dir on the first run. All of those but PhiX also have an optional directories.*_db key: point it at a copy you already hold and nothing is fetched. Download recipes, sizes and the eight optional keys are on reference databases.

Step 3 — the keys that decide a run

Your copy of config/config.yaml is long, but almost all of it is tuning that can stay as shipped. These are the keys an Illumina run cannot start without:

mode: illumina

input:
  illumina_dir: /data/reads/illumina        # {sample}_R1.<ext> + {sample}_R2.<ext>

directories:
  output_dir: /data/results/run1            # everything is written here
  bakta_db:   /data/db/bakta/db
  blast_db:   /data/db/NCBI_core_nt
  eggnog_db:  /data/db/eggnog
  gtdbtk_db:  /data/db/release232
  platon_db:  /data/db/platon/db

links:
  phix_link:  https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/819/615/GCF_000819615.1_ViralProj14015/GCF_000819615.1_ViralProj14015_genomic.fna.gz
  card_link:  https://card.mcmaster.ca/download/0/broadstreet-v4.0.2.tar.bz2
  dbcan_link: https://zenodo.org/records/18622157/files/dbcan_db_v5.1.2.tar.gz

resources:
  threads: 16
  ram_gb:  64

dbcan_link already carries that value in the shipped config; phix_link and card_link are empty and required in illumina and hybrid mode — they feed the PhiX removal step and the read-based CARD screen, neither of which exists in the other two modes. Every key, with its default and what it trades off, is in configuration.

Input files are found by pattern, not listed by hand. BacFlux globs illumina_dir for {sample}_R1.<ext> files, rebuilds the R2 path per sample, and the part before _R1 becomes the sample name used in every output file:

/data/reads/illumina/
├── isolate1_R1.fastq.gz
├── isolate1_R2.fastq.gz
├── isolate2_R1.fastq.gz
└── isolate2_R2.fastq.gz         →  samples isolate1 and isolate2

All files of one kind must share one extension (fastq, fq, fastq.gz or fq.gz); mixing them stops the run. Sample names become filenames and locus tags, so fifteen characters are refused outright — * # @ % ^ / ! space ? & : ; | < > — and everything else, underscores and dots included, is accepted.

Edit a copy, not the shipped file

config/config_custom.yaml is the one name .gitignore already knows, so a copy under that name survives a git pull and never lands in a commit. Any other name runs just as well but is not ignored. Either way, leave config/config.yaml alone so you always have the commented template to read.

Step 4 — the dry run

After completing database preparation and configuration, preview the jobs:

snakemake --sdm conda --configfile config/config_custom.yaml --cores 24 -n

-n (--dry-run) plans the analysis without executing jobs. It checks input discovery and the configuration conditions evaluated during planning. Inspect the header to confirm the selected mode, analysis options and samples:

… BacFlux banner …

Mode: illumina — Genomic analysis of bacterial Illumina reads.
Phage caller: virsorter2 (default). Plasmid stage: Platon-only (geNomad off).
Decontamination mode: auto (auto_vote=bp, discard_no_hit=true).
Using CheckV database from link: 'https://zenodo.org/records/21510554/files/checkv-db-v1.5.tar.gz' (db_id='checkv-db-v1.5').
Sample isolate1 will be processed.

Each of those lines is a decision you can still change: the mode, the virus caller, the decontamination policy, and every database that is being downloaded rather than read from a copy you hold. When the mobilome module is on it announces itself here too.

Compare the discovered sample list with the intended input. A mismatch can indicate a naming-pattern problem, a missing input file or an incorrect directory. Below the header, Snakemake lists the jobs. A single isolate through the default Illumina pipeline, into an empty output directory, plans 44 jobs, listed in the order they can run:

Job stats:
job                                count
-------------------------------  -------
abricate_databases                     1
cazyme_db_download                     1
checkv_db                              1
…
amr_contigs                            4
…
amr_workbook                           1
multiqc                                1
all                                    1
total                                 44

The only count above one is amr_contigs: ABRicate runs once per database.

What is checked before the first job starts, and what each failure looks like:

[BacFlux] mode=illumina requires 'input.illumina_dir' to be set in the config.
[BacFlux] input.illumina_dir is not an existing directory: '/nope/reads'
[BacFlux] mode=illumina removes PhiX spike-in reads before assembly, which requires 'links.phix_link' to be set in the config.
[BacFlux] mode=illumina runs the read-based CARD AMR leg, which requires 'links.card_link' to be set in the config.
[BacFlux] directories.bakta_db is missing or empty, but every run needs it. Set it in your config (config/config.yaml lists every key).
[BacFlux] directories.checkv_db points at '/data/db/checkv', which is not a directory. …
[BacFlux] Missing Illumina mate pair for sample 'isolate1': /data/reads/illumina/isolate1_R2.fastq.gz
[BacFlux] Sample name 'isolate 1' contains characters that are not allowed (' '). Rename the input files.

Each of them stops Snakemake with exit status 1, so a wrapper script or a cluster job that launched the run sees it fail.

A config with no mode at all stops with a KeyError: 'mode' from workflow/rules/shared/00_common.smk, rather than guessing a pipeline.

The database check finds the right folder, not a complete database

Each of the five required directories.*_db paths must be an existing directory holding one file that only a real copy of that database has, so a typo, an empty path or the folder one level above the database stops the run here:

[BacFlux] directories.gtdbtk_db is '/data/db/GTDB_R232', but it has no 'metadata/metadata.txt'. Point it at the GTDB-Tk release folder itself (release232/ for R232), …

The databases themselves are not opened while the plan is built, so a copy that is incomplete or of the wrong release surfaces only when its tool runs. A dry run that reaches the job table means the plan is sound, not that every database is complete.

Step 5 — the run

snakemake --sdm conda --configfile config/config_custom.yaml --cores 24

For local execution, --cores is the whole CPU budget and needs no other setting: every CPU-bound rule declares threads:, so --cores enforces the ceiling by itself. Do not also pass --jobs/-j: for a local run Snakemake then stops enforcing the core budget, and rules can oversubscribe the machine. See Running BacFlux for the scheduling behaviour and resource measurements.

A first run spends a long time on setup: a default Illumina run builds 21 of the 33 conda environments in workflow/envs/ and downloads the databases BacFlux fetches for itself. Environments are created under .snakemake/conda in the directory you launched from, so launching from the same place each time is what stops them being rebuilt.

The run is resumable. If it is interrupted, repeat the same command and Snakemake redoes only what is missing or out of date. After changing the configuration, inspect a new dry run to confirm which jobs Snakemake schedules for recomputation.

What lands in the output directory

After a successful single-sample run, with the mobilome module off (the default):

/data/results/run1/
├── 01.reads/phix/                        # the PhiX genome and its Bowtie2 index, kept
├── 01.reads/isolate1/illumina/
│   ├── isolate1_fastp.html               # trimming report; the trimmed FASTQs are temporary
│   └── isolate1_fastp.json
├── 02.assembly/isolate1/
│   ├── contigs_final.fasta               # ← the delivered genome; every later stage reads this file
│   ├── contigs_filt.fasta                # after the length/coverage filter, before decontamination
│   ├── spades/contigs.fasta
│   ├── contaminants/
│   │   ├── contig_taxonomy_decisions.tsv # one row per contig: kept or dropped, and why
│   │   ├── isolate1_composition.txt      # genus composition of the assembly
│   │   ├── isolate1_kept_genus.txt       # the genus Bakta names the genome after
│   │   ├── isolate1_blastout
│   │   ├── contigs.list
│   │   └── bestscore.blob.blobDB.table.txt
│   └── eval/
│       ├── isolate1_qc_genomes.tsv       # which evaluated genome is which
│       └── quast/  checkm/  qualimap/
├── 03.taxonomy/isolate1/                 # GTDB-Tk classify_wf; the call is in classify/gtdbtk.*.summary.tsv
├── 04.annotation/
│   ├── bakta/isolate1/                   # the annotation: .gff3 .tsv .faa .fna .gbff
│   ├── eggnog/isolate1/
│   ├── antismash/isolate1/               # plus antismash/databases/, fetched once
│   └── dbcan/isolate1/                   # plus dbcan/dbcan_db_v5.1.2/, fetched once
├── 05.amr/
│   ├── abricate/isolate1/                # four databases, one TSV each, plus AMR_summary.txt
│   └── mapping/isolate1/                 # the read-based CARD leg: covstats, AMR_legend, CARD_report
├── 06.plasmids/isolate1/platon/
├── 07.phages/
│   ├── virsorter/isolate1/  checkv/isolate1/
│   └── checkv_db/  vs2_db/               # fetched once and kept
├── 09.report/multiqc_report.html
├── 10.workbooks/isolate1_amr.xlsx        # the strain's AMR genes and their context
└── logs/                                 # one log per job, named rule + sample

Stage numbers are the same in all four modes; a stage a mode cannot produce is simply absent (01.reads in contigs mode, 05.amr/mapping wherever there are no short reads). 08.mobilome appears only when the module is switched on — see turning it on.

Intermediates are declared temporary and deleted as soon as the last rule needing them has finished, which is why 01.reads ends up holding only reports and the PhiX genome with its index. Those two, and CARD's extracted copy under 05.amr/card_db/, are kept, so PhiX and CARD are downloaded and the PhiX index built once per output folder, and a sample added to the folder later runs without redoing the finished ones (why). Set directories.card_db to a copy you hold to skip even the CARD download.

Use these files to inspect the main results:

Question File
The genome 02.assembly/{sample}/contigs_final.fasta
Why was that contig kept or dropped? 02.assembly/{sample}/contaminants/contig_taxonomy_decisions.tsv
Completeness and contamination estimates 02.assembly/{sample}/eval/checkm/{sample}_checkm_stats.tsv
Assembly statistics 02.assembly/{sample}/eval/quast/
What species is it? 03.taxonomy/{sample}/classify/gtdbtk.*.summary.tsv
What genes does it carry? 04.annotation/bakta/{sample}/
Resistance and virulence, from the contigs 05.amr/abricate/{sample}/AMR_summary.txt
Resistance, from the reads 05.amr/mapping/{sample}/{sample}_CARD_report.tsv
Which contigs are plasmids? 06.plasmids/{sample}/platon/verified_plasmids.txt
One QC page for the whole batch 09.report/multiqc_report.html
The strain's AMR genes in one file, each with its plasmid and prophage context 10.workbooks/{sample}_amr.xlsx

The full layout, stage by stage, is in output files.

Next