前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >脚本分享—将GenBank格式的文件转换为GFF3格式

脚本分享—将GenBank格式的文件转换为GFF3格式

作者头像
用户1075469
发布2024-01-26 19:48:34
1920
发布2024-01-26 19:48:34
举报
文章被收录于专栏:科技记者科技记者

小编欢乐豆又放出一个珍藏多年的脚本,2749 行的长度,长到已经难以用 GPT 解读啦,不过用起来还是很方便的!这个 perl 脚本用于将 GenBank 格式的文件转换为 GFF3 格式。

脚本使用准备

perl 是前提啦,当然,如果用 Linux,有自带的,就不需要再安装啦!推荐使用windows10/11的 WSL2。以下是我的依赖安装记录:

代码语言:javascript
复制
# 修改 cpan镜像地址:
vi  ~/.cpan/CPAN/MyConfig.pm

# 不习惯vi的话gedit也可以的,前提是安装了的 gedit ~/.cpan/CPAN/MyConfig.pm
# 这一行修改为中科大的源,这样就能节省很多模块的下载时间啦
  'urllist' => [q[http://mirrors.ustc.edu.cn/CPAN/]],
cpan
# 安装 Bioperl
install  Bio::Root::RootI # 敲上几个回车就解决啦!

参数和用法

以下是脚本的一些主要选项和用法:

代码语言:javascript
复制
 perl Genbank_to_gff3.pl -h
Usage:
      Genbank_to_gff3.pl [options] filename(s)

      # process a directory containing GenBank flatfiles
      perl Genbank_to_gff3.pl --dir path_to_files --zip

      # process a single file, ignore explicit exons and introns
      perl Genbank_to_gff3.pl --filter exon --filter intron file.gbk.gz

      # process a list of files
      perl Genbank_to_gff3.pl *gbk.gz

      # process data from URL, with Chado GFF model (-noCDS), and pipe to database loader
      curl ftp://ftp.ncbi.nih.gov/genomes/Saccharomyces_cerevisiae/CHR_X/NC_001142.gbk \
      | perl Genbank_to_gff3.pl -noCDS -in stdin -out stdout \

        Options:
            --noinfer  -r  don't infer exon/mRNA subfeatures
            --conf     -i  path to the curation configuration file that contains user preferences
                           for Genbank entries (must be YAML format)
                           (if --manual is passed without --ini, user will be prompted to
                            create the file if any manual input is saved)
            --sofile  -l  path to to the so.obo file to use for feature type mapping
                           (--sofile live will download the latest online revision)
            --manual   -m  when trying to guess the proper SO term, if more than
                           one option matches the primary tag, the converter will
                           wait for user input to choose the correct one
                           (only works with --sofile)
            --dir      -d  path to a list of genbank flatfiles
            --outdir   -o  location to write GFF files (can be 'stdout' or '-' for pipe)
            --zip      -z  compress GFF3 output files with gzip
            --summary  -s  print a summary of the features in each contig
            --filter   -x  genbank feature type(s) to ignore
            --split    -y  split output to separate GFF and fasta files for
                           each genbank record
            --nolump   -n  separate file for each reference sequence
                           (default is to lump all records together into one
                           output file for each input file)
            --ethresh  -e  error threshold for unflattener
                           set this high (>2) to ignore all unflattener errors
            --[no]CDS  -c  Keep CDS-exons, or convert to alternate gene-RNA-protein-exon
                           model. --CDS is default. Use --CDS to keep default GFF gene model,
                           use --noCDS to convert to g-r-p-e.
            --format   -f  Input format (SeqIO types): GenBank, Swiss or Uniprot, EMBL work
                           (GenBank is default)
            --GFF_VERSION  3 is default, 2 and 2.5 and other Bio::Tools::GFF versions available
            --quiet        don't talk about what is being processed
            --typesource   SO sequence type for source (e.g. chromosome; region; contig)
            --help     -h  display this message

显然也难以使用 GPT 进行改写啦,一般的大模型都 hold 不住这么长的输入吧!没关系,我们先用起来试试!随便从 ncbi 上下载一个 gbk 序列测试下,比如这条:ftp://ftp.ncbi.nih.gov/genomes/Saccharomyces_cerevisiae/CHR_X/NC_001142.gbk

代码语言:javascript
复制
perl Genbank_to_gff3.pl --dir ./
# Input: .//E_coli.gbk
# working on region:NZ_KE701390, Escherichia coli KOEGE 71 (186a), Escherichia coli KOEGE 71 (186a) acYxK-supercont1.9, whole genome shotgun sequence., 23-JUN-2023
# GFF3 saved to ./E_coli.gbk.gff

GBK格式,从ncbi网页上下载下来的.gb后辍的,一样可以分析的,看下下是用的正则表达式匹配的:

gbk格式:

转换好的GFF3格式:

代码语言:javascript
复制
head E_coli.gbk.gff less -S

怎么样,有没有用,要不要收藏或者用起来呀? 如果在学习过程中有什么疑问欢迎大家留言讨论。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-01-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 微因 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 脚本使用准备
  • 参数和用法
相关产品与服务
腾讯云服务器利旧
云服务器(Cloud Virtual Machine,CVM)提供安全可靠的弹性计算服务。 您可以实时扩展或缩减计算资源,适应变化的业务需求,并只需按实际使用的资源计费。使用 CVM 可以极大降低您的软硬件采购成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档