mashengwei的个人博客分享 http://blog.sciencenet.cn/u/mashengwei

博文

统计序列中的gap位置和大小

已有 8299 次阅读 2018-8-3 15:34 |系统分类:科研笔记| python, genome, wheat, gap

支持python3,可用来统计基因组上的gap位置,gap大小。输出格式是gff3。当然根据需要修改print那一行可以输出bed等格式

使用格式如下:

python3 getgaps.py genome.fasta > gaps.gff3


#!/usr/bin/env python3

# this code was changed based on biostar "https://www.biostars.org/p/152592/"
# Import necessary packages
import argparse
import re
from Bio import SeqIO

# Parse command-line arguments
parser = argparse.ArgumentParser()
parser.add_argument("fasta")
args = parser.parse_args()

# Open FASTA, search for masked regions, print in GFF3 format
with open(args.fasta) as handle:
    i = 0
    for record in SeqIO.parse(handle, "fasta"):
        for match in re.finditer('N+', str(record.seq)):
            i = i+1
            print (record.id, ".""gap", match.start() + 1, match.end(), ".""."".""Name=gap" + str(i) + ";size=" + str(match.end()-match.start()), sep='\t')

#use the following at CMD: FILENAME.py FILENAME.fasta >> FILENAME.gff3  here




https://blog.sciencenet.cn/blog-1094241-1127394.html

上一篇:获取目标染色体区间内的基因和候选基因的筛选策略
下一篇:小麦单基因分析
收藏 IP: 58.213.93.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-25 19:50

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部