美文网首页
python从基因组注释文件中提取GO信息

python从基因组注释文件中提取GO信息

作者: wangsb_2020 | 来源:发表于2019-11-26 09:14 被阅读0次
问题

在转录组或基因组注释文件中有基因的GO注释,为了做GO富集分析,需要从中提取每个有GO注释的基因对应的GO号。
Interpro_output.gff3文件内容如下:

$ head CIA_Interpro_output.gff3 
##gff-version 3
##feature-ontology http://song.cvs.sourceforge.net/viewvc/song/ontology/sofa.obo?revision=1.269
##interproscan-version 5.35-74.0
##sequence-region CIA_ORF9411 1 466
CIA_ORF9411     .       polypeptide     1       466     .       +       .       ID=CIA_ORF9411;md5=2f764379a092e5b22282e2c0f506f89f
CIA_ORF9411     Pfam    protein_match   41      133     1.1E-20 +       .       date=17-11-2019;Target=CIA_ORF9411 41 133;ID=match$1_41_133;signature_desc=Domain associated at C-terminal with AAA;Name=PF14363;status=T;Dbxref="InterPro:IPR025753","KEGG:00230+3.6.1.3"
CIA_ORF9411     Gene3D  protein_match   211     401     2.7E-44 +       .       date=17-11-2019;Target=CIA_ORF9411 211 401;ID=match$2_211_401;Name=G3DSA:3.40.50.300;status=T
CIA_ORF9411     Pfam    protein_match   262     400     7.7E-17 +       .       date=17-11-2019;Target=CIA_ORF9411 262 400;Ontology_term="GO:0005524";ID=match$3_262_400;signature_desc=ATPase family associated with various cellular activities (AAA);Name=PF00004;status=T;Dbxref="InterPro:IPR003959"
CIA_ORF9411     SUPERFAMILY     protein_match   164     444     3.18E-49        +       .       date=17-11-2019;Target=CIA_ORF9411 164 444;ID=match$4_164_444;Name=SSF52540;status=T;Dbxref="InterPro:IPR027417"
CIA_ORF9411     ProSitePatterns protein_match   371     389     .       +       .       date=17-11-2019;Target=CIA_ORF9411 371 389;Ontology_term="GO:0005524";ID=match$5_371_389;signature_desc=AAA-protein family signature.;Name=PS00674;status=T;Dbxref="InterPro:IPR003960"

想要获得这种格式的GO注释信息

$ head CIA_GO1.txt
CIA_ORF100395 GO:0016747
CIA_ORF100980 GO:0015267        GO:0016020      GO:0055085
CIA_ORF102278 GO:0005200        GO:0005525      GO:0005874      GO:0007017
CIA_ORF105663 GO:0003824        GO:0046872
CIA_ORF105663 GO:0004222        GO:0006508
CIA_ORF12198 GO:0005524 GO:0009058
CIA_ORF12200 GO:0005524 GO:0009058
CIA_ORF12201 GO:0005524 GO:0009058
CIA_ORF12202 GO:0005524 GO:0009058
CIA_ORF12203 GO:0005524 GO:0009058

或者这种格式的:

$ head CIA_GO2.txt
CIA_ORF100395 GO:0016747
CIA_ORF100980 GO:0015267
CIA_ORF100980 GO:0016020
CIA_ORF100980 GO:0055085
CIA_ORF105663 GO:0003824
CIA_ORF105663 GO:0004222
CIA_ORF105663 GO:0006508
CIA_ORF105663 GO:0046872
CIA_ORF12198 GO:0005524
CIA_ORF12198 GO:0009058
python代码实现
import re
import os
f = open('CIA_Interpro_output.gff3', 'r')
result1 = open('CIA_GO1.txt', 'w')
result2 = open('CIA_GO2.txt', 'w')
lines = f.readlines()
for line in lines:
    result = re.findall('GO:\d+', line)
    if result:
        print(line.split('\t')[0], "\t".join(result), file=result1)
        for GO in result:
            print(line.split('\t')[0], GO, file=result2)
#排序去重            
os.system('cat CIA_GO1.txt | sort | uniq > tmp ; mv tmp CIA_GO1.txt')        
os.system('cat CIA_GO2.txt | sort | uniq > tmp ; mv tmp CIA_GO2.txt')

Interpro_output.gff3文件下载

相关文章

  • python从基因组注释文件中提取GO信息

    问题 在转录组或基因组注释文件中有基因的GO注释,为了做GO富集分析,需要从中提取每个有GO注释的基因对应的GO号...

  • Python积累

    从基因组注释中提取转录因子 字符串find使用+异常值处理 今天又写了一个小脚本,从基因组的注释文件中筛选所有可能...

  • linux--碱基序列处理

    从基因注释文件提取基因信息Zea_mays.B73_RefGen_v4.42.gtf gtf格式的注释文件 提取...

  • Python3 提取CDS

    根据物种基因组和注释文件,可以编写脚本,提取特殊的序列结构,完成个性化的分析。本文利用Python3提取拟南芥的最...

  • 使用TBtools提取基因组CDS并转换成蛋白文件

    基因功能注释需要蛋白文件,有时候注释或下载的基因组没有蛋白文件,需提取并转换,据师兄师弟说gffread提取结...

  • 使用bioawk对fasta文件进行序列分析

    最近在做水稻基因组注释,对于注释结果进行整理过滤,还在探索中。 evm注释结果 将结果转化成蛋白文件: 提取长度大...

  • 3.6. 生成代码文档

    go doc工具会从 Go 程序和包文件中提取顶级声明的首行注释以及每个对象的相关注释,并生成相关文档。 用法 g...

  • GTF 文件

    GFF和GTF是两种最常用的基因组注释格式,在信息分析中建库时除了需要fasta文件一般还会需要这两种文件,提取需...

  • 使用TBtools对叶绿体蛋白编码基因进行GO注释

    第一步:根据叶绿体基因组的genbank注释文件获得蛋白编码基因序列 提取序列的python脚本 使用方法pyth...

  • 基因组||基因组分析之鉴定基因类型

    基因类型的鉴定 基因组组装和注释完成,得到配套的基因组和注释文件之后,可以利用gffread提取对应的gene,c...

网友评论

      本文标题:python从基因组注释文件中提取GO信息

      本文链接:https://www.haomeiwen.com/subject/aqzswctx.html