[Bioperl-l] Newbie: Format GenBank
    Chris Fields 
    cjfields at illinois.edu
       
    Wed Sep 23 17:47:51 UTC 2009
    
    
  
On Sep 23, 2009, at 9:38 AM, adlai burman wrote:
> I have finally got past two major hurdles (for me) only to get  
> stumped:
> 1. I have written a perl script that can take a genbank formated  
> text file as a filehandle and do all sorts of nifty (for me) things  
> with it.
> 2. I have gotten my BioPerl installation working on a web hosting  
> service so my advisor can use this through a browser.
>
> BUT the code I have to fetch GB record can print it as a single HTML  
> line, and what I need is for it to assign the retrieved file to a  
> scaler variable. I am going blind trying to figure out how access  
> (not write) the gb file from an SeqIO object and assign it to a  
> variable.
>
> Here's an example of the code I have going on the server:
>
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> use Bio::SeqIO;
> use Bio::DB::GenBank;
>
> $genBank = new Bio::DB::GenBank;  # This object knows how to talk to  
> GenBank
>
> my $seq = $genBank->get_Seq_by_acc('DQ897681');  # get a record by  
> accession
>
> my $seqOut = new Bio::SeqIO(-format => 'genbank');
>
> $seqOut->write_seq($seq);
>
> exit;
>
> where 'DQ897861' will be replaced by a CGI post.
>
> I know that write_seq is not what I need, and I assume that this is  
> a simple problem but can anyone tell me how to assign the retrieved  
> gb file to a scaler?
>
> Thanks,
> Adlai
Actually, there are two ways you can do this, one involving write_seq.
(1) The first is to just grab the raw data using Bio::DB::EUtilities:
use Bio::DB::EUtilities;
my $eutil = Bio::DB::EUtilities->new(-eutil     => 'efetch',
                                      -db        => 'nuccore',
                                      -id        => 'DQ897681',
                                      -rettype   => 'gb');
my $var = $eutil->get_Response->content;
(2) Use IO::String (see the SeqIO HOWTO), or Roy's example code.  That  
would 'filter' everything through SeqIO via next_seq/write_seq, so the  
output is what BioPerl spits out and may not be exactly the same.
chris
    
    
More information about the Bioperl-l
mailing list