#!/bin/bash set -e # source msings-env/bin/activate
#BAM_LIST is a file of absolute paths to each bam file BAM_LIST=$1; BEDFILE=$2; MSI_BASELINE=$3; REF_GENOME=$4;
#Check for required variables: if [ -z "$BAM_LIST" ]; thenecho"BAM_LIST is unset" && exit ; elseecho"BAM_LIST is set to '$BAM_LIST'"; fi if [ -z "$BEDFILE" ]; thenecho"BEDFILE is unset" && exit ; elseecho"BEDFILE is set to '$BEDFILE'"; fi if [ -z "$MSI_BASELINE" ]; thenecho"MSI_BASELINE is unset" && exit ; elseecho"MSI_BASELINE is set to '$MSI_BASELINE'"; fi if [ -z "$REF_GENOME" ]; thenecho"REF_GENOME is unset" && exit ; elseecho"REF_GENOME is set to '$REF_GENOME'"; fi
#"multiplier" is the number of standard deviations from the baseline that is required to call instability multiplier=2.0 #"msi_min_threshold" is the maximum fraction of unstable sites allowed to call a specimen MSI negative msi_min_threshold=0.2 #"msi_max_threshold" is the minimum fraction of unstable sites allowed to call a specimen MSI positive msi_max_threshold=0.2
for BAM in `sed '/^$/d'$BAM_LIST`; do SAVEPATH=$(dirname$BAM) BAMNAME=$(basename$BAM) PFX=${BAMNAME%.*}
mkdir -p $SAVEPATH/$PFX
echo “Starting Analysis of $PFX” >> $SAVEPATH/$PFX/msi_run_log.txt; date +"%D %H:%M" >> $SAVEPATH/$PFX/msi_run_log.txt;
echo"sorting bam of $PFX" >> $SAVEPATH/$PFX/msi_run_log.txt; date +"%D %H:%M" >> $SAVEPATH/$PFX/msi_run_log.txt; samtools sort -o $SAVEPATH/$PFX/$PFX.sorted.bam $BAM && samtools index $SAVEPATH/$PFX/$PFX.sorted.bam