ncbi-genome-download批量下载基因组数据

2023-11-21 14:40

本文主要是介绍ncbi-genome-download批量下载基因组数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. ncbi-genome-download 的下载和安装

ncbi-genome-download 是一个可以直接从NCBI上批量下载序列的软件,支持下载多种格式

利用 conda 对其直接安装 参考

#创建环境
conda create -n ncbi_genome_download
#激活环境
conda activate ncbi_genome_download
# 安装
conda install -c bioconda ncbi-genome-download

2.常用的参数

  • -s:选择数据库(genbank,refseq),默认是refseq数据库
  • -F:需要下载基因组的格式,可以多种格式同时下载,用逗号隔开,默认是genbank格式
  • -l:序列组装程度,可以多种格式同时下载,用逗号隔开
  • -g:需要下载序列的属,后面要指定类群,比如bacteria
  • S:下载的具体的菌种名称,用逗号隔开,也可以写入一个文件中,一行一个菌种名称
  • -o:输出的文件名称
  • -r:失败时重新连接的次数,默认是0次
  • --flat-output:将下载的文件输入到一个目录中,不创建新的子文件(即下载的数据在指定的文件夹中,每个 Taxonomy ID 一个压缩文件)

参数详情:

(ncbi_genome_download) [hgzhong@head01 ~]$ ncbi-genome-download -h                                                               
usage: ncbi-genome-download [-h] [-s {refseq,genbank}] [-F FILE_FORMATS]                                                         [-l ASSEMBLY_LEVELS] [-g GENERA] [--genus GENERA]                                                    [--fuzzy-genus] [-S STRAINS] [-T SPECIES_TAXIDS]                                                     [-t TAXIDS] [-A ASSEMBLY_ACCESSIONS]                                                                 [--fuzzy-accessions] [-R REFSEQ_CATEGORIES]                                                          [--refseq-category REFSEQ_CATEGORIES] [-o OUTPUT]                                                    [--flat-output] [-H] [-P] [-u URI] [-p N] [-r N]                                                     [-m METADATA_TABLE] [-n] [-N] [-v] [-d] [-V]                                                         [-M TYPE_MATERIALS]                                                                                  groups                                                                                               positional arguments:                                                                                                            groups                The NCBI taxonomic groups to download (default: all).                                                    A comma-separated list of taxonomic groups is alsopossible. For example: "bacteria,viral"Choose from:['all', 'archaea', 'bacteria', 'fungi','invertebrate', 'metagenomes', 'plant', 'protozoa','vertebrate_mammalian', 'vertebrate_other', 'viral']optional arguments:-h, --help            show this help message and exit-s {refseq,genbank}, --section {refseq,genbank}NCBI section to download (default: refseq)-F FILE_FORMATS, --formats FILE_FORMATSWhich formats to download (default: genbank).A comma-separated list of formats is also possible. Forexample: "fasta,assembly-report". Choose from:['genbank', 'fasta', 'rm', 'features', 'gff','protein-fasta', 'genpept', 'wgs', 'cds-fasta', 'rna-fna', 'rna-fasta', 'assembly-report', 'assembly-stats', 'translated-cds', 'all']-l ASSEMBLY_LEVELS, --assembly-levels ASSEMBLY_LEVELSAssembly levels of genomes to download (default: all).A comma-separated list of assembly levels is alsopossible. For example: "complete,chromosome". Choosefrom: ['all', 'complete', 'chromosome', 'scaffold','contig']-g GENERA, --genera GENERAOnly download sequences of the provided genera. Acomma-seperated list of genera is also possible. Forexample: "Streptomyces coelicolor,Escherichia coli".(default: [])--genus GENERA        Deprecated alias of --genera--fuzzy-genus         Use a fuzzy search on the organism name instead of anexact match.-S STRAINS, --strains STRAINSOnly download sequences of the given strain(s). Acomma-separated list of strain names is possible, aswell as a path to a filename containing one name perline.-T SPECIES_TAXIDS, --species-taxids SPECIES_TAXIDSOnly download sequences of the provided species NCBItaxonomy IDs. A comma-separated list of species taxidsis also possible. For example: "52342,12325".(default: [])-t TAXIDS, --taxids TAXIDSOnly download sequences of the provided NCBI taxonomyIDs. A comma-separated list of taxids is alsopossible. For example: "9606,9685". (default: [])-A ASSEMBLY_ACCESSIONS, --assembly-accessions ASSEMBLY_ACCESSIONSOnly download sequences matching the provided NCBIassembly accession(s). A comma-separated list ofaccessions is possible, as well as a path to afilename containing one accession per line.--fuzzy-accessions    Use a fuzzy search on the entry accession instead ofan exact match.-R REFSEQ_CATEGORIES, --refseq-categories REFSEQ_CATEGORIESOnly download sequences of the provided refseqcategories [refrerence, representative, na]. A comma-separated list of categories is also possible.(default: download all categories)--refseq-category REFSEQ_CATEGORIESDeprecated alias for --refseq-categories-o OUTPUT, --output-folder OUTPUTCreate output hierarchy in specified folder (default:/data/home/hgzhong)--flat-output         Dump all files right into the output folder withoutcreating any subfolders.-H, --human-readable  Create links in human-readable hierarchy (might failon Windows)-P, --progress-bar    Create a progress bar for indicating the downloadprogress-u URI, --uri URI     NCBI base URI to use (default:https://ftp.ncbi.nih.gov/genomes)-p N, --parallel N    Run N downloads in parallel (default: 1)-r N, --retries N     Retry download N times when connection to NCBI fails(default: 0)-m METADATA_TABLE, --metadata-table METADATA_TABLESave tab-delimited file with genome metadata-n, --dry-run         Only check which files to download, don't downloadgenome files.-N, --no-cache        Don't cache the assembly summary file in/data/home/hgzhong/.cache/ncbi-genome-download.-v, --verbose         increase output verbosity-d, --debug           print debugging information-V, --version         print version information-M TYPE_MATERIALS, --type-materials TYPE_MATERIALSSpecifies the relation to type material for theassembly (default: any). "any" will include assemblieswith no relation to type material value defined, "all"will download only assemblies with a defined value. Acomma-separated list of relatons. For example:"reference,synonym". Choose from: ['any', 'all','type', 'reference', 'synonym', 'proxytype','neotype'] .

3. 批量下载基因组数据

3.1 根据属名下载

将需要下载的属名放置至一个txt文档(换行),利用参数--genera  pant_download.txt  plant

3.2 根据物种的 ID下载

将需要下载的物种的分类 ID 放置至一个txt文档(换行),利用参数--taxids my_taxids.txt 

再加上参数 --assembly-levels 指定下载的基因组的不同类型(包括contig,scaffold,chromosome,all,compete)

不同物种的 taxonomy id查询地址 taxonomy id query

例如 Oryza sativa 的 taxonomy id为4530

3.3 根据物种拉丁名下载

当你有一系列菌种需要下载时,你可以将这一系列菌种名保存到一个txt文件里,每个菌种名为一行,文件名为genera.txt

希望下载这些菌种基因组中的cds序列,并将下载的每个文件放在MyGenera文件夹中,在MyGenera目录下进入终端,运行:

ncbi-genome-download --genera genera.txt bacteria --flat-output --formats cds-fasta

然后,每个物种均会自动下载好指定的基因组类型序列

这样genera文本中的所有菌种的基因组cds序列就一条代码下载完成了。

注意:genera.txt文本中有10个菌种名,而下载了13个文件,说明有的菌种名下面有来自不同上传者提供的基因组信息(即一对多)

如下图,我要下载GCAlist.txt文本中的基因组序列的fasta文件,并保存在Assembly文件夹中,在Assembly目录下进入终端,运行:

ncbi-genome-download --assembly-accessions GCAlist.txt bacteria --section genbank --for

4.帮助查询

查询地址 帮助文档

  • 查看版本
ncbi-genome-download -V
  • 查看帮助
ncbi-genome-download -h
  • 语法格式
ncbi-genome-download [optional arguments] groups

optional arguments为可选参数,详细介绍见下文

groups为物种选择,可选['all', 'archaea', 'bacteria', 'fungi', 'invertebrate', 'metagenomes', 'plant', 'protozoa', 'vertebrate_mammalian', 'vertebrate_other', 'viral'],可选项即为NCBI的FTP下载目录Index of/genomes/refseq和Index of/genomes/genbank下的内容

  • 可选参数
--section

指定下载的数据库,可选['refseq', 'genbank'],默认refseq

--formats

指定下载的文件格式,可选['genbank', 'fasta', 'rm', 'features', 'gff', 'protein-fasta', 'genpept', 'wgs', 'cds-fasta', 'rna-fna', 'rna-fasta', 'assembly-report', 'assembly-stats', 'all'],默认genbank

--assembly-levels

指定下载的基因组组装水平,可选['all', 'complete', 'chromosome', 'scaffold', 'contig'],默认all

--genera

根据菌种名下载,后面可接想要下载的菌种名,如--genera 'Rhizobium alamii'

--taxids

根据NCBI taxonomy ID下载,后面可接想要下载的菌种的taxonomy ID,如--taxids '492774'

(还以Rhizobium alamii举例,通过NCBI Taxonomy Browser可以查询到该菌种的txid为492774)

--assembly-accessions

根据assembly accession下载,后面可接想要下载的菌种的assembly accession,如--assembly-accessions ‘GCF_000799895.1’

⚠️注意:因为默认下载的数据库是refseq,所以选择RefSeq assembly accession下载时无需加--section参数即可正常下载,如果要根据GenBank assembly accession下载,请再加上--section genbank。

--output-folder

指定下载目录,后面可接你想要存放的下载目录,如--output-folder ~/Downloads(下载到当前用户的下载文件夹中)

--flat-output

直接将下载的文件放入指定文件夹中,不创建子文件夹

详情参考 ncbi-genome-download工具

5. 核查下载情况

由于利用ncbi-genome-download下载物种的基因组数据时存在未成功下载(后续需自己手动下载)的情况,所有需要将当前目录下的a.genomic.fna.gz文件进行汇总

5.1 利用grep命令查找

随后将sequence_name.txt文件导入excel表中,与自己需要下载的物种进行vlookup函数匹配,找出未成功下载的基因组序列的物种名

grep ".*genomic.fna.gz” ./present dictionary > sequence_name.txt

5.2 将.txt文件转换成.bat文件

另一种方法,比较简单实用:

这篇关于ncbi-genome-download批量下载基因组数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/402994

相关文章

shell脚本批量导出redis key-value方式

《shell脚本批量导出rediskey-value方式》为避免keys全量扫描导致Redis卡顿,可先通过dump.rdb备份文件在本地恢复,再使用scan命令渐进导出key-value,通过CN... 目录1 背景2 详细步骤2.1 本地docker启动Redis2.2 shell批量导出脚本3 附录总

批量导入txt数据到的redis过程

《批量导入txt数据到的redis过程》用户通过将Redis命令逐行写入txt文件,利用管道模式运行客户端,成功执行批量删除以Product*匹配的Key操作,提高了数据清理效率... 目录批量导入txt数据到Redisjs把redis命令按一条 一行写到txt中管道命令运行redis客户端成功了批量删除k

SpringBoot多环境配置数据读取方式

《SpringBoot多环境配置数据读取方式》SpringBoot通过环境隔离机制,支持properties/yaml/yml多格式配置,结合@Value、Environment和@Configura... 目录一、多环境配置的核心思路二、3种配置文件格式详解2.1 properties格式(传统格式)1.

解决pandas无法读取csv文件数据的问题

《解决pandas无法读取csv文件数据的问题》本文讲述作者用Pandas读取CSV文件时因参数设置不当导致数据错位,通过调整delimiter和on_bad_lines参数最终解决问题,并强调正确参... 目录一、前言二、问题复现1. 问题2. 通过 on_bad_lines=‘warn’ 跳过异常数据3

Python实现批量提取BLF文件时间戳

《Python实现批量提取BLF文件时间戳》BLF(BinaryLoggingFormat)作为Vector公司推出的CAN总线数据记录格式,被广泛用于存储车辆通信数据,本文将使用Python轻松提取... 目录一、为什么需要批量处理 BLF 文件二、核心代码解析:从文件遍历到数据导出1. 环境准备与依赖库

C#监听txt文档获取新数据方式

《C#监听txt文档获取新数据方式》文章介绍通过监听txt文件获取最新数据,并实现开机自启动、禁用窗口关闭按钮、阻止Ctrl+C中断及防止程序退出等功能,代码整合于主函数中,供参考学习... 目录前言一、监听txt文档增加数据二、其他功能1. 设置开机自启动2. 禁止控制台窗口关闭按钮3. 阻止Ctrl +

java如何实现高并发场景下三级缓存的数据一致性

《java如何实现高并发场景下三级缓存的数据一致性》这篇文章主要为大家详细介绍了java如何实现高并发场景下三级缓存的数据一致性,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 下面代码是一个使用Java和Redisson实现的三级缓存服务,主要功能包括:1.缓存结构:本地缓存:使

在MySQL中实现冷热数据分离的方法及使用场景底层原理解析

《在MySQL中实现冷热数据分离的方法及使用场景底层原理解析》MySQL冷热数据分离通过分表/分区策略、数据归档和索引优化,将频繁访问的热数据与冷数据分开存储,提升查询效率并降低存储成本,适用于高并发... 目录实现冷热数据分离1. 分表策略2. 使用分区表3. 数据归档与迁移在mysql中实现冷热数据分

C#解析JSON数据全攻略指南

《C#解析JSON数据全攻略指南》这篇文章主要为大家详细介绍了使用C#解析JSON数据全攻略指南,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、为什么jsON是C#开发必修课?二、四步搞定网络JSON数据1. 获取数据 - HttpClient最佳实践2. 动态解析 - 快速

linux批量替换文件内容的实现方式

《linux批量替换文件内容的实现方式》本文总结了Linux中批量替换文件内容的几种方法,包括使用sed替换文件夹内所有文件、单个文件内容及逐行字符串,强调使用反引号和绝对路径,并分享个人经验供参考... 目录一、linux批量替换文件内容 二、替换文件内所有匹配的字符串 三、替换每一行中全部str1为st