diff --git a/tests/functional/tree/cram/generate-fasta.py b/tests/functional/tree/cram/generate-fasta.py new file mode 100644 index 000000000..8c3a3d055 --- /dev/null +++ b/tests/functional/tree/cram/generate-fasta.py @@ -0,0 +1,28 @@ +import random + +def get_random_unicode(length): + """Adapted from """ + + try: + get_char = unichr + except NameError: + get_char = chr + + # code point ranges to be sampled + include_ranges = [ + # ASCII non-control characters excluding single quote (0x27) and backslash (0x5c) + (0x20, 0x26), (0x28, 0x5b), (0x5d, 0x7e) + ] + + alphabet = [ + get_char(code_point) for current_range in include_ranges + for code_point in range(current_range[0], current_range[1] + 1) + ] + return ''.join(random.choice(alphabet) for _ in range(length)) + + +if __name__ == "__main__": + for i in range(10): + print('>' + get_random_unicode(5)) + print("ATGC") + diff --git a/tests/functional/tree/cram/iqtree-name-modifications.t b/tests/functional/tree/cram/iqtree-name-modifications.t index e86c9d6ae..41191caf6 100644 --- a/tests/functional/tree/cram/iqtree-name-modifications.t +++ b/tests/functional/tree/cram/iqtree-name-modifications.t @@ -84,3 +84,21 @@ similar to single quotes. Invalid characters: .* (re) [2] + +This test generates random ASCII names. It's disabled for CI as it's both +stochastic and slow but you can easily toggle it back on (by uncommenting the +function call) if you want to better test strain name handling in `augur tree` + + $ random_ascii_names() { + > python3 "$TESTDIR"/generate-fasta.py > random_${1}.mfa + > + > ${AUGUR} tree \ + > --method iqtree \ + > --alignment random_${1}.mfa \ + > --output random_${1}.new > /dev/null + > } + + $ for iteration in $(seq 1 100); do + > # random_ascii_names $iteration + > : + > done \ No newline at end of file