#!/bin/bash

pop=$1

cp /mnt/project/genotypes/ukb22418.hg38.{pgen,pvar,psam} .
cp /mnt/project/import/population/ukbb_qced.${pop}.txt.gz .

echo -e "6\t23000000\t37000000" > mhc.bed

thr=6
mem=24000

plink2 \
  --pfile ukb22418.hg38 \
  --keep ukbb_qced.${pop}.txt.gz \
  --maf 0.01 \
  --exclude bed0 mhc.bed \
  --threads $thr \
  --memory $mem \
  --indep-pairwise 1000 100 0.9 \
  --autosome \
  --out ukb22418.hg38.${pop}.1000_100_09

gzip -f ukb22418.hg38.${pop}.1000_100_09.prune.in

rm ukb22418.hg38.${pop}.1000_100_09.prune.out
rm ukb22418.hg38.{pgen,pvar,psam}
rm mhc.bed
rm ukbb_qced.${pop}.txt.gz

