Skip to content

Lmod

We use Lmod (Lua-based Environment Modules) on our cluster to manage software environments. Lmod allows users to easily load, unload, and switch between different software packages and versions.

Note

A large number of modules are installed on the cluster and are available on demand, making it easy to access the tools you need for your work.

Installed Modules

You can view all available software modules on the cluster using the following command.

module avail  # Flat list for the hierarchy level.

Finding Module

module keyword chemistry mpi   # By keyword across name, description, tags.
module spider Python/3.10      # By exact version and dependencies.

Loading Module

module load SAMtools/1.21

Now you will be able to use tools included in the module.

samtools --version

samtools 1.21
Using htslib 1.21

Unloading Module

You can unload specific module by command below.

module unload SAMtools

Resetting Modules

You can reset all modules loaded in environment by command below.

module reset

Example

Following PBS batch script submits a job called samtools_demo that requests one node with eight CPU cores, 16 GB of memory, and a two-hour wall-time limit. It resets the environment, loads the SAMtools/1.21 module, and defines input/output BAM filenames. The job then sorts the BAM file using eight threads, creates an index for random access, and generates a quick mapping-quality report with flagstat.

#!/bin/bash
#PBS -N samtools_demo                 # Job name
#PBS -l select=1:ncpus=8:mem=16gb     # One node, 8 cores, 16 GB RAM
#PBS -l walltime=02:00:00             # Max run time (hh:mm:ss)

module reset                          # Reset evironment
module load SAMtools/1.21             # Load the actual tool

INPUT_BAM=my_sample.bam
SORTED_BAM=my_sample.sorted.bam

# Coordinate-sort (8 threads, 2 GB/thread)
samtools sort -@ 8 -m 2G -o "$SORTED_BAM" "$INPUT_BAM"

# Index for random access
samtools index "$SORTED_BAM"

# Quick QC summary
samtools flagstat "$SORTED_BAM" > my_sample.flagstat.txt