#!/bin/bash

echo $@

FWDFILE=$1
shift
REVFILE=$1
shift
OUTXML=$1
shift
OUTCSV=$1
shift
ORGANISM=$1

OUTFOLDER=$(mktemp -d --tmpdir tmpMOST_XXXXXXXXXXXXXXXXXXXX)
rm -rf $OUTFOLDER # MOST insists on creating the folder itself

CMD="MOST.py -1 $FWDFILE -2 $REVFILE -o $OUTFOLDER -st $ORGANISM"

echo $CMD
eval $CMD

STEM=$(basename $FWDFILE)
STEM="${STEM%.*}"

mv $OUTFOLDER"/"$STEM"_MLST_result.csv" $OUTCSV
mv "$OUTFOLDER/$STEM.results.xml" $OUTXML

rm -rf $OUTFOLDER
