hello,hello!小伙伴们大家好,我是小编豆豆,好久没有给大家分享使用的脚本了,最近小编在一直在忙着16s整理数据库,需要下载大量物种的16s rRNA序列。
提到下载生物序列,大家第一时间就会想到NCBI GeneBank数据库,虽然我们可以使用浏览器从GeneBank数据库上下载序列及其注释信息,但是效率低下,对于几条和十几条序列大多人还是可以接受的,一旦序列增至成百上千条,使用浏览器下载序列能把人逼疯
今天小编就把我最近下载序列时用到的python代码分享给大家,希望小伙伴能够提升科研效率,多发paper。
安装python模块
# 使用pip安装
pip install biopython
查看脚本帮助文档
python Download_genbank_file.py -h
usage: Download_genbank_file.py [-h] -a ACCESSION [-o OUT_DIR]
This script was used to download gb or fasta file of cp genome from NCBI nucleotides database
optional arguments:
-h, --help show this help message and exit
-a ACCESSION, --accession ACCESSION
file name contain accession number of cp genome you want to download
-o OUT_DIR, --out_dir OUT_DIR
Specifies the output directory where the downloaded file will be saved. [Default:./]
脚本参数说明
-a 输入序列登录号文件,如下图所示
-o 结果文件输出路径,如果路径不存在脚本会自动创建,此参数可以省略,如果省略,结果文件会保存在当前路径下
实战演练
python Download_genbank_file.py -a test1.txt -o res1
python Download_genbank_file.py -a test2.txt -o res2
脚本运行过程
脚本运行结果
结果解读
1.genbank_sequence.fasta文件为fasta序列文件,结果如图:
2.genbank_annotation.tsv文件为序列注释文件,结果如图所示:
3.download_erro_genbank_accession.tsv如果提供序列的登录号在GeneBank中没有,则将这个登录号输出到这个文件中,方便使用浏览器进行校验,如图所示: