小编dhi*_*v10的帖子

使用python查找频繁的字符串模式

所以我试图解决这个问题,我必须在python的某些行中找到最常用的6个字母的字符串,所以我意识到可以做这样的事情:

>>> from collections import Counter
>>> x = Counter("ACGTGCA")
>>> x
Counter({'A': 2, 'C': 2, 'G': 2, 'T': 1})
Run Code Online (Sandbox Code Playgroud)

现在,我使用的数据是DNA文件,文件的格式如下:

> name of the protein
ACGTGCA ... < more sequences> 
ACGTGCA ... < more sequences> 
ACGTGCA ... < more sequences> 
ACGTGCA ... < more sequences> 

> another protein 
AGTTTCAGGAC ... <more sequences>
AGTTTCAGGAC ... <more sequences>
AGTTTCAGGAC ... <more sequences>
AGTTTCAGGAC ... <more sequences>
Run Code Online (Sandbox Code Playgroud)

我们可以从一次运行一个蛋白质开始,但是如何修改上面的代码块来搜索最常见的6个字符的字符串模式?谢谢.

python string bioinformatics

9
推荐指数
1
解决办法
3017
查看次数

标签 统计

bioinformatics ×1

python ×1

string ×1