INDEX=/home/linyize/WGSExtractv4/reference/genomes/hs38.fa.gz
sample=$1
dir=$2
fq1=${dir}/${sample}_1.fastq.gz
fq2=${dir}/${sample}_2.fastq.gz
echo $sample $fq1 $fq2

ulimit -n 2048

mkdir tmp2

# 双端
bwa mem -t 1 -R "@RG\tID:${sample}\tSM:${sample}\tLB:WGS\tPL:TheYtree.com" $INDEX $fq1 $fq2 
#|samtools view -bS - > tmp2/${sample}.paired.bam 

# 双端
# 排序 - 双端
samtools sort -o tmp2/${sample}.sorted.bam tmp2/${sample}.paired.bam
samtools index tmp2/${sample}.sorted.bam
samtools view -b -h tmp2/${sample}.sorted.bam chrM chrY > tmp2/${sample}.paired2.bam

# 去重
mv tmp2/${sample}.sorted.bam ${dir}/${sample}.WGS.bam
mv tmp2/${sample}.paired2.bam ${dir}/${sample}.chrYM.bam

rm -rf tmp2/*

