runtests

来自「EM算法的改进」· 代码 · 共 300 行

TXT
300
字号
#!/bin/sh# runtests - created from runtests.txt by make## $Id: runtests.txt 1339 2006-09-21 19:46:28Z tbailey $## $Log$# Revision 1.7  2006/03/08 20:50:11  nadya# merge chamges from v3_5_2 branch## Revision 1.6.4.4  2006/01/31 19:16:42  nadya# rm obsolete $suffix references# use MEME_SH variable for script calling## Revision 1.6.4.3  2006/01/25 08:07:52  tbailey# Remove blank lines from output files before diff-ing so that they# don't mess up the automatic tests.# Remove output file lines starting with "LAM " produced by some MPI implementations.## Revision 1.6.4.2  2006/01/24 02:24:29  nadya# EXT is obsoleted by using printf()## Revision 1.6.4.1  2006/01/24 02:09:22  nadya# use EXT variable for echo# change "info" from an array to string to make it work on solaris# change output to be table-like## Revision 1.6  2005/10/05 06:18:35  nadya# use full path for "rm". Asssume everybody has /bin/rm.## Revision 1.5  2005/10/02 05:13:54  nadya# set a variable for sourcing meme.sh# add sourcing of meme_config to set additional environment# calli binary executables by variables set in meme_config.## Revision 1.4  2005/09/01 00:30:42  nadya# extrapolate dataset name from one  embedded (with wrong path) in memefile## Revision 1.3  2005/08/31 04:12:47  nadya# fix sed regexpr## Revision 1.2  2005/08/24 04:04:39  nadya# add func_run_mast_adn() for a speciic test## Revision 1.1  2005/08/18 01:40:18  nadya# new runtests, initial revision### set meme environment variablesENV=/root/etc/meme.shif [ -f $ENV ] ; then    . $ENVelse    echo "$ENV does not exist. Meme installation is incomplete"    exit 1fiCONF=/root/etc/meme_configif [ -f $CONF ] ; then    . $CONFelse    echo "$CONF does not exist. Meme installation is incomplete"    exit 1fi#####################################################################                      define functions ##################################################################### prints usage on stdoutfunc_usage () {   echo "USAGE: $0 [OPTION]"   echo   echo "Known options:"   echo "    -p NUM    run parallel version of MEME on NUM nodes"   echo "    -s        save results of MEME and MAST"   echo "    -nomeme   don't run MEME tests"   echo "    -nomast   don't run MAST tests"   echo "    -h        print this help"}# sets parameters for datasets# takes a dataset name as an argumentfunc_set_params () {    case "$1" in     crp0)        params="-dna -revcomp" ;;    INO_up800)        params="-dna -revcomp -bfile $dir/yeast.nc.6.freq" ;;    farntrans5)        params="-protein" ;;    lipocalin)        params="-protein" ;;    adh)        params="-protein" ;;    esac    params="$params -nostatus -nmotifs 2 -minw 8"}# runs make_logodds on input file and outputs# alphabet and database used for corresponding meme run# takes a meme filename as an argumentfunc_logodds () {    logodds=$dirout/logodds.$$    info=`perl $MEME_BIN/make_logodds $1 $logodds`    alphabet=`echo $info | awk '{print $1}'`    vardb=`echo $info | awk '{print $2}'`    database=$dir/`basename $vardb`}# run mast tests on all datasets func_run_mast () {    if [ $nomast ] ; then        echo "Skipping mast test"        return    fi	echo ""    echo  "                   Mast test for "	echo  "    ----------------------------------------------"	echo  "      Dataset       Model     Sequence     result " 	echo  "    ----------------------------------------------"    for dset in $datasets    do        for mod in $models        do		    seq=""            memefile=meme.$dset.$mod            func_logodds $dir/$memefile            params="-nostatus -logodds $logodds -alphabet $alphabet -mf $dir/$memefile"            mastfile=mast.$dset.$mod            params="$params -database $database -df $database"            $MEME_BIN/$MAST_EXEC "mast $memefile" $params > $dirout/$mastfile			line=`echo $dset $mod | awk '{printf("    %-16s%-8s%-14s  ", $1,$2, "")}'`            func_diff $mastfile             func_save $dirout/$mastfile            if [ "$dset" = "adh" ]; then                func_run_mast_adn             fi        done    done}# run additional mast test for adh datasetfunc_run_mast_adn () {    seq=mini-drosoph.s    params="-nostatus -logodds $logodds -alphabet $alphabet -mf $dir/$memefile"    mastfile=mast.$dset.$mod.$seq    args="$memefile -stdin -dna -seqp"    params="$params -stdin -df -stdin -dna -seqp"    cat $dir/$seq | $MEME_BIN/$MAST_EXEC "mast $args" $params > $dirout/$mastfile    func_diff $mastfile     func_save $dirout/$mastfile}# run meme tests on all datasetsfunc_run_meme () {    if [ $nomeme ] ; then        echo "Skipping meme test"        return    fi	echo ""    echo  "                   Meme test for "	echo  "    ----------------------------------------------"	echo  "      Dataset       Model     Sequence     result " 	echo  "    ----------------------------------------------"    for dset in $datasets    do        func_set_params $dset         for mod in $models        do            memefile=meme.$dset.$mod            $MEME_BIN/$MEME_SH $pargs -text $dir/$dset.s -mod $mod $params > $dirout/$memefile            func_diff $memefile             func_save $dirout/$memefile        done    done}# remove lines specified by regexpr from the file# takes a filename as an argumentfunc_sed () {    e1="/Release date/d"    e2="/http:/d"    e3="/MOTIFS/d"    e4="/Time/d"    e5="/CPU:/d"    e6="/DATAFILE=/d"    e7="/DATABASE/d"    e8="/command: /d"    e9="/Background letter frequencies/d"    e10="/Last updated/d"    e11="/^LAM/d"    e12="/^\$/d"    sed -e "$e1" -e "$e2" -e "$e3" -e "$e4" -e "$e5" \        -e "$e6" -e "$e7" -e "$e8" -e "$e9" -e "$e10" \        -e "$e11" -e "$e12" $1 > $1.sed}# checks two files for differences.  Arguments - a filename# and a string containing dataset and model info to print.func_diff () {    f1=$dir/$1      # first file    f2=$dirout/$1   # second file    # string to print    str=`echo $dset $mod $seq | awk '{printf("    %-16s%-8s%-14s  ", $1,$2,$3)}'`    if [ ! -f  $f1 ]; then        echo "File $f1 does not exist, can't compare output"        echo  "$str" "SKIPPED"        return     fi    if [ ! -f  $f2 ]; then        echo "File $f2 does not exist, can't compare output"        echo  "$str" "SKIPPED"        return     fi    func_sed $f1     func_sed $f2     num=`diff $f1.sed $f2.sed | wc -l`    status=$?    if [ $status -eq 0 -a  $num -eq 0 ]; then        echo  "$str" "OK"    else        echo  "$str" "FAIL"        err=1    fi    return }# initializes tests parametersfunc_set () {    datasets="crp0 INO_up800 farntrans5 lipocalin adh"    models="oops zoops tcm"    dir=$MEME_DIRECTORY/tests    dirout=$MEME_DIRECTORY/tests/results    if [ ! -d $dirout ]; then        cmd=`mkdir $dirout`        status=$?        if [ $status -eq 1 ] ; then             exit 1        fi    fi    err=0}# removes temp output filesfunc_clean () {    /bin/rm -rf $dir/*.sed $dirout/*.sed $dirout/logodds.*    if [ ! $err ] ; then        /bin/rm -rf $dirout    fi}# saves file produced by meme or mast into tests/# takes a file name as an argumentfunc_save () {    if [ $save ]; then        mv $1 $dir    fi}#####################################################################             check command line arguments and run tests##################################################################### check argumentswhile test $# -gt 0; do    case "$1" in    -s)        save=1 ;;    -p)        shift        procs=$1        pargs="-p $1"        ;;    -nomeme)        nomeme=1 ;;    -nomast)        nomast=1 ;;    -h)        func_usage        exit 1 ;;    *)        func_usage        exit 1 ;;    esac    shiftdone# run testsfunc_set func_run_memefunc_run_mastfunc_clean

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?