#!/bin/bash script_name="split_study.sh" #Help function usage() { echo "-h --Help documentation for $script_name" echo "-r --Study_RID." echo "-t --Tag of pipelne" echo "-e --Email on failure" echo "-o --Path to output directory" echo "Example: $script_name -r 16-1ZP0 -t 0.1.0 -e 'first.last@utsouthwestern.edu' -o '/path/to/output/dir/'" exit 1 } main(){ # Load required modules module load python/3.6.4-anaconda module load nextflow/20.01.0 module load singularity/3.5.3 # Parsing options OPTIND=1 # Reset OPTIND while getopts :r:t:e:o:h opt do case $opt in r) rid=$OPTARG;; t) tag=$OPTARG;; e) email=$OPTARG;; o) out=$OPTARG;; h) usage;; esac done shift $(($OPTIND -1)) # Check for mandatory options if [[ -z $rid ]] || [[ -z $tag ]] || [[ -z $email ]] || [[ -z $out ]]; then usage fi # query GUDMAP/RBK for study RID echo "curl --location --request GET 'https://dev.gudmap.org/ermrest/catalog/2/entity/RNASeq:Replicate/Study_RID="${rid}"'" | bash > $rid\_studyRID.json # extract replicate RIDs python3 ./scripts/split_study.py -s $rid # cleanup study RID files rm $rid\_studyRID.json # make dir for study mkdir $out/$rid mv $rid\_studyRID.csv $out/$rid cd $out/$rid # download version of RNA-seq pipelne existed_in_remote=$( git ls-remote --tags git@git.biohpc.swmed.edu:gudmap_rbk/rna-seq.git ${tag}) if [[ -z ${existed_in_remote} ]]; then echo "The tag ${tag} doesn't exist." exit 1 fi git clone -b $tag --depth 1 git@git.biohpc.swmed.edu:gudmap_rbk/rna-seq.git cd rna-seq # run pipeline on replicate RIDs in parallel while read repRID; do echo ${repRID}; sleep 30; done < "../${rid}_studyRID.csv" | xargs -P 5 -I {} nextflow -q run workflow/rna-seq.nf --repRID {} --source dev --deriva /project/BICF/BICF_Core/shared/gudmap/test_data/auth/credential.json --bdbag /project/BICF/BICF_Core/shared/gudmap/test_data/auth/cookies.txt --dev false --upload true --email ${email} -with-report ./output/{}_report.html -with-timeline ./output/{}_timeline.html } main "$@"