Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (28 sloc) 862 Bytes
from itertools import combinations
from numpy import unique
def splits(a,character):
left,right=[],[]
answer=[]
for i,x in enumerate(character):
if x=='0':
left.append(a[i])
elif x=='1':
right.append(a[i])
for t in combinations(left,2):
for u in combinations(right,2):
if t[0]<u[0]:
answer.append('{%s, %s} {%s, %s}'%(t[0],t[1],u[0],u[1]))
else:
answer.append('{%s, %s} {%s, %s}'%(u[0],u[1],t[0],t[1]))
return answer
with open("rosalind_qrt.txt","rU") as f:
taxa=f.readline().split()
xcharacters=f.readlines()
characters=map(lambda x: x.strip(),xcharacters)
final=[]
for z in characters:
a=splits(taxa,z)
final.extend(a)
with open('qrt.txt','w') as f:
for x in unique(final):
f.write(x+'\n')
You can’t perform that action at this time.