Skip to content
Snippets Groups Projects
GENERATE.WITH_HPC_CLUSTER.sh 2.88 KiB
Newer Older
Tim O'Donnell's avatar
Tim O'Donnell committed
#!/bin/bash
#
#
set -e
set -x

DOWNLOAD_NAME=data_mass_spec_benchmark
SCRATCH_DIR=${TMPDIR-/tmp}/mhcflurry-downloads-generation
SCRIPT_ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
SCRIPT_DIR=$(dirname "$SCRIPT_ABSOLUTE_PATH")
export PYTHONUNBUFFERED=1

mkdir -p "$SCRATCH_DIR"
rm -rf "$SCRATCH_DIR/$DOWNLOAD_NAME"
mkdir "$SCRATCH_DIR/$DOWNLOAD_NAME"

# Send stdout and stderr to a logfile included with the archive.
Timothy ODonnell's avatar
Timothy ODonnell committed
exec >  >(tee -ia "$SCRATCH_DIR/$DOWNLOAD_NAME/LOG.txt")
exec 2> >(tee -ia "$SCRATCH_DIR/$DOWNLOAD_NAME/LOG.txt" >&2)
Tim O'Donnell's avatar
Tim O'Donnell committed

# Log some environment info
date
pip freeze
git status

cd $SCRATCH_DIR/$DOWNLOAD_NAME

cp $SCRIPT_DIR/write_proteome_peptides.py .
cp $SCRIPT_DIR/run_mhcflurry.py .
cp $SCRIPT_DIR/write_allele_list.py .

PEPTIDES=$(mhcflurry-downloads path data_mass_spec_annotated)/annotated_ms.csv.bz2
REFERENCES_DIR=$(mhcflurry-downloads path data_references)

Tim O'Donnell's avatar
Tim O'Donnell committed
python write_allele_list.py "$PEPTIDES" --out alleles.txt
mkdir predictions

# First just chr1 peptides
Timothy ODonnell's avatar
Timothy ODonnell committed
python write_proteome_peptides.py \
    "$PEPTIDES" \
    "${REFERENCES_DIR}/uniprot_proteins.csv.bz2" \
Tim O'Donnell's avatar
Tim O'Donnell committed
    --chromosome 1 \
    --out proteome_peptides.chr1.csv
Tim O'Donnell's avatar
Tim O'Donnell committed

for kind in with_mass_spec no_mass_spec
do
    python run_mhcflurry.py \
Tim O'Donnell's avatar
Tim O'Donnell committed
        proteome_peptides.chr1.csv \
        --chunk-size 100000 \
Timothy ODonnell's avatar
Timothy ODonnell committed
        --batch-size 65536 \
Tim O'Donnell's avatar
Tim O'Donnell committed
        --models-dir "$(mhcflurry-downloads path models_class1_pan)/models.$kind" \
        --allele $(cat alleles.txt) \
Tim O'Donnell's avatar
Tim O'Donnell committed
        --out "predictions/chr1.mhcflurry.$kind" \
Tim O'Donnell's avatar
Tim O'Donnell committed
        --verbosity 1 \
        --worker-log-dir "$SCRATCH_DIR/$DOWNLOAD_NAME" \
        --cluster-parallelism \
        --cluster-max-retries 15 \
        --cluster-submit-command bsub \
        --cluster-results-workdir ~/mhcflurry-scratch \
        --cluster-script-prefix-path $SCRIPT_DIR/cluster_submit_script_header.mssm_hpc.lsf
done

Tim O'Donnell's avatar
Tim O'Donnell committed
# Now all peptides
python write_proteome_peptides.py \
    "$PEPTIDES" \
    "${REFERENCES_DIR}/uniprot_proteins.csv.bz2" \
    --out proteome_peptides.all.csv

for kind in with_mass_spec no_mass_spec
do
    python run_mhcflurry.py \
        proteome_peptides.all.csv \
        --chunk-size 500000 \
        --batch-size 65536 \
        --models-dir "$(mhcflurry-downloads path models_class1_pan)/models.$kind" \
        --allele $(cat alleles.txt) \
        --out "predictions/all.mhcflurry.$kind" \
        --verbosity 1 \
        --worker-log-dir "$SCRATCH_DIR/$DOWNLOAD_NAME" \
        --cluster-parallelism \
        --cluster-max-retries 15 \
        --cluster-submit-command bsub \
        --cluster-results-workdir ~/mhcflurry-scratch \
        --cluster-script-prefix-path $SCRIPT_DIR/cluster_submit_script_header.mssm_hpc.lsf
done


Tim O'Donnell's avatar
Tim O'Donnell committed
bzip2 proteome_peptides.chr1.csv
Tim O'Donnell's avatar
Tim O'Donnell committed
bzip2 proteome_peptides.all.csv
Tim O'Donnell's avatar
Tim O'Donnell committed

Tim O'Donnell's avatar
Tim O'Donnell committed
cp $SCRIPT_ABSOLUTE_PATH .
bzip2 LOG.txt
RESULT="$SCRATCH_DIR/${DOWNLOAD_NAME}.$(date +%Y%m%d).tar.bz2"
tar -cjf "$RESULT" *
echo "Created archive: $RESULT"