-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tree] random ascii strain name testing
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`
- Loading branch information
1 parent
1283f64
commit c3390c4
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import random | ||
|
||
def get_random_unicode(length): | ||
"""Adapted from <https://stackoverflow.com/a/21666621>""" | ||
|
||
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") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters