Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中获得序列的反向补码_Python - Fatal编程技术网

如何在python中获得序列的反向补码

如何在python中获得序列的反向补码,python,Python,我试图构造一个程序,它反转输入的序列,然后要求用户输入另一个序列,直到用户输入一个不包含a、T、G、C的序列并提供错误消息为止。下面的代码给出了相反的补码,但不会提示用户输入另一个序列,任何建议都会有所帮助 这是我的密码: def revcomp(s, reverse, complement): bases = 'ATGCTACG' complement_dict = {bases[i]:bases[i+4] for i in range(4)} if reverse:

我试图构造一个程序,它反转输入的序列,然后要求用户输入另一个序列,直到用户输入一个不包含a、T、G、C的序列并提供错误消息为止。下面的代码给出了相反的补码,但不会提示用户输入另一个序列,任何建议都会有所帮助

这是我的密码:

def revcomp(s, reverse, complement):
    bases = 'ATGCTACG'
    complement_dict = {bases[i]:bases[i+4] for i in range(4)}
    if reverse:
       dna = reversed(dna)
       result_as_list = None
    if complement:
       result_as_list = [complement_dict[base] for base in dna]
    else:
       result_as_list = [base for base in dna]
       return ''.join(result_as_list)

s = input("enter sequence")
variable = revcomp(s, reverse, complement)
print("Reverse comp", variable)

您没有定义反向补码。您也从不使用
输入的
序列
变量
Python是缩进敏感的。请缩进您提供的代码以匹配编辑器中的代码。您的意思是
def revcomp(dna,反向,补码):
?是的,def revcomp(dna,反向,补码):您没有定义反向补码。您也从不使用
输入的
序列
变量
Python是缩进敏感的。请缩进您提供的代码以匹配编辑器中的代码。您的意思是
def revcomp(dna,reverse,complete):
?是的,def revcomp(dna,reverse,complete):