#!/bin/bash

# parsing tools.cfg values
IN_FOLDER="../$(sed -n -e 's/^\s*kres_tsv\s*=\s*//p' ../tools.cfg)"
echo "input folder: $IN_FOLDER"
OUT_FOLDER="../$(sed -n -e 's/^\s*kres_srl\s*=\s*//p' ../tools.cfg)"
echo "output folder: $OUT_FOLDER"

SUFFIX="srl.tsv"

mkdir -p $OUT_FOLDER
rm $OUT_FOLDER/*${SUFFIX} &> /dev/null

for infile in $IN_FOLDER/*; do
	echo "Tagging: ${infile}"
	base=$(basename $infile | cut -d'.' -f1)
	outfile=${OUT_FOLDER}/${base}.${SUFFIX}

	# mate-tools tagger
	./scripts/parse_srl_only_mod.sh $infile $outfile

	if [ $? -eq 0 ]; then
		echo "Saved as ${outfile}"
	else
		echo "ERR"
		exit 1
	fi
done

