Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (39 sloc) 1.16 KB
from nwck_class_3 import Newick_Tree
from collections import defaultdict
from my_iterators import Tree
from parsimony_class import Parsimony
sequences=dict()
with open("Lewis/angio35Sequences6.txt","rU") as f:
for line in f:
taxon,sequence=line.split()
sequences[taxon]=sequence
bad=[]
for x in sequences.keys():
for i,y in enumerate(sequences[x]):
if y.upper() not in ['C','A','G','T'] and i not in bad:
bad.append(i)
#good=[]
#
#k=sequences.keys()[0]
#t=sequences[k]
#for i in range(len(t)):
# for u in sequences.keys():
# if sequences[u][i]!=t[i]:
# good.append(i)
for x in sequences.keys():
fixed=''
for i,y in enumerate(sequences[x]):
if i not in bad:
fixed+=y.upper()
sequences[x]=fixed
spectrum=[]
taxa=sequences.keys()
N=min([len(x) for x in sequences.values()])
for x in Tree(taxa):
m=Parsimony(Newick_Tree(x),sequences,['A','C','G','T'],N)
print x,m.score()
spectrum.append(m.score())
print sorted(spectrum)
#x=z[1:]
#for t in trees(x):
# print '(%s)%s;'%(lists_to_newick(t),z[0])
You can’t perform that action at this time.