001、
root@PC1:/home/test# ls a.fasta test.py root@PC1:/home/test# cat test.py ## 测试程序 #!/usr/bin/python in_file = open("a.fasta", "r") dict1 = dict() for i in in_file: i = i.strip() if i[0] == ">": key = i dict1[key] = [] else: dict1[key].append(i.lower()) for i,j in dict1.items(): print(i) j = "".join(j) for k in range(0, len(j), 5): print(j[k:k+5]) in_file.close() root@PC1:/home/test# cat a.fasta ## 测试fasta文件 >gene1 myc AGCTGCCTAAGC GGCATAGCTAATCG >gene2 jun ACCGAATCGGAGCGATG GGCATTAAAGATCTAGCT >gene3 malat1 AGGCTAGCGAG GCGCGAG GATTAGGCG root@PC1:/home/test# python test.py ## 执行程序 >gene1 myc agctg cctaa gcggc atagc taatc g >gene2 jun accga atcgg agcga tgggc attaa agatc tagct >gene3 malat1 aggct agcga ggcgc gagga ttagg cg
参考:https://www.jianshu.com/p/5ee54bea4cb0
标签:dict1,小写字母,PC1,python,test,home,fasta From: https://www.cnblogs.com/liujiaxin2018/p/16589210.html