# in the next line (and all other for loop lines), fill in your population names. For each population name, there should be a file $POP.list in the same directory that contains the bams for every sample in the population, one bam file per line.
for POP in pop1 pop2
do
	echo $POP
	/redser4/personal/jonas/src/angsd/angsd -b $POP'.list' -ref /redser4/genomes/Oncorhynchus_mykiss/GCF_013265735.2_USDA_OmykA_1.1_genomic.fna -anc /redser4/genomes/Oncorhynchus_mykiss/GCF_013265735.2_USDA_OmykA_1.1_genomic.fna -out results/$POP.noTrans -uniqueOnly 1 -remove_bads 1 -only_proper_pairs 1 -trim 5 -C 50 -minMapQ 20 -minQ 20 -setMaxDepth 90 -noTrans 1 -doCounts 1 -GL 2 -doSaf 1 -sites /redser4/personal/andrew/trout/GCF_013265735.2_USDA_OmykA_1.1_angsd_region_file.txt &
done
wait

echo "Finished all angsd saf steps"

for POP in pop1 pop2
do
        echo $POP
        /redser4/personal/jonas/src/angsd/misc/realSFS results/$POP.noTrans.saf.idx -fold 1 -P 10 > results/$POP.noTrans.sfs &
done
wait

echo "Finished all realsfs sfs steps"

for POP in pop1 pop2
do
	/redser4/personal/jonas/src/angsd/misc/realSFS saf2theta results/$POP.noTrans.saf.idx -outname results/$POP.noTrans -sfs results/$POP.noTrans.sfs -fold 1 &
done
wait

for POP in pop1 pop2
do
	/redser4/personal/jonas/src/angsd/misc/thetaStat do_stat results/$POP.noTrans.thetas.idx &
	/redser4/personal/jonas/src/angsd/misc/thetaStat do_stat results/$POP.noTrans.thetas.idx -win 50000 -step 10000 -outnames results/$POP.noTrans.thetasWindow.gz &
done
