#!/bin/bash
dir="$(cd "$(dirname "$0")" && pwd)"

input=$1
ref=$2
output=$3
f=$(file $input)
zipType="Zip archive"
if [[ "$f" == *"$zipType"* ]]
then
	echo "Zip archive, assuming IMGT output file"
	echo "Trying: unzip $input -d $PWD/files/"
	unzip $input -d $PWD/files/ > $PWD/unziplog.log
	cat $PWD/files/*/2_* | cut -f2,4,7 > $PWD/gappednt.txt
	python $dir/script_imgt.py --input $PWD/gappednt.txt --ref $ref --output $output
else
	python $dir/script_xlsx.py --input $input --ref $ref --output $output
fi
