SAMPLIST=$1 # Input is list of samples, one per line. Assumes each bam is in its own folder, labeled with the sample name. Bams are named sample.rmdup.bam

for SAMP in `cat $SAMPLIST`; do
	cd $SAMP
	#create index if not already present
	if test -f ./$SAMP.rmdup.bam.bai; then
		echo "index exists"
	else
		samtools index -@ 10 ./$SAMP.rmdup.bam
	fi
	/redser4/personal/andrew/src/mosdepth -t 10 -n -x $SAMP ./$SAMP.rmdup.bam
	cd ..
done
	
