Skip to content

Instantly share code, notes, and snippets.

@rpetit3
Last active June 11, 2025 18:17
Show Gist options
  • Save rpetit3/4c50750f884fb64502c7823a00afb676 to your computer and use it in GitHub Desktop.
Save rpetit3/4c50750f884fb64502c7823a00afb676 to your computer and use it in GitHub Desktop.
An sbatch script download and format ATB assemblies for Bactopia on Medicine Bow
#! /bin/bash
# A script to submit a SLURM job to run bactopia-atb-downloader and bactopia-atb-formatter
# Expected Options:
# 1: Organism to download
# 2: ARCC Account
# 3: Output Directory
ORGANISM="${1}"
LOWERCASE_ORGANISM="${ORGANISM,,}"
UNDERSCORE_ORGANISM="${LOWERCASE_ORGANISM// /_}"
ACCOUNT=${2}
OUTDIR=${3}
sbatch <<EOT
#!/bin/bash
#SBATCH --job-name=bactopia-atb-${UNDERSCORE_ORGANISM}-setup
#SBATCH --output=bactopia-atb-${UNDERSCORE_ORGANISM}-setup.out
#SBATCH --error=bactopia-atb-${UNDERSCORE_ORGANISM}-setup.err
#SBATCH --time=24:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=16G
#SBATCH --account=${ACCOUNT}
#SBATCH --qos=Normal
# Load the necessary modules
module load miniconda3
conda activate bactopia
# Change to the working directory
mkdir -p ${OUTDIR}
cd ${OUTDIR}
# Download ATb assemblies for the specified organism
echo "Downloading ATB assemblies for ${ORGANISM} (${UNDERSCORE_ORGANISM})" 1>&2
bactopia-atb-downloader \
--query "${ORGANISM}" \
--cpus 8
# Setup the directory structure for Bactopia (delete if it exists)
if [ -d ${OUTDIR}/${UNDERSCORE_ORGANISM}/bactopia ]; then
echo "Removing existing Bactopia directory for ${ORGANISM}" 1>&2
rm -rf ${OUTDIR}/${UNDERSCORE_ORGANISM}/bactopia
fi
echo "Creating Bactopia directory for ${ORGANISM} (${OUTDIR}/${UNDERSCORE_ORGANISM}/bactopia)" 1>&2
mkdir -p (${OUTDIR}/${UNDERSCORE_ORGANISM}/bactopia
bactopia-atb-formatter \
--path (${OUTDIR}/atb-assemblies/${UNDERSCORE_ORGANISM}/ \
--bactopia-dir (${OUTDIR}/${UNDERSCORE_ORGANISM}/bactopia \
--extension ".fa.gz" \
--verbose
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment