Skip to content

Instantly share code, notes, and snippets.

@indapa
Created March 4, 2012 03:26
Show Gist options
  • Save indapa/1970441 to your computer and use it in GitHub Desktop.
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
#!/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