#! /bin/sh

INFILE=EF.phy
RAND=`expr $RANDOM \* 2 - 1` 

PREFIX=`echo $INFILE | sed -e 's/\.phy$//' -e 's/\.PHY$//'`

HEADLINE=`head -1 $INFILE | sed -e 's/^ *//' -e 's/ *$//' -e 's/  */ /'`
NUMTAXA=`echo $HEADLINE | cut -d ' ' -f 1` 
NUMCOLS=`echo $HEADLINE | cut -d ' ' -f 2` 

echo $NUMTAXA $NUMCOLS


rm -f outfile infile
(echo ${INFILE}; echo y; echo ${RAND}) | ./seqboot
mv outfile ${PREFIX}.outfile

NUMLINES=`grep -n "$NUMTAXA  *$NUMCOLS" ${PREFIX}.outfile | head -2 | tail -1 | sed -e 's/:.*//'`
NUMLINES=`expr $NUMLINES - 1`
echo $NUMLINES

split --suffix-length=3 --lines=$NUMLINES --numeric-suffixes --verbose ${PREFIX}.outfile ${PREFIX}.


