我如何下载只有登录号的整个GenBank文件? [英] How can I download the entire GenBank file with just an accession number?

查看:179
本文介绍了我如何下载只有登录号的整个GenBank文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的登录号数组,我想知道是否有一种方法可以使用BioPerl自动保存genbank文件.我知道您可以获取序列信息,但是我想要整个GenBank记录.

I've got an array full of accession numbers, and I'm wondering if there's a way to automatically save genbank files using BioPerl. I know you can grab sequence information, but I want the entire GenBank record.

#!/usr/bin/env perl
use strict;
use warnings;
use Bio::DB::GenBank;

my @accession;
open (REFINED, "./refine.txt") || die "Could not open: $!";

while(<REFINED>){
    if(/^(\D+)\|(.*?)\|/){
    push(@accession, $2);
    }
}
close REFINED;
foreach my $number(@accession){

    my $db_obj = Bio::DB::GenBank->new;
    }

推荐答案

您可以使用Bio::DB::EUtilities保存完整的genbank记录.这是一个示例,该示例将获取ID列表,并将每个genbank记录保存在名为 myseqs.gb 的文件中:

You can save the full genbank records by using Bio::DB::EUtilities. Here is an example that will take a list of IDs and save genbank records for each in a file called myseqs.gb:

#!/usr/bin/env perl

use strict;
use warnings;
use Bio::DB::EUtilities;

my @ids = qw(1621261 89318838 68536103 20807972 730439);

my $factory = Bio::DB::EUtilities->new(-eutil   => 'efetch',
                                       -db      => 'protein',
                                       -rettype => 'gb',
                                       -email   => 'mymail@foo.bar',
                                       -id      => \@ids);

my $file = 'myseqs.gb';

# dump HTTP::Response content to a file (not retained in memory)
$factory->get_Response(-file => $file);

如果要拆分返回的单个记录而不是将它们全部保存在一个文件中,则可以使用Bio::SeqIO轻松完成.查看 EUtilities HOWTO

If you want to split the individual records returned instead of having them all in one file, this can easily be done with Bio::SeqIO. Check out the EUtilities HOWTO and the EUtilities Cookbook for more examples and explanation.

这篇关于我如何下载只有登录号的整个GenBank文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆