我一直在尝试反向补充fasta DNA序列。这是我的代码:
fastafile=open('sequence (3).fasta','r')
entries=[]
reverse=""
sequence=['A','T','G','C','N']
for line in fastafile:
if not line.startswith('>'):
line = line.split()
entries.append(line)
print entries
for index in range(0,len(entries[::-1])):
if index !=sequence:
print "this is not a valid nucleotide"
break
else:
if index=='A':
reverse+='T'
elif index=='T':
reverse+='A'
elif index=='C':
reverse+='G'
elif index=='G':
reverse+ 'C'
elif index=='N':
reverse+='N'
print reverse
每次我得到输出时,这不是一个有效的核苷酸,即使我的条目打印显示它有顺序的项目。这是我打印输入时的输出示例;
[['GCTCCCCTGAGGTTCGGCACCCACACTCCCTTCCCAGGAGCTCGCGATGCAAGAGCCACAGTCAGAGCTC'], ['AATATCGACCCCCCTCTGAGCCAGGAGACATTTTCAGAATTGTGGAACCTGCTTCCTGAAAACAATGTTC'], ['TGTCTTCGGAGCTGTGCCCAGCAGTGGATGAGCTGCTGCTCCCAGAGAGCGTCGTGAACTGGCTAGACGA']
我怎样才能解决这个问题?我只想补充一点,我大约 2 个月前才开始认真地使用 python 编程,所以我仍在学习和改进。谢谢!