1

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;
    }
4

1 回答 1

4

您可以使用 保存完整的 genbank 记录Bio::DB::EUtilities。这是一个示例,它将获取 ID 列表并将每个 ID 的 genbank 记录保存在名为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 HOWTOEUtilities Cookbook以获得更多示例和解释。

于 2013-05-06T17:42:48.563 回答