# # MoleCuilder - creates and alters molecular systems # Copyright (C) 2020 Frederik Heber # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ### 7. select atom by random AT_SETUP([Selection - select atoms randomly]) AT_KEYWORDS([selection random atom select-atom-by-random]) # go through all possible counts (1-8) and removed i=1 while test $i -lt 8; do file=count${i}_missing.xyz AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByRandom/pre/test.xyz $file]) AT_CHECK([chmod u+w $file], 0) AT_CHECK([../../molecuilder --dry-run -i $file -v 3 --select-atom-by-random $i -r --no-dry-run --store-session session-selection-select-atom-by-random.py --session-type python], 0[], [ignore], [ignore]) AT_CHECK([grep -v "Command.*DryRun" session-selection-select-atom-by-random.py >session-selection-select-atom-by-random_new.py], 0, [ignore], [ignore]) AT_CHECK([../../molecuilderguitest session-selection-select-atom-by-random_new.py], [], [ignore], [ignore]) let remain=8-$i AT_CHECK([grep -c "^H" $file | grep -q $remain], 0, [ignore], [ignore]) ((i+=1)) done AT_CLEANUP AT_SETUP([Selection - select atoms randomly fails when atoms absent]) AT_KEYWORDS([selection random atom select-atom-by-random]) AT_CHECK([../../molecuilder --dry-run -i empty.xyz -v 3 --select-atom-by-random 1 --no-dry-run --store-session session-selection-select-atom-by-random.py --session-type python], 0, [ignore], [ignore]) AT_CHECK([grep -v "Command.*DryRun" session-selection-select-atom-by-random.py >session-selection-select-atom-by-random_new.py], 0, [ignore], [ignore]) AT_CHECK([../../molecuilderguitest session-selection-select-atom-by-random_new.py], 5, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Selection - select all atoms randomly]) AT_KEYWORDS([selection random atom select-atom-by-random]) file=test_all.xyz AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByRandom/pre/test.xyz $file]) AT_CHECK([chmod u+w $file], 0) AT_CHECK([../../molecuilder --dry-run -i $file -v 3 --select-atom-by-random 8 -r --no-dry-run --store-session session-selection-select-atom-by-random.py --session-type python], 0[], [ignore], [ignore]) AT_CHECK([grep -v "Command.*DryRun" session-selection-select-atom-by-random.py >session-selection-select-atom-by-random_new.py], 0, [ignore], [ignore]) AT_CHECK([../../molecuilderguitest session-selection-select-atom-by-random_new.py], [], [ignore], [ignore]) AT_CHECK([grep -q "^H" $file], 1, [ignore], [ignore]) AT_CLEANUP