Skip to content
Snippets Groups Projects
run_pepstats 1.67 KiB
Newer Older
tjc's avatar
tjc committed
#!/bin/sh -

# this script will run pepstats on a sequence input file or on each
# file in a file of filenames

# to customise this script see the function called run_one_prog below


RCS_HEADER="$Header: //tmp/pathsoft/artemis/etc/run_pepstats,v 1.1 2004-06-09 10:03:10 tjc Exp $"

PROG=`echo $RCS_HEADER | sed 's/.*run_\(.*\),v.*/\1/'`


if [ $# = 4 -a x$1 = x-onefile ]
then
    shift
    ONEFILE=t
    PARAMETERS=$3 export PARAMETERS
else
    if [ $# = 2 ]
    then
        PARAMETERS=$2 export PARAMETERS
    else
        echo usage: $0 -onefile input_file output_file parameters 1>&2
        echo    or: $0 file_of_filenames parameters 1>&2
        exit 1
    fi
fi


### change this function to suit your site:

run_one_prog () {
    INPUT_FILE=$1
    OUTPUT_FILE=$2

    ### change these lines:
    EXEC=pepstats

    COMMAND_LINE="$EXEC -filter $INPUT_FILE"

    echo "about to start $EXEC with input from $INPUT_FILE and output to" 1>&2
    echo "$OUTPUT_FILE using parameters: $PARAMETERS" 1>&2
    echo "command line: $COMMAND_LINE" 1>&2

    # add/change the flags to suit your site:
    (head -1 $INPUT_FILE | sed 's/^>//'; echo;
     $COMMAND_LINE) 2>&1 > $OUTPUT_FILE | tee ${PROG}_errors.new 1>&2

    #### end of changes


    if [ -s ${PROG}_errors.new ]
    then
        ( echo ERROR running $PROG: ; echo; 
          echo ===================================================
          cat ${PROG}_errors.new ) >> $OUTPUT_FILE
        cat ${PROG}_errors.new >> ${PROG}_errors
    fi
}

(echo "#!/bin/sh -"; echo "kill $$") > $PROG.kill

chmod a+x $PROG.kill

if [ x$ONEFILE = x ]
then
    for i in `cat $1`
    do
        run_one_prog $i $i.out
    done

else
    run_one_prog $1 $2
fi

exit 0