python中提取原始序列名字第一个空格前的名字作为的序列名字,输出到屏幕
作者:互联网
001、
(base) root@PC1:/home/test2# ls a.fasta test.py (base) root@PC1:/home/test2# cat a.fasta ## 测试fasta文件 >gene1 myc AGCTGCCTAAGC GGCATAGCTAATCG >gene2 jun ACCGAATCGGAGCGATG GGCATTAAAGATCTAGCT >gene3 malat1 AGGCTAGCGAG GCGCGAG GATTAGGCG (base) root@PC1:/home/test2# cat test.py ## 测试程序 #!/usr/bin/python in_file = open("a.fasta", "r") for i in in_file: i = i.strip() if i.startswith(">"): print(i.split(" ")[0].split(">")[1]) else: print(i) (base) root@PC1:/home/test2# python test.py ## 运行程序 gene1 AGCTGCCTAAGC GGCATAGCTAATCG gene2 ACCGAATCGGAGCGATG GGCATTAAAGATCTAGCT gene3 AGGCTAGCGAG GCGCGAG GATTAGGCG
参考:https://www.jianshu.com/p/403a23fdd7bb
标签:test2,python,PC1,名字,base,序列,home,fasta,root 来源: https://www.cnblogs.com/liujiaxin2018/p/16583734.html