Installing Conda and Bioinformatics Tools

Overview

In this lesson, we will install conda on a local laptop and create separate environments for different bioinformatics tasks.

We will cover installation for:

  • Windows using WSL
  • Linux
  • macOS

After installing conda, we will create separate environments and install commonly used tools for bacterial genomics analysis.

NoteWhy use conda?

Conda helps us install bioinformatics tools and manage software dependencies.
Using separate environments keeps tools organised and reduces software conflicts.

Learning objectives

By the end of this lesson, you should be able to:

  • install Miniconda on Windows using WSL, Linux, or macOS
  • check that conda is installed correctly
  • configure conda channels
  • create separate conda environments
  • install tools for sra-tools, QC, assembly, taxonomy, annotation, AMR, pangenome, and phylogeny
  • install required databases for CheckM2, and Kraken2
  • activate and deactivate conda environments

Conda setup

Part 1: Install conda

Before installing conda on Windows: Install WSL

Windows users should install Windows Subsystem for Linux (WSL) first. WSL allows you to run a Linux terminal on Windows.

NoteRecommended

For this course, Windows users should use Ubuntu through WSL rather than installing conda directly in Windows PowerShell or Command Prompt. If you have installed Windows Subsystem for Linux (WSL) please visit Installing Windows Subsystem for Linux (WSL) and install WSL first.

Step 1: Open WSL terminal

Open your Ubuntu terminal from the Windows Start menu.

Check that you are inside Linux:

pwd

You should see a Linux-style path such as:

/home/your_username

Step 2: Download Miniconda installer

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Step 3: Run the installer

bash Miniconda3-latest-Linux-x86_64.sh

Follow the instructions on screen.

When asked to accept the license, type:

yes

When asked whether to initialise Miniconda, type:

yes

Step 4: Restart terminal

Close the WSL terminal and open it again.

Then check conda:

conda --version

Example output:

conda 24.11.3

Step 5: Update conda

conda update -n base -c defaults conda

When asked to proceed, type:

y

Sometimes, you may be asked to type a to accept, if so type the full word:

accept

Step 1: Open terminal

Open a terminal and move to your home directory:

cd ~

Step 2: Download Miniconda installer

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Step 3: Run the installer

bash Miniconda3-latest-Linux-x86_64.sh

Follow the instructions on screen.

When asked to accept the license, type:

yes

When asked whether to initialise Miniconda, type:

yes

Step 4: Restart terminal

Close the terminal and open it again.

Then check conda:

conda --version

Step 5: Update conda

conda update -n base -c defaults conda

Step 1: Open Terminal

Open Terminal from Applications or Spotlight.

Check your chip type:

uname -m

If you see:

x86_64

you are using an Intel Mac.

If you see:

arm64

you are using Apple Silicon, such as M1, M2, M3, or M4.

Step 2: Download Miniconda installer

curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh

Step 3: Run the installer

bash Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-arm64.sh

Follow the instructions on screen.

When asked to accept the license, type:

yes

When asked whether to initialise Miniconda, type:

yes

Step 4: Restart Terminal

Close Terminal and open it again.

Then check conda:

conda --version

Step 5: Update conda

conda update -n base conda

Part 2: Configure conda channels

After installing conda, configure the channels needed for bioinformatics tools.

Run these commands once:

conda config --add channels bioconda
conda config --add channels conda-forge
conda config --set channel_priority strict

Check the configured channels:

conda config --show channels

You should see:

channels:
  - conda-forge
  - bioconda
  - defaults
NoteImportant

For most bioinformatics tools, the recommended channel order is:

conda-forge
bioconda
defaults

Accept TOS for channels

conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r

Part 3: Basic conda commands

Task Command
Check conda version conda --version
Update conda conda update -n base conda
List environments conda env list
Create environment conda create -n env_name
Activate environment conda activate env_name
Deactivate environment conda deactivate
Search package conda search package_name
Install package conda install package_name
Remove environment conda env remove -n env_name

Part 4: Create separate environments

In this training, we recommend using separate environments for different parts of the workflow.

Environment Purpose
qc Read quality control and trimming
assembly Genome assembly and assembly QC
classify Taxonomic classification
mlst MLST analysis
annotation Genome annotation
amr AMR and virulence factor screening
pangenome Pangenome analysis
phylogeny Phylogenetic analysis
WarningInstallation time

Some tools may take several minutes to install depending on internet speed and computer performance.

Environment creation

Tip

During training sessions, you only installed tools with default version (usually latest). However we can define which version we want to work with. Below examples are all based on particular examples.

Environment 1: sra-tools

Create and activate the sra-tools environment:

conda create -n sra-tools
conda activate sra-tools

Install QC and trimming tools:

conda install sra-tools=3.4.1

Check installation:

prefetch --version
WarningWarning

If you face errors due to sra-tools conflicting with latest Conda version, type the following and install again

conda config --set plugins.use_sharded_repodata false
conda clean --index-cache
conda install sra-tools=3.4.1

Deactivate:

conda deactivate

Environment 2: QC

Create and activate the qc environment:

conda create -n qc
conda activate qc

Install QC and trimming tools:

conda install fastqc=0.12.1 trimmomatic=0.40

Check installation:

fastqc --version
trimmomatic -version

Deactivate:

conda deactivate

Environment 3: Assembly

Create and activate the assembly environment:

conda create -n assembly
conda activate assembly

Install assembly and assembly QC tools:

conda install spades=4.2.0 quast=5.3.0 checkm2=1.1.0 seqkit=2.13.0

Check installation:

spades.py --version
quast --version
checkm2 --version
seqkit version

Deactivate:

conda deactivate

Environment 4: Taxonomic classification

Create and activate the classify environment:

conda create -n classify
conda activate classify

Install classification tools:

conda install kraken2=2.17.1 krakentools=1.2.1 krona=2.8.1

Check installation:

kraken2 --version
ktImportText

Deactivate:

conda deactivate

Environment 5: MLST

Create and activate the mlst environment:

conda create -n mlst
conda activate mlst

Install MLST:

conda install mlst

Check installation:

mlst --version

Deactivate:

conda deactivate

Environment 6: Annotation

Create and activate the annotation environment:

conda create -n annotation
conda activate annotation

Install annotation tools:

conda install prokka=1.15.6

Check installation:

prokka --version

Deactivate:

conda deactivate

Environment 7: AMR and virulence

Create and activate the amr environment:

conda create -n amr
conda activate amr

Install ABRicate:

conda install abricate=1.4.0

Check installation:

abricate --version
abricate --list

Deactivate:

conda deactivate

Environment 8: Pangenome

Create and activate the pangenome environment:

conda create -n pangenome
conda activate pangenome

Install Panaroo:

conda install panaroo=1.7.0

Check installation:

panaroo --version

Deactivate:

conda deactivate

Environment 9: Phylogeny

Create and activate the phylogeny environment:

conda create -n phylogeny
conda activate phylogeny

Install phylogeny tools:

conda install snp-sites=2.5.1 iqtree=3.1.1

Check installation:

snp-sites --version
iqtree --version

Deactivate:

conda deactivate

Check all environments

List all conda environments:

conda env list

You should see environments such as:

base
sra-tools
qc
assembly
classify
mlst
annotation
amr
pangenome
phylogeny

Install required databases

Some tools need additional databases before they can be used properly.

In this training, we need to prepare databases for:

  • CheckM2
  • Kraken2
WarningImportant

Database installation can take time and may require a stable internet connection.

Some databases are large, so make sure you have enough disk space before starting.

CheckM2 database setup

Activate the assembly environment:

conda activate assembly

Check that CheckM2 is available:

checkm2 --version

Download the CheckM2 database:

checkm2 database --download

This will download and configure the default CheckM2 database.

Run a Test Simulation:

Execute the test command to verify end-to-end functionality:

checkm2 testrun

If successful, the terminal will print

INFO: CheckM2 completed successfully.

Deactivate the environment:

conda deactivate
WarningDatabase size

The CheckM2 database may be large. Make sure you have enough disk space before downloading it.

Kraken2 database setup

Kraken2 requires a database before it can classify sequences.

For this training, we will use the Standard-8 Kraken2 database from the Ben Langmead AWS index collection.

NoteWhy Standard-8?

The full Kraken2 standard database is very large.

The Standard-8 database is capped at approximately 8 GB, so it is more suitable for training and local laptop use.

Activate the classify environment:

conda activate classify

Check that Kraken2 is available:

kraken2 --version

Create a directory for Kraken2 databases:

mkdir -p ~/databases/minikrakendb
cd ~/databases/minikrakendb

Download the Standard-8 database:

wget https://genome-idx.s3.amazonaws.com/kraken/k2_standard_08_GB_20260226.tar.gz

Extract the database:

tar -xvzf k2_standard_08_GB_20260226.tar.gz

Check the database files:

ls

We recommend you to download the latest Kraken2 database using wget. If you face any difficulties, e.g., slow internet speed, splitting up of the downloaded file etc., you can download all files manually from this link

https://drive.google.com/drive/folders/1aBOZIenpRtG9oQzLX1KiKWFIEPimvAKu?usp=sharing

You should see files such as:

hash.k2d
opts.k2d
taxo.k2d

Deactivate the environment:

conda deactivate
NoteDatabase path

In this training, the Kraken2 database path will be:

~/databases/minikrakendb

Example Kraken2 command using this database

When classifying an assembly, use the database path with --db.

kraken2 \
  --db ~/databases/minikrakendb \
  --threads 4 \
  --report classify/S1.kraken2.report \
  --output classify/S1.kraken2.output \
  assemblies/S1_contigs_filtered.fasta
TipKraken2 command with memory issue

If you see errors in terminal mentioning that Kraken2 cannot run due to memory insufficiency, use the flag --memory-mapping to run efficiently

kraken2 \
  --db ~/databases/minikrakendb \
  --memory-mapping \
  --threads 4 \
  --report classify/S1.kraken2.report \
  --output classify/S1.kraken2.output \
  assemblies/S1_contigs_filtered.fasta
conda activate assembly
checkm2 database --download
conda deactivate

conda activate classify
mkdir -p ~/databases/minikrakendb
cd ~/databases/minikrakendb
wget https://genome-idx.s3.amazonaws.com/kraken/k2_standard_08_GB_20260226.tar.gz
tar -xvzf k2_standard_08_GB_20260226.tar.gz 
ls
conda deactivate
conda config --add channels bioconda
conda config --add channels conda-forge
conda config --set channel_priority strict

conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r

conda create -n sra-tools
conda activate sra-tools
conda install sra-tools
conda deactivate

conda create -n qc
conda activate qc
conda install fastqc trimmomatic seqkit
conda deactivate

conda create -n assembly
conda activate assembly
conda install spades quast checkm2
conda deactivate

conda create -n classify
conda activate classify
conda install kraken2 krona
conda deactivate

conda create -n mlst
conda activate mlst
conda install mlst
conda deactivate

conda create -n annotation
conda activate annotation
conda install prokka
conda deactivate

conda create -n amr
conda activate amr
conda install abricate
conda deactivate

conda create -n pangenome
conda activate pangenome
conda install panaroo
conda deactivate

conda create -n phylogeny
conda activate phylogeny
conda install snp-sites iqtree
conda deactivate

conda activate assembly
checkm2 database --download
checkm2 database --list
conda deactivate

conda activate classify
mkdir -p ~/databases
cd ~/databases
wget https://genome-idx.s3.amazonaws.com/kraken/k2_standard_08gb_20260226.tar.gz
mkdir -p minikrakendb
tar -xvzf k2_standard_08gb_20260226.tar.gz -C minikrakendb
ls minikrakendb
conda deactivate

conda activate annotation
prokka --setupdb
prokka --listdb
conda deactivate

Troubleshooting

Problem Possible reason Solution
conda: command not found Terminal was not restarted after installation Close and reopen terminal
PackagesNotFoundError Channel not configured correctly Check channel order
Installation is very slow Conda dependency solving is slow Wait, or use mamba if available
EnvironmentNameNotFound Environment was not created Run conda env list
command not found Correct environment is not active Run conda activate environment_name
checkm2: command not found assembly environment is not active Run conda activate assembly
kraken2: command not found classify environment is not active Run conda activate classify
prokka: command not found annotation environment is not active Run conda activate annotation
CheckM2 database download fails Internet connection interrupted Run checkm2 database --download again
Kraken2 database download fails Database link changed or internet issue Check the latest Standard-8 link from the Kraken2 AWS index page
Prokka database setup fails Internet or permission issue Check connection and try again
hash.k2d not found Kraken2 database was not extracted correctly Re-run the tar command
Tool cannot find database Database path is not configured correctly Check database paths carefully
Not enough disk space Databases are large Free space or install databases on a larger drive
Tool installed but not working Dependency conflict or incomplete install Recreate the environment

Key points

NoteImportant
  • Install conda once on your local laptop.
  • Use WSL for Windows users.
  • Use separate environments for different analysis steps.
  • Always activate the correct environment before running a tool.
  • Use conda env list to check available environments.
  • Use conda deactivate before switching to another environment.
  • Some tools require separate database setup after software installation.
  • In this lesson, we install databases for CheckM2, Kraken2, and Prokka.
Back to top