我正在用 Python 做作业。我必须找到一个函数或程序将这个列表转换为相应的 DNA 序列。
bases_list = ['Adenosine', 'Guanine', 'Thymine', 'Cytosine', 'Thymine', 'Adenosine', 'Guanine', 'Cytosine', 'Thymine', 'Adenosine', 'Guanine']
print(dna)
AGTCTAGCTAG #the output
我想也许我可以做一个定义函数来将这些碱基转换为相应的字母。我怎样才能做到这一点?有任何想法吗?
PS:最近才开始学python,希望大家多多帮助:)
最佳答案
是的,有几个!正如您不久前开始的那样,让我们做一些简单的事情:
bases_list = ['Adenosine', 'Guanine', 'Thymine', 'Cytosine', 'Thymine', 'Adenosine', 'Guanine', 'Cytosine', 'Thymine', 'Adenosine', 'Guanine']
dna = "" # You begin with the dna empty
for sequence in bases_list: # you go throw every chain
dna += sequence[0] # you add the first letter with the op [0] of lists
print(dna) # finally print
你可以在这里阅读循环的基础 https://wiki.python.org/moin/ForLoop
关于python - 将核苷酸转换为相应的 DNA 序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47036012/