001、
(base) [root@pc1 test1]# ls a.fa test.py (base) [root@pc1 test1]# cat a.fa ## 测试fasta >chr1 tttcccggg >chr2 tttgggjjj cccjjjjjj >chr3 ccc >chr4 aaaaatt (base) [root@pc1 test1]# cat test.py ## 程序 #!/usr/bin/env python3 # -*- coding: utf-8 -*- dict1 = dict() with open("a.fa", "r") as in_put: for i in in_put: i = i.strip() if i[0] == ">": key = i dict1[key] = "" else: dict1[key] += i in_put.close() for i,j in dict1.items(): print(i) for k in range(0, len(j), 5): print(j[k:k+5])
(base) [root@pc1 test1]# ls a.fa test.py (base) [root@pc1 test1]# python3 test.py ## 运算结果 >chr1 tttcc cggg >chr2 tttgg gjjjc ccjjj jjj >chr3 ccc >chr4 aaaaa tt
。
标签:test1,pc1,python,碱基,base,test,py,fasta,root From: https://www.cnblogs.com/liujiaxin2018/p/17763678.html