我有一个问题,我正在构建一个程序,我想识别两个列表的重叠序列。
序列_1 ='blablablaaaabla'
分隔符_2 ='aaablaccbla'
预期产出为:"啊啊啊"
我创建了这个函数来告诉我sequ_2中的序列是否与sequ_1重叠:
定义重叠(序列_1,序列_2):
count_overlapp = 0
count_nooverlapp = 0
for i in range(len(sequ_1)-len(sequ_2)+1):
if loci1[i:i+len(sequ_1)]==sequ_2:
count_overlapp= count_overlapp+1
else: count_nooverlapp = count_nooverlapp +1
return print(f'The number of overlapped sequence:{count_overlapp}\nThe number of not overlapped sequence:{count_nooverlapp}')`
但是,只有当sequ_2在sequ_1内时,它才计算良好,而如果sequ_2与sequ_1部分重叠,它就不能计算良好
最好的办法是找出重叠的序列
先谢谢你了
1条答案
按热度按时间osh3o9ms1#
也许这个解决方案是你需要的:
输出:aaabla