#!/bin/sh
PREFIX=temp
FA=$(grep -P "index\t$2\t" $3/sam_fa_indices.loc | cut -f3)
samtools view -bt $FA.fai -o $PREFIX.bam $1 2> /dev/null
samtools sort -n $PREFIX.bam $PREFIX.namesorted 2> /dev/null
bam2hits $FA $PREFIX.namesorted.bam > $PREFIX.hits 2> /dev/null
mmseq $PREFIX.hits $PREFIX > /dev/null
mv $PREFIX.mmseq $4
mv $PREFIX.identical.mmseq $5
mv $PREFIX.gene.mmseq $6