好吧,我正在为学校做一个小项目,一个6帧的翻译。我不想谈太多细节,我只想描述一下我想补充的内容。
正常输出如下:TTCPTISPALGLAWS_DLGTLGFMSYSANTASGETLVSLYQLGLFEM_VVSYGRTKYYLICP_LFHLSVGFVPSD
这个字符串的重要部分是M和-uu(起始密码子和终止密码子,生物学的东西)。我想做的是这样强调:
^{pr2}$
这里是(对我来说)比较棘手的地方,我的输出是这样的(添加一个空格和一个来突出显示开始和结束)。但它只做一次,因为它发现的第一次启动和停止。如果有其他的M…..组合,它不会突出显示它们。在
以下是我当前的代码,试图使其高亮显示多次:def start_stop(translation):
index_2 = 0
while True:
if M in translation[index_2::1]:
index_1 = translation[index_2::1].find(M)
index_2 = translation[index_1::1].find(\_) + index_1
new_translation = translation[:index_1] + " \" + \
translation[index_1:index_2 + 1] + " " +\
translation[index_2 + 1:]
else:
break
return new_translation