Created
March 4, 2012 03:26
-
-
Save indapa/1970441 to your computer and use it in GitHub Desktop.
Using itertools to count the number of possible genotypes given a certain ploidy
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
#!/usr/bin/env python | |
from itertools import * | |
#print the number of possible genotypes with various ploidies | |
ploidys=[2,3,4,5,6,7,8,9,10] | |
for p in ploidys: | |
print p, len([combo for combo in combinations_with_replacement(['A','C','G','T'],p) ]) | |
#output | |
#2 10 | |
#3 20 | |
#4 35 | |
#5 56 | |
#6 84 | |
#7 120 | |
#8 165 | |
#9 220 | |
#10 286 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment