首页 > 编程语言 >python 脚本统计fasta文件每条scaffold的碱基长度

python 脚本统计fasta文件每条scaffold的碱基长度

时间:2022-10-27 23:33:22浏览次数:44  
标签:dict1 key python scaffold pc1 file test fasta

 

001、

[root@pc1 test]# cat a.fa
>chr1
aatt
cc
>chr2
ttgg
ccgg
>chr3
aa
[root@pc1 test]# cat test.py
#!/usr/bin/python
in_file = open("a.fa", "r")
dict1 = dict()
for i in in_file:
        i = i.strip()
        if i.startswith(">"):
                key = i
                dict1[key] = ""
        else:
                dict1[key] += i
for i,j in dict1.items():
        print(i.strip(">"), len(j))
in_file.close()
[root@pc1 test]# python test.py
('chr1', 6)
('chr2', 8)
('chr3', 2)

 

标签:dict1,key,python,scaffold,pc1,file,test,fasta
From: https://www.cnblogs.com/liujiaxin2018/p/16834390.html

相关文章