python实现fasta文件碱基序列每行按照指定数目输出
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
。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2022-10-14 configure: error: htscodecs submodule files not present.
2022-10-14 centos中 在线安装 libz
2022-10-14 slurm、docker
2022-10-14 centos7 中 升级cmake
2022-10-14 linux 中如何统计每一行所占的字符长度
2022-10-14 centos7 中manta软件的安装
2020-10-14 linux系统中case命令的用法