Skip to content

Commit

Permalink
test for element notes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendes committed May 26, 2024
1 parent 92bb27a commit b7cc8d0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/0027_PulsedDrugNotes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 0027_PulsedDrugNotes

creates a set of 2 units of the PulsedDrug model

## tests

- 1D, 2 units, events, notes
- cps file reads well
- produces no warning or error
- tests -o option to name output file
- checks that compartment notes were copied
- checks that species notes were copied
- checks that global quantity notes were copied
- validates the model with CopasiSE
54 changes: 54 additions & 0 deletions tests/0027_PulsedDrugNotes/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

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

fail=0

# run sbmodelr
../../sbmodelr -t drug --pn Drug_dose 0.5 uni -n ../sources/twins.gv -o PD2.cps ../sources/PulsedDrug.cps 2 > output

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

# poor man's way of checking existence of notes: grepping the cps file...

# check that there are two notes for the compartment
n=$(grep -c "a location within which every species is well mixed" PD2.cps)
if ((n != 2)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 2"
fi

# check that there are two notes for the S species
n=$(grep -c "fixed substrate" PD2.cps)
if ((n != 2)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 4"
fi

# check that there are two notes for the Drug_dose global quantity
n=$(grep -c "<p>the <i>amount</i> of drug added each time</p></body>" PD2.cps)
if ((n != 2)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 8"
fi

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

if [ "$fail" = 0 ] ; then
printf 'PASS %s\n' "${test}"
rm PD2.cps output > /dev/null 2>&1
fi

exit $fail
10 changes: 10 additions & 0 deletions tests/0027_PulsedDrugNotes/target_stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Processing ../sources/PulsedDrug.cps
Reactions: 3
Species: 5 (Reactions: 3, Fixed: 2, Assignment: 0, ODE: 0)
Compartments: 1 (Fixed: 1, Assignment: 0, ODE: 0)
Global quantities: 5 (Fixed: 5, Assignment: 0, ODE: 0)
Events: 2 (Only time-dependent: 0, variable-dependent: 2)
Network: undirected (Nodes: 2, Edges: 1)

created new model PD2.cps with a set of 2 replicas of ../sources/PulsedDrug.cps

0 comments on commit b7cc8d0

Please sign in to comment.