The user wants to learn how to operate an HPC (High-Performance Computing) queue specifically for bioinformatics tasks.
The request covers six specific areas:
- Job Packaging: How to bundle tasks efficiently.
- Resource Requests: How to ask for CPU, RAM, GPU, time correctly.
- Containerization: Using Docker/Singularity/Apptainer for reproducibility.
- Cost Tracking: Monitoring usage (often in "credits" or hours).
- Failure Triage: Debugging why jobs fail.
- Reproducibility Hygiene: Keeping logs, scripts, and environments clean for future reuse.
Target Audience Analysis:
The user seems to be a bioinformatician or researcher moving from local computing to an HPC environment, or someone looking to optimize their workflow. They likely know how to run a command (e.g., fastqc file.fastq), but need help with the infrastructure/orchestration layer (SLURM, PBS, SGE).
Strategy:
I should structure this as a comprehensive guide, assuming a standard scheduler like SLURM (since it's the most common in modern bioinformatics), but keep the concepts general enough for PBS/SGE.
Section-by-Section Breakdown:
-
Introduction: Briefly define the role of the scheduler (SLURM/PBS) and the concept of "blocks" on the supercomputer.
-
Job Packaging (Array Jobs vs. Packaged Binaries):
- Concept: Don't run one job per file if you have 1000 files.
- Technique: Job Arrays (
--array) for embarrassingly parallel tasks (common in bioinformatics like processing FASTQs).
- Alternative: GNU Parallel within a single node allocation (packing small tasks into one big allocation).
-
Resource Requests (The Art of Estimation):
- The "Goldilocks" problem: Too little = crash; Too much = queue wait priority drop.
- Key parameters:
--cpus-per-task, --mem, --time.
- Bioinfo specifics: Multi-threading (using
-t flags in tools like BWA/Salmon) vs. actual core usage. Mention that requesting 32 cores doesn't make a single-thread script faster.
-
Containerization (Apptainer/Singularity):
- Why: HPC admins hate Docker (root privileges). Use Singularity/Apptainer.
- Workflow: Pull Docker image -> Convert to SIF -> Run command inside SIF.
- Binding: Crucial concept. How to access
/scratch or data directories inside the container.
-
Cost Tracking (Fairshare & Accounting):
- Concept: Service Units (SUs) = Cores × Time.
- Tools:
sacct and sreport.
- Optimization: Show how to check historical usage to improve future requests.
-
Failure Triage (The "WHY" stack):
- Common Errors:
- OOM (Out of Memory):
SIGKILL / oom-kill.
- Time Limit:
TIMEOUT.
- Node Failure:
Node Failure / DRAINED.
- Debugging: Checking
stderr/stdout, checking email alerts, using sacct to see state codes.
-
Reproducibility Hygiene (The "Future You" stack):
- Version Control: Git for scripts.
- Workflow Managers: Mention Nextflow/Snakemake (this is the ultimate level of job packaging).
- Record Keeping: Logging the exact container hash and command.
Drafting Content - Specifics to Bioinformatics:
- Examples: Use BWA, FastQC, or GATK as examples.
- Scheduler: Focus on SLURM syntax (e.g.,
#SBATCH) but mention it translates to PBS (#PBS).
Refinement on "Job Packaging":
There's a nuance here. "Packaging" can mean software packaging (Containers) or job bundling (Arrays). The user lists Containerization separately, so "Job Packaging" likely refers to task bundling/arrays. I will focus on Job Arrays and MPI/Threaded logic.
Refinement on "Cost Tracking":
In academic HPC, "cost" is usually "wait time" or "Fairshare score". In Cloud HPC (AWS Batch), it's dollars. I'll assume academic/on-prem primarily but mention cloud briefly. I'll focus on efficiency (CPU utilization) as a proxy for cost.
Structure:
I will use a "From Zero to Hero" progression.
- The Anatomy of a Job (The Basics).
- The specific components requested.
Let's build the cheat sheet.
Self-Correction during drafting: I initially thought about explaining MPI. Bioinformatics rarely uses MPI nowadays (except for very specific tools like RAxML or some CFD simulations). Most bioinfo tools are either single-threaded or use OpenMP (shared memory multi-threading). I should emphasize Threaded execution over MPI.
Reproducibility Hygiene:
This needs to be practical.
env modules are old school but still used.
- Containers are modern.
- Workflow managers (Snakemake/Nextflow) are the ultimate solution. I should position workflow managers as the "Pro" version of job packaging.
Final Polish:
Ensure the tone is professional yet accessible. Use code blocks for SLURM examples.
Plan:
- Philosophy: The HPC is a shared resource.
- Resource Requests: How not to get killed by the scheduler.
- Job Packaging: Arrays vs. Monolithic.
- Containers: Singularity/Apptainer deep dive.
- Triage: Exit codes and
sacct.
- Hygiene: Workflow managers & Git.
Let's write it out.
Operating an HPC (High-Performance Computing) queue effectively is less about typing commands and more about resource economics. You are negotiating with a scheduler (usually SLURM, PBS, or SGE) for a slice of a shared pie.
Here is the curriculum for operating a bioinformatics HPC queue, moving from basic submission to advanced reproducibility.
1. Resource Requests: The "Goldilocks" Estimation
The most common mistake is requesting resources based on "vibes" rather than data. Over-requesting wastes money/credits and increases your queue wait time; under-requesting gets your job killed.
The Strategy:
- Memory (RAM): Bioinformatics tools are memory-hungry (aligners, Java tools).
- Rule of thumb: For genome assembly or large variant calling, request 1.5x the size of the uncompressed input file.
- Java: Always set
-Xmx (max heap) to be ~80% of your requested SLURM memory.
- CPUs (Threads): Do not request 32 cores "just in case."
- Amdahl's Law: Most bio tools (BWA, Samtools, GATK) parallelize poorly after 8-16 threads.
- Test: Run a small subset with 4, 8, and 16 threads. If the speed gain flattens, that is your cap.
- Walltime: Always request 2x the expected time. If it usually takes 2 hours, request 4.
The "Profit" Trick (Backfill):
Schedulers often have "holes" where nodes are partially free for short periods.
- Standard Job: 24 cores, 100GB RAM, 24 hours. (Wait: 2 days).
- Backfill Job: 4 cores, 16GB RAM, 2 hours. (Wait: 5 minutes).
- Tip: If you can split your task into small chunks, you will skip the queue.
2. Job Packaging: Arrays and Bundling
Don't submit one job per file. If you have 100 FASTQ files, submitting 100 separate jobs clogs the scheduler and creates millions of small files (I/O stress).
Technique A: Job Arrays (The "Map" operation)
Use arrays when every task is independent (e.g., FastQC on 100 samples).
# SLURM example
#SBATCH --array=1-100%10 # Run 100 tasks, max 10 concurrent
#SBATCH --output=logs/sample_%a.out
# Map the array ID to a filename
SAMPLE=$(sed -n "${SLURM_ARRAY_TASK_ID}p" samples.txt)
fastqc ${SAMPLE}.fastq
Technique B: In-Node Parallelism (The "Reduce" operation)
If you have a node with 32 cores, don't run one process using 1 core.
Use GNU parallel or xargs inside your submission script to pack the node.
# Inside your job script
# Run 4 processes at once, each using 8 threads (Total = 32)
cat samples.txt | parallel -j 4 'bwa mem -t 8 ref.fa {} > {.}.sam'
3. Containerization: The "Works on My Machine" Fix
HPC environments often have outdated OS kernels. Docker is rarely allowed on traditional HPCs due to root privileges. The standard is Apptainer (formerly Singularity).
The Workflow:
- Develop locally using Docker.
- Convert to Apptainer on the HPC login node:
apptainer pull docker://biocontainers/bwa:0.7.17--hed695b0_7
# Creates a .sif file
- Execute via the container inside the job script:
apptainer exec \
--bind /path/to/data:/data \ # Crucial: Mount your data dir
bwa_0.7.17.sif \
bwa mem /data/ref.fa /data/sample_R1.fastq
Why this matters: It solves reproducibility hygiene. Three years from now, you can rerun the exact binary even if the HPC OS upgrades.
4. Failure Triage: The Post-Mortem
Jobs fail. Usually, you get a cryptic email or a generic error code. Here is how to triage:
Step 1: Check the Output/Error files
- Look at the end of the file, not the beginning.
tail -n 50 slurm-12345.out
Step 2: Common Error Patterns
SIGKILL / OUT_OF_MEMORY: The job hit the RAM limit. Increase memory or check for memory leaks (common in poorly written Perl/Python scripts).
SIGTERM / TIMEOUT: The job hit the walltime limit. Request more time or optimize the code.
Bus error / Segmentation fault: Usually bad hardware (ECC RAM failure) or a bug in the software. Try running on a different node.
Disk Quota Exceeded: You filled your home directory. Clean up tmp/ or redirect temp files to scratch storage ($TMPDIR).
Step 3: Interactive Debugging
Don't submit a job to debug. Request an interactive session.
salloc --time=1:00:00 --cpus-per-task=4 --mem=16G --pty bash
# Now you are on a compute node. Run your commands manually to see the error.
5. Cost Tracking (Efficiency)
In bioinformatics, "Cost" is usually Core-Hours.
- 1 Core for 1 hour = 1 S.U. (Service Unit)
- 32 Cores for 1 hour = 32 S.U.
How to track efficiency:
Use seff <jobid> (SLURM) to see how much you requested vs. how much you used.
Job ID: 12345
State: COMPLETED (exit code 0)
Cores: 4
CPU Efficiency: 12.50% of 08:00:00 core-walltime <-- BAD
Memory Efficiency: 95.00% of 4.00 GB <-- GOOD
Interpretation: In the example above, you reserved 4 cores but the program was single-threaded (only used 1). You wasted 75% of your allocated credits.
6. Reproducibility Hygiene: The "Future You" Protocol
Bioinformatics projects often die because the researcher cannot rerun the analysis 6 months later.
The 5 Pillars of HPC Hygiene:
- Version Control Scripts: Keep your
.sh submission scripts in Git.
- Log Environments: At the start of every script, print the environment details.
# Save this info to the log file
echo "Job ID: $SLURM_JOB_ID"
echo "Date: $(date)"
echo "Node: $SLURMD_NODENAME"
module list # Shows loaded software versions
conda list # Shows python packages
- Parameter Sweeps: Never manually edit a script to change a parameter from 0.05 to 0.1. Pass parameters as arguments or use a config file.
- Data Management:
- Raw Data: Read-only. Never modify the raw FASTQs.
- Intermediate: Use the HPC high-speed scratch (
$TMPDIR or /scratch) for temp files.
- Results: Only copy final VCFs/BAMs back to your home/project storage.
- Workflow Managers: Once you master manual submission, graduate to Snakemake or Nextflow. These tools handle the queue submission, logging, and re-running failed steps automatically.