Skip to content

Commit

Permalink
tests ode compartment arrays diffusive connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendes committed May 24, 2024
1 parent f249da7 commit 5930922
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/0025_CompartmentArray/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 0025_CompartmentArray

set of 27 units of model with compartment ODE connected by diffusive connections of *blob* 3x3x3

## tests

- 3D, 27 units, diffusive connection compartment ODE

- SBML file reads well
- network file reads well
- checks that coupling constant exists and is set to default value
- checks that there are 2 ODEs which contain the diffusive terms
65 changes: 65 additions & 0 deletions tests/0025_CompartmentArray/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

# work out our folder name
test=${PWD##*/} # to assign to a variable
test=${test:-/} # to correct for the case where PWD=/

# run sbmodelr
../../sbmodelr -d blob -c 0.05 --pn blob 0.9 uni ../sources/blob.cps 3 3 3 > output

fail=0

# compare output and target
difference=$(diff output target_stdout)
if [[ $difference ]]; then
printf 'FAIL %s\n' "${test}"
fail=1
fi

# create model summary
../model_report.py blob_3x3x3.cps >/dev/null
if ! [[ $? = 0 ]]; then
printf 'FAIL %s\n' "${test}"
exit -1
fi

# check that the coupling constant has been defined with the correct value
if ! grep -Pq "^k_blob_coupling\s+fixed\s+0.05" blob_3x3x3.summary.txt; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 2"
fi

# check that there are 27 compartments
n=$(grep -Pc "^blob_[123],[123],[123]\s+ode" blob_3x3x3.summary.txt )
if ((n != 27)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 4"
fi

# check that the ode for blob_2,2,2 (the center unit) has 6 diffusive terms
n=$(grep -P "^blob_2,2,2\s+ode" blob_3x3x3.summary.txt | grep -Po "\+ Values\[k_blob_coupling\] \* \("| wc -l)
if ((n != 6)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 8"
fi

# check that min and max of [blob]_0 are different (checks that --pn worked)
n=$(grep -Po "^blob_[123],[123],[123]\s+ode\s+(.[0-9]+\.[0-9]+\s)" blob_3x3x3.summary.txt | awk '(NR==1){Min=$3;Max=$3};(NR>=2){if(Min>$3) Min=$3;if(Max<$3) Max=$3} END {if(Min == Max) {print 1} else {print 0} }')
if ((n != 0)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 16"
fi

# validate the model with CopasiSE
../CopasiSE -c . --nologo --validate blob_3x3x3.cps > cpsout 2>&1
if ! [[ $? = 0 ]]; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 32"
fi

if [ "$fail" = 0 ] ; then
printf 'PASS %s\n' "${test}"
rm blob_3x3x3.* cpsout output
fi

exit $fail
8 changes: 8 additions & 0 deletions tests/0025_CompartmentArray/target_stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Processing ../sources/blob.cps
Reactions: 0
Species: 0 (Reactions: 0, Fixed: 0, Assignment: 0, ODE: 0)
Compartments: 1 (Fixed: 0, Assignment: 0, ODE: 1)
Global quantities: 0 (Fixed: 0, Assignment: 0, ODE: 0)
Events: 0 (Only time-dependent: 0, variable-dependent: 0)
created new model blob_3x3x3.cps with a 3D set of 27 replicas (3x3x3) of ../sources/blob.cps

0 comments on commit 5930922

Please sign in to comment.