#!/bin/bash

#$ -N purge-yahs
#$ -cwd
#$ -o ../../logs/$JOB_NAME.$JOB_ID.log
#$ -e ../../logs/$JOB_NAME.$JOB_ID.err
#$ -pe smp 56
#$ -l h_vmem=4.4g


######################################
GENOME=/mnt/data/arslan/Teas/01_Assembly/Arima-Yahs/Yahs-AJ/AJ_scaffolds_final.fa

conda activate purgehap-env

minimap2 -t ${NSLOTS} -ax map-pb ${GENOME} /mnt/data/arslan/Teas/00_Reads_analysis/AJ.fastq.gz --secondary=no |\
    samtools sort -@ 20 -o AJ_yahs.bam

purge_haplotigs hist -b AJ_yahs.bam -g ${GENOME} -t ${NSLOTS}
purge_haplotigs cov -i AJ_yahs.bam.gencov -l 2 -h 95 -m 2 -o AJ_yahs_coverage_stats.csv
purge_haplotigs purge -I 8G -g ${GENOME} -c AJ_yahs_coverage_stats.csv -a 80 -t ${NSLOTS} -o AJ.curated
