首页 > 编程语言 >python 中将单条scaffold的碱基序列按照指定数目输出

python 中将单条scaffold的碱基序列按照指定数目输出

时间:2022-11-04 10:11:22浏览次数:34  
标签:test3 python root scaffold pc1 fa file 单条 out

 

 

001\

[root@pc1 test3]# cat a.fa
>chr1
cccccggggggggttttgg
cccgggggg
>chr2
uuuuutttttNNNNNddffff
dddgggggggggggcccccccccc
[root@pc1 test3]# cat test.py
#!/usr/bin/python

in_file = open("a.fa", "r")
out_file = open("result.fa", "w")

tag = in_file.readlines()[0].strip()
print(tag, file = out_file)

step = 8
tail = ""

in_file = open("a.fa", "r")
for i in in_file:
        if not i.startswith(">"):
                i = i.strip()
                i = tail + i
                while len(i) >= step:
                        print(i[:step], file = out_file)
                        i = i[step::]
                tail = i

if len(tail) != 0:
        print(tail, file = out_file)

in_file.close()
out_file.close()

 

2\

[root@pc1 test3]# ls
a.fa  test.py
[root@pc1 test3]# python3 test.py
[root@pc1 test3]# ls
a.fa  result.fa  test.py
[root@pc1 test3]# cat result.fa
>chr1
cccccggg
gggggttt
tggcccgg
gggguuuu
utttttNN
NNNddfff
fdddgggg
gggggggc
cccccccc
c

 

标签:test3,python,root,scaffold,pc1,fa,file,单条,out
From: https://www.cnblogs.com/liujiaxin2018/p/16856777.html

相关文章

  • Python函数参数中的 : 以及 ->
    一些python函数中,参数后面有冒号,函数后面还有箭头,这是什么含义呢?函数参数中的冒号是参数的类型建议符,告诉函数调用者希望传入的实参的类型。函数后面跟着的箭头是函数返回......
  • ipython 的感叹号、问号的使用
    目录使用感叹号!运行Shell命令使用一个感叹号!运行赋值编码使用两个感叹号!!运行编码赋值注意使用问号?获取帮助使用一个问号?使用两个问号??使用*做模糊查询......
  • Python3爬虫豆瓣电影TOP250将电影名写入到EXCEL
    大家好,我是你们的老朋友泽哥,最近在学习Python3.6,于是兴起写了个小小的爬虫今天我们要爬取得页面是豆瓣电影TOP250,连接如下:​​http://movie.douban.com/top250?start=0&filt......
  • windows10安装dlib+python3.9
     1、whl安装注意,仅支持特定版本,请检查pip所支持的版本是否一致dlib-19.23.0-cp39-cp39-win_amd64.whlhttps://gitee.com/billyme/python-dlib/raw/master/dist/dlib-......
  • 3.9 使用Python操作Excel表格的样式1
    #获取表格单元格,修改字体样式修改字体样式 Font(name=字体名称,size=字体大小,bold=是否加粗,italic=是否斜体,color=字体颜色)获取表格中字体的样式cell.font.属性......
  • python 迭代器
    #迭代:当前执行依赖于上一次执行结果,可迭代对象内置了__iter__()方法的,就是可迭代对象基本数据类型中,属于可迭代对象的有:字典、列表、元组、集合、字符串、......
  • python描述 LeetCode 1486. 数组异或操作
    python描述LeetCode1486.数组异或操作  大家好,我是亓官劼(qíguānjié),在【亓官劼】公众号、GitHub、B站、华为开发者论坛等平台分享一些技术博文,主要包括前端开发、......
  • Python获取当前运行函数的名称、类方法名称
    获取函数的名称在函数外部获取函数的名称,可以使用.__name__来获取。deftest_func_name1(): print('test')func_name1=test_func_name1.__name__print(func_name1......
  • 用Docker搭建Python环境
    步骤1创建项目目录$cd/PATH/TO$mkdirpython-demo2下载python镜像1#下载镜像2dockerpullpython:3.834#查看镜像5dockerimages3创建pytho......
  • Python第九章实例
    01       02    03    04   ......