Created
December 5, 2013 20:35
-
-
Save cwidmer/7813411 to your computer and use it in GitHub Desktop.
generates a random sequence of length over alphabet
This file contains hidden or 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
| def rand_seq(alphabet, length): | |
| """ | |
| generates a random sequence of length over alphabet | |
| @param alphabet: alphabet from which to choose characters | |
| @type alphabet: list<str> | |
| @param length: length of random string | |
| @type length: int | |
| """ | |
| for c in alphabet: | |
| if len(c)>1: | |
| print "warning: individual tokens of length > 1: " + c | |
| seq = "".join([random.choice(alphabet) for j in range(length)]) | |
| return seq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment