我试图运行我的代码,但错误被弹出。这是我的代码,谢谢! 我检查了每个return语句和缩进块。 这是我使用的呼叫命令: python3 generate_seqs.py -t -p -r -o
我将代码粘贴到这里:https://pastebin.com/q3R9wavL
'''python
#!/usr/bin/env python3
ERROR_GTR_PARAMS_FILE = "Invalid GTR parameters file"
ERROR_ROOT_SEQ = "Invalid root sequence. Must be path to FASTA file or integer"
from decimal import *
from math import log
from random import uniform
from numpy import matrix
from scipy.linalg import expm
try:
import Queue as Q # ver. < 3.0
except ImportError:
import queue as Q
import treeswift
def randomChoice(prob):
faces = sorted(die.keys())
probs = [die[key] for key in faces]
cdf = [probs[0]]
while len(cdf) < len(probs):
cdf.append(cdf[-1] + probs[len(cdf)])
num = uniform(0, 1)
index = 0
while cdf[index] < num:
index += 1
return faces[index]
是进化序列 ''' prob_A,prob_C,prob_G,prob_T = gtr_probs#如果方便的话可以使用这些 rate_CT,rate_AT,rate_GT,rate_AC,rate_CG,rate_AG = gtr_rates#如果方便的话可以使用它们 seqs = dict()#这将是您的输出(键=叶子标签(str)和值=序列(str)) #TODO您的代码在这里 rate_dict = {'AC':rate_AC, “ CT”:rate_CT, 'AT':rate_AT, 'GT':rate_GT, “ CG”:rate_CG, 'AG':rate_AG}
prob_dict = {'A': prob_A,
'C': prob_C,
'G': prob_G,
'T': prob_T}
R = gtr2matrix(rate_dict,prob_dict)
root = tree.seed_node
root.seq = root_seq
todo = Q.Queue()
for child in root.child_nodes():
todo.put(child)
while not todo.empty():
node = todo.get()
node.seq = evolveSeq(node.parent_node.seq, node.edge_length, R)
for child in node.child_nodes():
todo.put(child)
for leaf in tree.leaf_node_iter():
seqs[leaf.taxon.label] = leaf.seq
return seqs
'''python