Skip to content
Permalink
6d5cc671f5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
52 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])