Skip to content

Commit

Permalink
test for GRN
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendes committed May 20, 2024
1 parent 2e348bb commit 4efefc0
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/0023_GRNrepressilator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 0023_GRNrepressilator

a gene regulatory network of 3 genes connected in a circle with inhibition (like repressilator)

## tests

- 1D, 3 units, network, GRN
- cps file reads well
- network file reads well
- named output file
- checks the regulated_by_1 rate law was created
- checks that there are exactly 3 species
- checks that noise worked
- checks no compartments created
- checks that there are three synthesis reactions
65 changes: 65 additions & 0 deletions tests/0023_GRNrepressilator/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 -g G --pn G 0.8 uni --grn-a -1 --grn-h 4 -n ../sources/3circle.gv -o repressilator.cps --ignore-compartments ../sources/GeneExpressionUnit.cps 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 repressilator.cps >/dev/null
if ! [[ $? = 0 ]]; then
printf 'FAIL %s\n' "${test}"
exit -1
fi

# check that there is one rate law for regulation by 1
if ! grep -Pq "^regulated_by_1\s+V \* \( \( 1 \+ \( 1 \+ a1 \) \* M1 \^ h1 \) \/ \( 1 \+ M1 \^ h1 \) \)" repressilator.summary.txt; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 2"
fi

# check that there are three species
n=$(grep -Pc "^G_[123]\s+reactions\s+[0-9]+\.[0-9]+" repressilator.summary.txt)
if ((n != 3)); then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 4"
fi

# check that min and max of initial concentrations are different (meaning noise worked!)
n=$(grep -Po "^G_[123]\s+reactions\s+([0-9]+\.[0-9]+\s)" repressilator.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 0} else {print 1}}')
if ((n != 0)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 8"
fi

# check that no new compartments were created
n=$(grep -Pc "^cell_[123]\s+fixed" repressilator.summary.txt)
if ((n != 0)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 16"
fi

# checks that there are three synthesis reactions
n=$(grep -Pc "synthesis (G_[123])\s+-> \1\;\s+G_[123]\s+regulated_by_1" repressilator.summary.txt)
if ((n != 3)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 32"
fi

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

exit $fail
9 changes: 9 additions & 0 deletions tests/0023_GRNrepressilator/target_stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Processing ../sources/GeneExpressionUnit.cps
Reactions: 2
Species: 1 (Reactions: 1, Fixed: 0, Assignment: 0, ODE: 0)
Compartments: 1 (Fixed: 1, Assignment: 0, ODE: 0)
Global quantities: 0 (Fixed: 0, Assignment: 0, ODE: 0)
Events: 0 (Only time-dependent: 0, variable-dependent: 0)
Network: directed (Nodes: 3, Edges: 3)
created new model repressilator.cps with a set of 3 replicas of ../sources/GeneExpressionUnit.cps

0 comments on commit 4efefc0

Please sign in to comment.