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.
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.
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:
pwdYou 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.shStep 3: Run the installer
bash Miniconda3-latest-Linux-x86_64.shFollow 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 --versionExample output:
conda 24.11.3
Step 5: Update conda
conda update -n base -c defaults condaWhen 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.shStep 3: Run the installer
bash Miniconda3-latest-Linux-x86_64.shFollow 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 --versionStep 5: Update conda
conda update -n base -c defaults condaStep 1: Open Terminal
Open Terminal from Applications or Spotlight.
Check your chip type:
uname -mIf 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.shcurl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.shStep 3: Run the installer
bash Miniconda3-latest-MacOSX-x86_64.shbash Miniconda3-latest-MacOSX-arm64.shFollow 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 --versionStep 5: Update conda
conda update -n base condaPart 2: Configure conda channels
After installing conda, configure the channels needed for bioinformatics tools.
Run these commands once:
conda config --add channels biocondaconda config --add channels conda-forgeconda config --set channel_priority strictCheck the configured channels:
conda config --show channelsYou should see:
channels:
- conda-forge
- bioconda
- defaults
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/mainconda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/rPart 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 |
Some tools may take several minutes to install depending on internet speed and computer performance.
Environment creation
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-toolsconda activate sra-toolsInstall QC and trimming tools:
conda install sra-tools=3.4.1Check installation:
prefetch --versionIf 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 falseconda clean --index-cacheconda install sra-tools=3.4.1Deactivate:
conda deactivateEnvironment 2: QC
Create and activate the qc environment:
conda create -n qcconda activate qcInstall QC and trimming tools:
conda install fastqc=0.12.1 trimmomatic=0.40Check installation:
fastqc --versiontrimmomatic -versionDeactivate:
conda deactivateEnvironment 3: Assembly
Create and activate the assembly environment:
conda create -n assemblyconda activate assemblyInstall assembly and assembly QC tools:
conda install spades=4.2.0 quast=5.3.0 checkm2=1.1.0 seqkit=2.13.0Check installation:
spades.py --versionquast --versioncheckm2 --versionseqkit versionDeactivate:
conda deactivateEnvironment 4: Taxonomic classification
Create and activate the classify environment:
conda create -n classifyconda activate classifyInstall classification tools:
conda install kraken2=2.17.1 krakentools=1.2.1 krona=2.8.1Check installation:
kraken2 --versionktImportTextDeactivate:
conda deactivateEnvironment 5: MLST
Create and activate the mlst environment:
conda create -n mlstconda activate mlstInstall MLST:
conda install mlstCheck installation:
mlst --versionDeactivate:
conda deactivateEnvironment 6: Annotation
Create and activate the annotation environment:
conda create -n annotationconda activate annotationInstall annotation tools:
conda install prokka=1.15.6Check installation:
prokka --versionDeactivate:
conda deactivateEnvironment 7: AMR and virulence
Create and activate the amr environment:
conda create -n amrconda activate amrInstall ABRicate:
conda install abricate=1.4.0Check installation:
abricate --versionabricate --listDeactivate:
conda deactivateEnvironment 8: Pangenome
Create and activate the pangenome environment:
conda create -n pangenomeconda activate pangenomeInstall Panaroo:
conda install panaroo=1.7.0Check installation:
panaroo --versionDeactivate:
conda deactivateEnvironment 9: Phylogeny
Create and activate the phylogeny environment:
conda create -n phylogenyconda activate phylogenyInstall phylogeny tools:
conda install snp-sites=2.5.1 iqtree=3.1.1Check installation:
snp-sites --versioniqtree --versionDeactivate:
conda deactivateCheck all environments
List all conda environments:
conda env listYou 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:
CheckM2Kraken2
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 assemblyCheck that CheckM2 is available:
checkm2 --versionDownload the CheckM2 database:
checkm2 database --downloadThis will download and configure the default CheckM2 database.
Run a Test Simulation:
Execute the test command to verify end-to-end functionality:
checkm2 testrunIf successful, the terminal will print
INFO: CheckM2 completed successfully.
Deactivate the environment:
conda deactivateThe 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.
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 classifyCheck that Kraken2 is available:
kraken2 --versionCreate a directory for Kraken2 databases:
mkdir -p ~/databases/minikrakendbcd ~/databases/minikrakendbDownload the Standard-8 database:
wget https://genome-idx.s3.amazonaws.com/kraken/k2_standard_08_GB_20260226.tar.gzExtract the database:
tar -xvzf k2_standard_08_GB_20260226.tar.gzCheck the database files:
lsWe 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 deactivateIn 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.fastaIf 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.fastaconda 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 deactivateconda 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 deactivateTroubleshooting
| 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
- 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 listto check available environments. - Use
conda deactivatebefore switching to another environment. - Some tools require separate database setup after software installation.
- In this lesson, we install databases for
CheckM2,Kraken2, andProkka.