Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Created February 11, 2026 23:48
Show Gist options
  • Select an option

  • Save icaoberg/a08dad753473812af5da7b652c259e62 to your computer and use it in GitHub Desktop.

Select an option

Save icaoberg/a08dad753473812af5da7b652c259e62 to your computer and use it in GitHub Desktop.
[PSC] BLAST example #bridges2
#!/bin/bash
#SBATCH --job-name=blast_demo
#SBATCH --output=blast_%j.out
#SBATCH --error=blast_%j.err
#SBATCH --time=02:00:00
#SBATCH -n 8
#SBATCH --mem=16000M
#SBATCH -p RM-shared
###############################################################################
# blast_demo.sh
#
# Copyright (c) 2026 icaoberg at the Pittsburgh Computing Center for Bridges-2
#
# Description:
# Example BLASTN search against the human genome (GRCh38) using a multi-volume
# BLAST v5 database. Generates a guaranteed matching query sequence from the
# database and runs blastn.
#
# Date: 2026-02-11
###############################################################################
echo "Loading BLAST module..."
module load BLAST
echo "Extracting human genome BLAST database..."
tar -xvzf /ocean/datasets/community/genomics/blast/latest/human_genome.00.tar.gz
tar -xvzf /ocean/datasets/community/genomics/blast/latest/human_genome.01.tar.gz
DATABASE=GCF_000001405.39_top_level
echo "Generating guaranteed matching query sequence..."
# Select a valid accession from the database to guarantee a match
SEQID=$(blastdbcmd -db $DATABASE -entry all -outfmt "%a" | head -n 1)
echo "Using sequence: $SEQID"
blastdbcmd -db $DATABASE -entry "$SEQID" -range 1-200 > query.fa
echo "Running blastn..."
blastn \
-query query.fa \
-db $DATABASE \
-out blast_results.txt \
-evalue 1e-5 \
-outfmt 6 \
-num_threads 8
echo "Top BLAST hits:"
head blast_results.txt
echo "Job completed successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment