| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# The tests here mainly check that errors are caught and that |
| 4 |
# execution is successful in normal cases. For some cases the output |
| 5 |
# is compared with reference output, but the correctness of |
| 6 |
# calculations is generally handled by the unit tests. |
| 7 |
|
| 8 |
# Making this a .in-file was necessary to get 'make distcheck' to work |
| 9 |
|
| 10 |
cli=../src/freesasa |
| 11 |
datadir=@top_srcdir@/tests/data |
| 12 |
sharedir=@top_srcdir@/share/ |
| 13 |
dump=tmp/test-cli.dump # will only contain the latest output |
| 14 |
nofile=nonexistent-file |
| 15 |
nodir=nonexistent-dir/file |
| 16 |
smallpdb=$datadir/rsa/GLY.pdb |
| 17 |
#global errors |
| 18 |
errors=0 |
| 19 |
use_xml=0 |
| 20 |
if [[ "x@USE_XML@" = "xyes" ]] ; then |
| 21 |
use_xml=1 |
| 22 |
fi |
| 23 |
use_xmllint=0 |
| 24 |
if [[ "x@XMLLINT@" = "xxmllint" ]] ; then |
| 25 |
use_xmllint=1 |
| 26 |
fi |
| 27 |
use_json=0 |
| 28 |
if [[ "x@USE_JSON@" = "xyes" ]] ; then |
| 29 |
use_json=1 |
| 30 |
fi |
| 31 |
use_jsonlint=0 |
| 32 |
if [[ "x@JSONLINT@" = "xjsonlint" ]] ; then |
| 33 |
use_jsonlint=1 |
| 34 |
fi |
| 35 |
|
| 36 |
|
| 37 |
function assert_pass |
| 38 |
{ |
| 39 |
eval $1 |
| 40 |
if [[ $? -ne 0 ]]; then |
| 41 |
echo Error: \"$1\" failed |
| 42 |
let errors=errors+1 |
| 43 |
#else |
| 44 |
# echo \"$1\" successful |
| 45 |
fi |
| 46 |
} |
| 47 |
|
| 48 |
function assert_fail |
| 49 |
{ |
| 50 |
eval $1 2>/dev/null |
| 51 |
if [[ $? -eq 0 ]]; then |
| 52 |
echo Error: \"$1\" did not fail as expected |
| 53 |
let errors=errors+1 |
| 54 |
#else |
| 55 |
# echo \"$1\" failed as expected; |
| 56 |
fi |
| 57 |
} |
| 58 |
|
| 59 |
function assert_equal_opt |
| 60 |
{ |
| 61 |
tmp1=tmp/tmp1 |
| 62 |
tmp2=tmp/tmp2 |
| 63 |
eval $1 $2 > $tmp1 2>/dev/null |
| 64 |
eval $1 $3 > $tmp2 2>/dev/null |
| 65 |
diff -B $tmp1 $tmp2 |
| 66 |
if [[ $? -ne 0 ]]; then |
| 67 |
echo Error: \"$1\" gives different results with arguments \"$2\" and \"$3\" |
| 68 |
let errors=errors+1 |
| 69 |
#else |
| 70 |
# echo \"$1\" gives same result with arguments \"$2\" and \"$3\". Success. |
| 71 |
fi |
| 72 |
} |
| 73 |
|
| 74 |
function assert_equal_total |
| 75 |
{ |
| 76 |
tmp1=tmp/tmp1 |
| 77 |
tmp2=tmp/tmp2 |
| 78 |
|
| 79 |
eval $1 $2 | grep "Total" > $tmp1 2>/dev/null |
| 80 |
if [[ $? -ne 0 ]]; then |
| 81 |
echo Error: \"$1 $2\" fails |
| 82 |
let errors=errors+1 |
| 83 |
fi |
| 84 |
|
| 85 |
eval $1 $3 | grep "Total" > $tmp2 2>/dev/null |
| 86 |
if [[ $? -ne 0 ]]; then |
| 87 |
echo Error: \"$1 $3\" fails |
| 88 |
let errors=errors+1 |
| 89 |
fi |
| 90 |
|
| 91 |
diff $tmp1 $tmp2 |
| 92 |
if [[ $? -ne 0 ]]; then |
| 93 |
echo Error: \"$1\" gives different results with arguments \"$2\" and \"$3\" |
| 94 |
let errors=errors+1 |
| 95 |
#else |
| 96 |
# echo \"$1\" gives same result with arguments \"$2\" and \"$3\". Success. |
| 97 |
fi |
| 98 |
} |
| 99 |
|
| 100 |
if [[ ! -d tmp ]]; then mkdir tmp; fi |
| 101 |
|
| 102 |
rm -f tmp/* |
| 103 |
echo |
| 104 |
echo "== Basic file errors ==" |
| 105 |
assert_fail "$cli > $dump" |
| 106 |
assert_fail "$cli $nofile > $dump" |
| 107 |
assert_fail "$cli < $nofile > $dump" |
| 108 |
assert_fail "$cli -c $nofile < $smallpdb > $dump" |
| 109 |
assert_fail "$cli < $smallpdb > $nodir" |
| 110 |
assert_fail "$cli -e $nodir $smallpdb" |
| 111 |
assert_fail "$cli -o $nodir $smallpdb" |
| 112 |
# can only have one output |
| 113 |
assert_fail "$cli -o $dump -o $dump $smallpdb" |
| 114 |
# deprecated |
| 115 |
assert_fail "$cli --B-value-file $nodir < $smallpdb > $dump" |
| 116 |
assert_fail "$cli --residue-type-file $nodir < $smallpdb > $dump" |
| 117 |
assert_fail "$cli --residue-file $nodir < $smallpdb > $dump" |
| 118 |
|
| 119 |
echo |
| 120 |
echo "== General options ==" |
| 121 |
# unknown options |
| 122 |
assert_fail "$cli --blablabla $smallpdb" |
| 123 |
assert_fail "$cli -x $smallpdb" |
| 124 |
# no option argument |
| 125 |
assert_fail "$cli $smallpdb -o" |
| 126 |
# help message |
| 127 |
assert_pass "$cli -h > $dump 2> /dev/null" |
| 128 |
assert_pass "$cli --deprecated > $dump 2> /dev/null" |
| 129 |
# check that it's a valid version number |
| 130 |
version=`$cli -v | head -n 1` |
| 131 |
assert_pass "echo $version | perl -ne 'if (m/FreeSASA (\d+\.)*\d(-beta)?$/) {exit 0} else {exit 1}'" |
| 132 |
# check that running with several output options doesn't crash |
| 133 |
assert_pass "$cli -o $dump -e tmp/err -n 1 $smallpdb" |
| 134 |
|
| 135 |
echo |
| 136 |
echo "== Testing S&R ==" |
| 137 |
assert_pass "$cli -S < $datadir/1ubq.pdb > $dump" |
| 138 |
echo |
| 139 |
#check that output message has required components, also verifies that basics of computation still work |
| 140 |
assert_pass "grep 'source\s\s*: stdin' $dump" |
| 141 |
$cli -S $datadir/1ubq.pdb > $dump |
| 142 |
assert_pass "grep 'source\s\s*: $datadir/1ubq.pdb' $dump" |
| 143 |
assert_pass "grep 'atoms\s\s*: 602' $dump" |
| 144 |
assert_pass "grep 'probe-radius\s\s*: [[:digit:]]' $dump" |
| 145 |
assert_pass "grep 'threads\s\s*: [[:digit:]]' $dump" |
| 146 |
assert_pass "grep 'testpoints\s\s*: [[:digit:]]' $dump" |
| 147 |
assert_pass "grep 'algorithm\s\s*: \w' $dump" |
| 148 |
assert_pass "grep 'Total\s\s*:\s\s*4834.72' $dump" |
| 149 |
assert_pass "grep 'Polar\s\s*:\s\s*2515.82' $dump" |
| 150 |
assert_pass "grep 'Apolar\s\s*:\s\s*2318.90' $dump" |
| 151 |
# The above formulation of log output gives freedom in ordering and |
| 152 |
# whitespace, and also version. Allows non-essential details to change |
| 153 |
# without breaking the test. Will not be performed for variant |
| 154 |
# parameter values, those should be covered by tests. |
| 155 |
assert_pass "$cli -S -Y $datadir/1d3z.pdb -w > $dump" |
| 156 |
assert_pass "grep 'atoms\s\s*: 1231' $dump" |
| 157 |
assert_pass "grep 'Total\s\s*:\s\s*5035.61' $dump" |
| 158 |
assert_pass "$cli -S -H -w $datadir/1ubq.pdb > $dump" # suppress warnings here |
| 159 |
assert_pass "grep 'atoms\s\s*: 660' $dump" |
| 160 |
assert_pass "grep 'Total\s\s*:\s\s*5656.65' $dump" |
| 161 |
assert_pass "$cli -S -n 50 < $datadir/1ubq.pdb > $dump" |
| 162 |
assert_fail "$cli -S -n 0 < $datadir/1ubq.pdb > $dump" |
| 163 |
assert_fail "$cli -S -n \"-1\" < $datadir/1ubq.pdb > $dump" |
| 164 |
assert_fail "$cli -S -t 1000 < $datadir/1ubq.pdb > $dump" |
| 165 |
assert_pass "$cli -S -t 16 < $smallpdb > $dump" |
| 166 |
|
| 167 |
echo |
| 168 |
echo "== Testing -m -M and -C options ==" |
| 169 |
# using flags -S and -n 10 to speed things up |
| 170 |
assert_pass "$cli -n 2 -S -M $datadir/1d3z.pdb > $dump" |
| 171 |
n_mod=`grep 1d3z.pdb $dump | wc -l` |
| 172 |
assert_pass "test $n_mod -eq 10" |
| 173 |
assert_pass "$cli -n 2 -S -C $datadir/1d3z.pdb > $dump" |
| 174 |
n_mod=`grep 1d3z.pdb $dump | wc -l` |
| 175 |
assert_pass "test $n_mod -eq 1" |
| 176 |
assert_pass "$cli -n 2 -S -M -C $datadir/1d3z.pdb > $dump" |
| 177 |
n_mod=`grep 1d3z.pdb $dump | wc -l` |
| 178 |
assert_pass "test $n_mod -eq 10" |
| 179 |
assert_pass "$cli -n 2 -S -M $datadir/2jo4.pdb > $dump" |
| 180 |
n_mod=`grep 2jo4.pdb $dump | wc -l` |
| 181 |
assert_pass "test $n_mod -eq 10" |
| 182 |
assert_pass "$cli -n 2 -S -C $datadir/2jo4.pdb > $dump" |
| 183 |
n_mod=`grep 2jo4.pdb $dump | wc -l` |
| 184 |
assert_pass "test $n_mod -eq 4" |
| 185 |
assert_pass "$cli -n 2 -S -M -C $datadir/2jo4.pdb > $dump" |
| 186 |
n_mod=`grep 2jo4.pdb $dump | wc -l` |
| 187 |
assert_pass "test $n_mod -eq 40" |
| 188 |
assert_fail "$cli -mM $datadir/2jo4.pdb > $dump" |
| 189 |
|
| 190 |
echo |
| 191 |
echo "== Testing L&R ==" |
| 192 |
assert_pass "$cli -L < $smallpdb > $dump" |
| 193 |
assert_pass "$cli -L -n 10 < $smallpdb > $dump" |
| 194 |
assert_fail "$cli -L -n 0 < $smallpdb > $dump" |
| 195 |
assert_fail "$cli -L -n \"-1\" < $smallpdb > $dump" |
| 196 |
assert_fail "$cli -L -t 1000 < $datadir/1ubq.pdb > $dump" |
| 197 |
assert_pass "$cli -L -t 16 < $smallpdb > $dump" |
| 198 |
|
| 199 |
echo |
| 200 |
echo "== Testing option --chain-groups ==" |
| 201 |
assert_pass "$cli -g S -S -n 10 $smallpdb > $dump" |
| 202 |
assert_fail "$cli -g B -S -n 10 $smallpdb > $dump" |
| 203 |
assert_pass "$cli -g AB -S -n 10 $datadir/2jo4.pdb > $dump" |
| 204 |
assert_fail "$cli -g E -S -n 10 $datadir/2jo4.pdb > $dump" |
| 205 |
assert_pass "$cli -g AB+CD -S -n 10 $datadir/2jo4.pdb > $dump" |
| 206 |
assert_fail "$cli -g A-B -S -n 10 $datadir/2jo4.pdb > $dump" |
| 207 |
assert_fail "$cli -g AB -S -n 10 $smallpdb > $dump" |
| 208 |
assert_fail "$cli -g A+B -S -n 10 $smallpdb > $dump" |
| 209 |
|
| 210 |
echo |
| 211 |
echo "== Testing probe radius ==" |
| 212 |
assert_fail "$cli -S -n 10 -p=-1 < $datadir/1ubq.pdb > $dump" |
| 213 |
assert_pass "$cli -S -n 10 -p 1 < $datadir/1ubq.pdb > $dump" |
| 214 |
assert_pass "$cli -S -p 1.4 --format=pdb < $datadir/1ubq.pdb | grep -v REMARK > tmp/bfactor.pdb" |
| 215 |
assert_pass "diff tmp/bfactor.pdb $datadir/1ubq.B.pdb" |
| 216 |
|
| 217 |
echo |
| 218 |
echo "== Testing option --unknown ==" |
| 219 |
assert_pass "$cli --unknown=guess -Y -w -n 2 $datadir/1d3z.pdb > $dump" |
| 220 |
assert_pass "grep 1231 $dump" |
| 221 |
assert_pass "$cli --unknown=skip -Y -w -n 2 $datadir/1d3z.pdb > $dump" |
| 222 |
assert_pass "grep 602 $dump" |
| 223 |
assert_fail "$cli --unknown=halt -Y -w -n 2 $datadir/1d3z.pdb > $dump" |
| 224 |
# misspelling should fail |
| 225 |
assert_fail "$cli --unknown=haltt -Y -w -n 2 $datadir/1d3z.pdb > $dump" |
| 226 |
|
| 227 |
echo |
| 228 |
echo "== Testing option --cif ==" |
| 229 |
assert_equal_total "$cli" "$datadir/1ubq.pdb" "$datadir/1ubq.cif --cif" |
| 230 |
assert_equal_total "$cli" "$datadir/1d3z.pdb" "$datadir/1d3z.cif --cif" |
| 231 |
assert_equal_total "$cli" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" |
| 232 |
assert_equal_total "$cli" "$datadir/5hdn.pdb" "$datadir/5hdn.cif --cif" |
| 233 |
assert_equal_total "$cli" "$datadir/3bkr.pdb" "$datadir/3bkr.cif --cif" |
| 234 |
assert_equal_total "$cli -w" "$datadir/3gnn.pdb" "$datadir/3gnn.cif --cif" |
| 235 |
assert_equal_total "$cli --join-models" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" |
| 236 |
assert_equal_total "$cli --chain-groups AB+CD -S -n 10" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" |
| 237 |
assert_pass "$cli --cif --separate-models --format=cif $datadir/1ubq.cif > $dump" |
| 238 |
assert_pass "$cli --cif --format=cif $datadir/1ubq.cif > $dump" |
| 239 |
assert_pass "$cli --cif --format=cif --separate-chains $datadir/1ubq.cif > $dump" |
| 240 |
assert_pass "$cli --cif --format=cif --separate-chains --separate-models $datadir/1ubq.cif > $dump" |
| 241 |
assert_fail "$cli --cif --format=pdb $datadir/1ubq.cif > $dump" |
| 242 |
assert_fail "$cli --format=cif $datadir/1ubq.pdb > $dump" |
| 243 |
|
| 244 |
echo |
| 245 |
echo "== Testing --separate-chains and --separate-models output are equal between cif and pdb" |
| 246 |
assert_equal_total "$cli --separate-chains -S -n 10" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" |
| 247 |
assert_equal_total "$cli --separate-chains -S -n 10" "$datadir/2isk.pdb" "$datadir/2isk.cif --cif" |
| 248 |
assert_equal_total "$cli --separate-chains -S -n 10" "$datadir/1sui.pdb" "$datadir/1sui.cif --cif" |
| 249 |
assert_equal_total "$cli --separate-chains -S -n 10" "$datadir/5dx9.pdb" "$datadir/5dx9.cif --cif" |
| 250 |
|
| 251 |
# need input files with multiple models |
| 252 |
assert_equal_total "$cli --separate-models -S -n 10" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" |
| 253 |
assert_equal_total "$cli --separate-models -S -n 10" "$datadir/2isk.pdb" "$datadir/2isk.cif --cif" |
| 254 |
assert_equal_total "$cli --separate-models -S -n 10" "$datadir/1sui.pdb" "$datadir/1sui.cif --cif" |
| 255 |
assert_equal_total "$cli --separate-models -S -n 10" "$datadir/1d3z.pdb" "$datadir/1d3z.cif --cif" |
| 256 |
# need input files with multiple models |
| 257 |
assert_equal_total "$cli --separate-chains --separate-models -S -n 10" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" |
| 258 |
assert_equal_total "$cli --separate-chains --separate-models -S -n 10" "$datadir/2isk.pdb" "$datadir/2isk.cif --cif" |
| 259 |
assert_equal_total "$cli --separate-chains --separate-models -S -n 10" "$datadir/1sui.pdb" "$datadir/1sui.cif --cif" |
| 260 |
assert_equal_total "$cli --separate-chains --separate-models -S -n 10" "$datadir/1d3z.pdb" "$datadir/1d3z.cif --cif" |
| 261 |
|
| 262 |
echo |
| 263 |
echo "== Testing user-configurations ==" |
| 264 |
assert_pass "$cli -c $sharedir/naccess.config -n 3 < $smallpdb > $dump" |
| 265 |
assert_pass "$cli -c $sharedir/oons.config -n 3 < $smallpdb > $dump" |
| 266 |
assert_fail "$cli -c $datadir/err.config -n 3 < $smallpdb > $dump" |
| 267 |
# can't combine these options |
| 268 |
assert_fail "$cli -c $datadir/naccess.config -n 3 -O < $smallpdb > $dump" |
| 269 |
assert_fail "$cli -c $datadir/naccess.config -n 3 --radii=naccess < $smallpdb > $dump" |
| 270 |
|
| 271 |
echo |
| 272 |
echo "== Testing --radii" == |
| 273 |
assert_pass "$cli --radii=naccess -n 3 < $datadir/1ubq.pdb > tmp/static.dat" |
| 274 |
assert_pass "$cli -c $sharedir/naccess.config -n 3 < $datadir/1ubq.pdb > tmp/from_config.dat" |
| 275 |
assert_pass "diff tmp/static.dat tmp/from_config.dat" |
| 276 |
assert_pass "$cli --radii=protor -n 3 < $datadir/1ubq.pdb > tmp/static.dat" |
| 277 |
assert_pass "$cli -c $sharedir/protor.config -n 3 < $datadir/1ubq.pdb > tmp/from_config.dat" |
| 278 |
assert_pass "diff tmp/static.dat tmp/from_config.dat" |
| 279 |
assert_fail "$cli --radii=bla -n 3 < $datadir/1ubq.pdb > $dump" |
| 280 |
|
| 281 |
echo |
| 282 |
echo "== Testing res format ==" |
| 283 |
assert_pass "$cli -S --format=res -o tmp/restype -e $dump < $datadir/1ubq.pdb" |
| 284 |
assert_pass "diff tmp/restype $datadir/restype.reference" |
| 285 |
#deprecated |
| 286 |
assert_pass "$cli -S -r < $datadir/1ubq.pdb > tmp/restype" |
| 287 |
assert_pass "diff tmp/restype $datadir/restype.reference" |
| 288 |
|
| 289 |
echo |
| 290 |
echo "== Testing seq format ==" |
| 291 |
assert_pass "$cli -S --format=seq -o tmp/seq < $datadir/1ubq.pdb" |
| 292 |
assert_pass "diff tmp/seq $datadir/seq.reference" |
| 293 |
#deprecated |
| 294 |
assert_pass "$cli -S -R < $datadir/1ubq.pdb > tmp/seq" |
| 295 |
assert_pass "diff tmp/seq $datadir/seq.reference" |
| 296 |
|
| 297 |
echo |
| 298 |
echo "== Testing PDB output format ==" |
| 299 |
assert_pass "$cli -S --format=pdb < $datadir/1ubq.pdb | grep -v REMARK > tmp/bfactor.pdb" |
| 300 |
assert_pass "diff tmp/bfactor.pdb $datadir/1ubq.B.pdb" |
| 301 |
#deprecated |
| 302 |
assert_pass "$cli -S -B < $datadir/1ubq.pdb | grep -v REMARK > tmp/bfactor.pdb" |
| 303 |
assert_pass "diff tmp/bfactor.pdb $datadir/1ubq.B.pdb" |
| 304 |
|
| 305 |
echo |
| 306 |
echo "== Testing RSA format ==" |
| 307 |
for r in protor naccess |
| 308 |
do |
| 309 |
for p in $(ls $datadir/rsa/*.pdb) |
| 310 |
do |
| 311 |
rel=$($cli -L -n 1000 $p --format=rsa --radii=$r | grep "S 2" | sed "s/[[:space:]]\{1,\}/ /g" | cut -f 6,8,10,12,14 -d ' ') |
| 312 |
if [[ $p == *"GLY"* ]] |
| 313 |
then |
| 314 |
assert_pass "test '$rel' = '100.0 N/A 100.0 100.0 100.0' && test $p" |
| 315 |
else |
| 316 |
assert_pass "test '$rel' = '100.0 100.0 100.0 100.0 100.0' && test $p" |
| 317 |
fi |
| 318 |
done |
| 319 |
done |
| 320 |
assert_fail "$cli --format=rsa -C $smallpdb" |
| 321 |
assert_fail "$cli --format=rsa -M $smallpdb" |
| 322 |
assert_pass "$cli -L -n 1000 --format=rsa -O -w $datadir/rsa/ALA.pdb > tmp/no_rel" |
| 323 |
rel=$(grep "S 2" tmp/no_rel | sed "s/[[:space:]]\{1,\}/ /g" | cut -f 6,8,10,12,14 -d ' ') |
| 324 |
assert_pass "test '$rel' = 'N/A N/A N/A N/A N/A'" |
| 325 |
# deprecated |
| 326 |
assert_pass "$cli --rsa $datadir/1ubq.pdb > $dump" |
| 327 |
|
| 328 |
echo "== Verify idempotency of CIF format ==" |
| 329 |
assert_equal_opt "$cli --cif --format=cif $datadir/1ubq.cif" "" " | $cli --cif --format=cif" |
| 330 |
assert_equal_opt "$cli --cif --format=cif --separate-chains $datadir/2jo4.cif" "" " | $cli --separate-chains --cif --format=cif" |
| 331 |
assert_equal_opt "$cli --cif --format=cif --separate-models $datadir/2jo4.cif" "" " | $cli --separate-models --cif --format=cif" |
| 332 |
assert_equal_opt "$cli --cif --format=cif --separate-models --separate-chains $datadir/2jo4.cif" "" \ |
| 333 |
" | $cli --separate-models --separate-chains --cif --format=cif" |
| 334 |
|
| 335 |
# XML // very basic testing, just to make sure XML is valid and that the right tags are present |
| 336 |
if [[ use_xml -eq 1 ]] ; then |
| 337 |
echo |
| 338 |
echo "== Testing XML ==" |
| 339 |
xml_file=tmp/test.xml |
| 340 |
|
| 341 |
assert_pass "$cli --format=xml $smallpdb > $xml_file" |
| 342 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 343 |
|
| 344 |
assert_pass "$cli --format=xml --depth=atom $smallpdb > $xml_file" |
| 345 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 346 |
assert_pass "grep '<atom' $xml_file > $dump" |
| 347 |
assert_pass "grep '<residue' $xml_file > $dump" |
| 348 |
assert_pass "grep '<chain' $xml_file > $dump" |
| 349 |
|
| 350 |
assert_pass "$cli --format=xml --depth=residue $smallpdb > $xml_file" |
| 351 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 352 |
assert_fail "grep '<atom' $xml_file > $dump" |
| 353 |
assert_pass "grep '<residue' $xml_file > $dump" |
| 354 |
assert_pass "grep '<chain' $xml_file > $dump" |
| 355 |
|
| 356 |
assert_pass "$cli --format=xml --depth=chain $smallpdb > $xml_file" |
| 357 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 358 |
assert_fail "grep '<atom' $xml_file > $dump" |
| 359 |
assert_fail "grep '<residue' $xml_file > $dump" |
| 360 |
assert_pass "grep '<chain' $xml_file > $dump" |
| 361 |
|
| 362 |
assert_pass "$cli --format=xml --depth=structure $smallpdb > $xml_file" |
| 363 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 364 |
assert_fail "grep '<atom' $xml_file > $dump" |
| 365 |
assert_fail "grep '<residue' $xml_file > $dump" |
| 366 |
assert_fail "grep '<chain' $xml_file > $dump" |
| 367 |
|
| 368 |
assert_pass "$cli --format=xml -C $datadir/2jo4.pdb > $xml_file" |
| 369 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 370 |
assert_fail "grep '<selection' $xml_file > $dump" |
| 371 |
|
| 372 |
assert_pass "$cli --format=xml -C $smallpdb --select=\"ala, resn ala\" --select=\"C, name C\" > $xml_file" |
| 373 |
if [[ use_xmllint -eq 1 ]] ; then assert_pass "xmllint $xml_file > $dump"; fi |
| 374 |
assert_pass "grep '<selection' $xml_file > $dump" |
| 375 |
|
| 376 |
# misspelling |
| 377 |
assert_fail "$cli --format=xml --depth=structures $smallpdb > $xml_file" |
| 378 |
fi |
| 379 |
# JSON // very basic testing, just to make sure JSON is valid and that the right tags are present |
| 380 |
if [[ use_json -eq 1 ]] ; then |
| 381 |
echo |
| 382 |
echo "== Testing JSON ==" |
| 383 |
json_file=tmp/test.json |
| 384 |
assert_pass "$cli --format=json $smallpdb > $json_file" |
| 385 |
if [[ use_jsonlint -eq 1 ]] ; then assert_pass "jsonlint $json_file > $dump"; fi |
| 386 |
|
| 387 |
assert_pass "$cli --format=json --depth=atom $smallpdb > $json_file" |
| 388 |
if [[ use_jsonlint -eq 1 ]] ; then assert_pass "jsonlint $json_file > $dump"; fi |
| 389 |
assert_pass "grep 'atom' $json_file > $dump" |
| 390 |
assert_pass "grep 'residue' $json_file > $dump" |
| 391 |
assert_pass "grep 'chain' $json_file > $dump" |
| 392 |
|
| 393 |
assert_pass "$cli --format=json -C $datadir/2jo4.pdb > $json_file" |
| 394 |
if [[ use_jsonlint -eq 1 ]] ; then assert_pass "jsonlint $json_file > $dump"; fi |
| 395 |
assert_fail "grep 'selection' $json_file > $dump" |
| 396 |
|
| 397 |
assert_pass "$cli --format=json $smallpdb --select=\"ala, resn ala\" --select=\"C, name C\" > $json_file" |
| 398 |
if [[ use_jsonlint -eq 1 ]] ; then assert_pass "jsonlint $json_file > $dump"; fi |
| 399 |
assert_pass "grep 'selection' $json_file > $dump" |
| 400 |
fi |
| 401 |
|
| 402 |
echo |
| 403 |
echo "== Testing option --select ==" |
| 404 |
assert_pass "$cli -S --select \"s1, resn ala\" --select \"s2, resn arg\" --select \"s3, resi 1\" $datadir/1ubq.pdb > tmp/select" |
| 405 |
sel_ala=$(grep s1 tmp/select | cut -f 2 -d ':' | sed 's/\ //g') |
| 406 |
res_ala=$(grep ALA tmp/restype | cut -f 2 -d ':' | sed 's/\ //g') |
| 407 |
if [ "$res_ala" != "$sel_ala" ]; |
| 408 |
then |
| 409 |
let errors=errors+1 |
| 410 |
echo "Error: --format=res and --select don't give same result for ALA ('$res_ala' and '$sel_ala')" |
| 411 |
fi |
| 412 |
sel_arg=$(grep s2 tmp/select | cut -f 2 -d ':' | sed 's/\ //g' | sed s/A2//) |
| 413 |
res_arg=$(grep ARG tmp/restype | cut -f 2 -d ':' | sed 's/\ //g' | sed s/A2// | sed s/ARG//) |
| 414 |
if [ "$res_arg" != "$sel_arg" ] |
| 415 |
then |
| 416 |
let errors=errors+1 |
| 417 |
echo "Error: --format=res and --select don't give same result for ARG ('$res_arg' and '$sel_arg')" |
| 418 |
fi |
| 419 |
sel_res1=$(grep s3 tmp/select | cut -f 2 -d ':' | sed 's/\ //g' | sed s/A2//) |
| 420 |
seq_res1=$(grep " 1 " tmp/seq | cut -f 2 -d ':' | cut -f 2 -d 'T' | sed 's/ //g') |
| 421 |
if [ "$seq_res1" != "$sel_res1" ] |
| 422 |
then |
| 423 |
let errors=errors+1 |
| 424 |
echo "Error: --format=seq and --select don't give same result for first residue in 1ubq.pdb ('$seq_res1' and '$sel_res1')" |
| 425 |
fi |
| 426 |
|
| 427 |
echo |
| 428 |
echo |
| 429 |
echo "== Testing multithreading ==" |
| 430 |
assert_pass "$cli -t 1 -S -n 10 < $smallpdb > $dump" |
| 431 |
assert_pass "$cli -t 2 -S -n 10 < $smallpdb > $dump" |
| 432 |
assert_pass "$cli -t 10 -S -n 10 < $smallpdb > $dump" |
| 433 |
assert_pass "$cli -t 1 -L -n 3 < $smallpdb > $dump" |
| 434 |
assert_pass "$cli -t 2 -L -n 3 < $smallpdb > $dump" |
| 435 |
assert_pass "$cli -t 10 -L -n 3 < $smallpdb > $dump" |
| 436 |
assert_fail "$cli -t 0 < $smallpdb > $dump" |
| 437 |
|
| 438 |
echo |
| 439 |
echo "== Testing input with residue insertions ===" |
| 440 |
assert_pass "test $($cli -n 2 --format=seq < $datadir/icode.pdb | grep ^SEQ | wc -l) -eq 5" |
| 441 |
|
| 442 |
echo |
| 443 |
echo "== Testing conflicting options ==" |
| 444 |
assert_fail "$cli -m -M $smallpdb > $dump" |
| 445 |
assert_fail "$cli -g A+B -C $smallpdb > $dump" |
| 446 |
assert_fail "$cli -c $sharedir/naccess.config --radii=naccess $smallpdb > $dump" |
| 447 |
assert_fail "$cli -O --radii=naccess $smallpdb > $dump" |
| 448 |
assert_fail "$cli -c $sharedir/naccess.config -O $datadir/1ubq.pdb > $dump" |
| 449 |
|
| 450 |
echo |
| 451 |
echo "== Testing long-options ==" |
| 452 |
assert_equal_opt "$cli $smallpdb" "-h" "--help" |
| 453 |
assert_equal_opt "$cli $smallpdb" "-v" "--version" |
| 454 |
assert_equal_opt "$cli $smallpdb" "-S -n 10" "--shrake-rupley -n 10" |
| 455 |
assert_equal_opt "$cli $smallpdb" "-L -n 3 " "--lee-richards -n 3 " |
| 456 |
assert_equal_opt "$cli $smallpdb" "-p 1.5 -n 3" "--probe-radius=1.5 -n 3" |
| 457 |
assert_equal_opt "$cli $smallpdb" "-L -n 3 " "-L --resolution=3 " |
| 458 |
assert_equal_opt "$cli $smallpdb" "-n 5" "--resolution=5" |
| 459 |
assert_equal_opt "$cli $smallpdb" "-t 4" "--n-threads=4" |
| 460 |
assert_equal_opt "$cli $smallpdb" "-c $sharedir/naccess.config" "--config-file=$sharedir/naccess.config" |
| 461 |
assert_equal_opt "$cli $smallpdb" "-H -w" "--hetatm -w" |
| 462 |
assert_equal_opt "$cli $datadir/1d3z.pdb" "-Y -n 2" "--hydrogen -n 2" |
| 463 |
assert_equal_opt "$cli $datadir/1d3z.pdb" "-m -n 2" "--join-models -n 2" |
| 464 |
assert_equal_opt "$cli $datadir/1d3z.pdb" "-C -n 2" "--separate-chains -n 2" |
| 465 |
assert_equal_opt "$cli $datadir/1d3z.pdb" "-M -n 2" "--separate-models -n 2" |
| 466 |
assert_equal_opt "$cli $smallpdb" "-w -n 2" "--no-warnings -n 2" |
| 467 |
assert_equal_opt "$cli $datadir/2jo4.pdb" "-g AB+CD -n 2" "--chain-groups AB+CD -n 2" |
| 468 |
assert_equal_opt "$cli $datadir/2jo4.pdb" "-g AB+CD -n 2" "-g AB -g CD -n 2" |
| 469 |
assert_equal_opt "$cli $datadir/1ubq.B.pdb" "-O -n 2" "--radius-from-occupancy -n 2" |
| 470 |
assert_equal_opt "$cli $smallpdb" "-f xml -n 2" "--format=xml -n 2" |
| 471 |
# deprecated, just check that the program doesn't choke |
| 472 |
assert_equal_opt "$cli $smallpdb" "-r -n 2" "--foreach-residue-type -n 2" |
| 473 |
assert_equal_opt "$cli $smallpdb" "-R -n 2" "--foreach-residue -n 2" |
| 474 |
assert_equal_opt "$cli $smallpdb" "-B -n 2" "--print-as-B-values -n 2" |
| 475 |
assert_equal_opt "$cli $smallpdb" "-l -n 2" "--no-log -n 2" |
| 476 |
|
| 477 |
rm -f tmp/* |
| 478 |
|
| 479 |
echo |
| 480 |
echo "There where $errors errors." |
| 481 |
echo |
| 482 |
if [ $errors -gt 0 ]; then |
| 483 |
exit $errors |
| 484 |
else |
| 485 |
exit 0 |
| 486 |
fi |