<commit_before>#!/bin/bash 


TESTSDIR=./tests

HEAD=/usr/bin/head
CUT=/usr/bin/cut
SED=/bin/sed

#HEAD=/sw/bin/head
#CUT=/sw/bin/cut
#SED=/sw/bin/sed

WRAPPER=./stochastic-testsuite

#WRAPPER=`pwd`/stochastic-testsuite.app/Contents/MacOS/stochastic-testsuite

# go over all models in tests/model-list
#MODELS=`cat tests/model-list`

if [ $# != 2 ] ; then
  echo -e "\nUsage: run.sh MODEL_LIST_FILE NUM_REPEATS\n";
  exit 1;
fi  

MODELFILE=$1
NUM_REPEATS=$2

MODELS=`cat $MODELFILE` 


function getSpecies()
{
    $HEAD -n1 $1 | $CUT -d ',' -f 2- --output-delimiter=" " | $SED 's/[ \t\r\n]*$//';
}


for MODEL in $MODELS;do
  # set parameters 
  RESULT="passed"
  ENDTIME=50
  STEPNUMBER=50
  INFILE=${TESTSDIR}/${MODEL}.xml
  OUTFILE=${TESTSDIR}/${MODEL}.RESULT
  MEAN_OUTFILE=${TESTSDIR}/${MODEL}-mean.RESULT
  SD_OUTFILE=${TESTSDIR}/${MODEL}-sd.RESULT
  SPECIESLIST=`getSpecies ${TESTSDIR}/${MODEL}-mean.csv`
  MEAN_REFERENCE_FILE=${TESTSDIR}/${MODEL}-mean.csv
  SD_REFERENCE_FILE=${TESTSDIR}/${MODEL}-sd.csv
  # run simulation 
  if [ -e $INFILE ] ; then
    #echo "$WRAPPER $INFILE $ENDTIME $STEPNUMBER $NUM_REPEATS $OUTFILE $SPECIESLIST"
    rm -f $OUTFILE
    $WRAPPER $INFILE $ENDTIME $STEPNUMBER $NUM_REPEATS $OUTFILE $SPECIESLIST || RESULT="failed" ;
    if [ "e$RESULT" == "efailed" ] ; then
      echo "ERROR: Simulation failed.";
      rm -f $OUTFILE;
    fi  
    if [ -e $OUTFILE ] ; then
      # calculate mean and standard deviation
      rm -f $MEAN_OUTFILE $SD_OUTFILE
      ./calculate_statistics.py $OUTFILE $MEAN_OUTFILE $SD_OUTFILE $STEPNUMBER $NUM_REPEATS || RESULT="failed" ;
      if [ "e$RESULT" == "efailed" ] ; then
        echo "ERROR: Statistical calculation failed.";
        rm -f $MEAN_OUTFILE $SD_OUTFILE;
      fi  
      # compare results
      if [ -e ${MEAN_OUTFILE} ] ; then
        if [ -e ${SD_REFERENCE_FILE} ] ; then 
          if [ -e ${MEAN_REFERENCE_FILE} ] ; then
             rm -f ${TESTSDIR}/${MODEL}-mean-compare.RESULT 
             ./compare_mean.py ${MEAN_OUTFILE} ${MEAN_REFERENCE_FILE} ${SD_REFERENCE_FILE} $NUM_REPEATS ${TESTSDIR}/${MODEL}-mean-compare.RESULT || RESULT="failed"; 
             rm -f ${TESTSDIR}/${MODEL}-sd-compare.RESULT <commit_msg>Fix the script to run with standard version of cut.<commit_after>#!/bin/bash 


TESTSDIR=./dsmts23-20080307

HEAD=/usr/bin/head
CUT=/usr/bin/cut
SED=//usr/bin/sed

#HEAD=/sw/bin/head
#CUT=/sw/bin/cut
#SED=/sw/bin/sed

#WRAPPER=./stochastic-testsuite

WRAPPER=`pwd`/stochastic-testsuite.app/Contents/MacOS/stochastic-testsuite

# go over all models in tests/model-list
#MODELS=`cat tests/model-list`

if [ $# != 2 ] ; then
  echo -e "\nUsage: run.sh MODEL_LIST_FILE NUM_REPEATS\n";
  exit 1;
fi  

MODELFILE=$1
NUM_REPEATS=$2

MODELS=`cat $MODELFILE` 


function getSpecies()
{
    $HEAD -n1 $1 | $CUT -d ',' -f 2- | $SED -e ' s/,/ /g; s/[ \t\r\n]*$//';
}


for MODEL in $MODELS;do
  # set parameters 
  RESULT="passed"
  ENDTIME=50
  STEPNUMBER=50
  INFILE=${TESTSDIR}/${MODEL}.xml
  OUTFILE=${TESTSDIR}/${MODEL}.RESULT
  MEAN_OUTFILE=${TESTSDIR}/${MODEL}-mean.RESULT
  SD_OUTFILE=${TESTSDIR}/${MODEL}-sd.RESULT
  SPECIESLIST=`getSpecies ${TESTSDIR}/${MODEL}-mean.csv`
  MEAN_REFERENCE_FILE=${TESTSDIR}/${MODEL}-mean.csv
  SD_REFERENCE_FILE=${TESTSDIR}/${MODEL}-sd.csv
  # run simulation 
  if [ -e $INFILE ] ; then
    echo "$WRAPPER $INFILE $ENDTIME $STEPNUMBER $NUM_REPEATS $OUTFILE $SPECIESLIST"
    rm -f $OUTFILE
    $WRAPPER $INFILE $ENDTIME $STEPNUMBER $NUM_REPEATS $OUTFILE $SPECIESLIST || RESULT="failed" ;
    if [ "e$RESULT" == "efailed" ] ; then
      echo "ERROR: Simulation failed.";
      rm -f $OUTFILE;
    fi  
    if [ -e $OUTFILE ] ; then
      # calculate mean and standard deviation
      rm -f $MEAN_OUTFILE $SD_OUTFILE
      ./calculate_statistics.py $OUTFILE $MEAN_OUTFILE $SD_OUTFILE $STEPNUMBER $NUM_REPEATS || RESULT="failed" ;
      if [ "e$RESULT" == "efailed" ] ; then
        echo "ERROR: Statistical calculation failed.";
        rm -f $MEAN_OUTFILE $SD_OUTFILE;
      fi  
      # compare results
      if [ -e ${MEAN_OUTFILE} ] ; then
        if [ -e ${SD_REFERENCE_FILE} ] ; then 
          if [ -e ${MEAN_REFERENCE_FILE} ] ; then
             rm -f ${TESTSDIR}/${MODEL}-mean-compare.RESULT 
             ./compare_mean.py ${MEAN_OUTFILE} ${MEAN_REFERENCE_FILE} ${SD_REFERENCE_FILE} $NUM_REPEATS ${TESTSDIR}/${MODEL}-mean-compare.RESULT || RESULT="failed"; 
             rm -f ${TESTSDIR}/${MODEL}-sd-compare.RESULT 
{'fraction_non_alphanumeric': 0.16289491373515572, 'fraction_numerical': 0.00717006497871387, 'mean_word_length': 3.2232734153263953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6483224', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1722, 'n_words': 335}