[Bioperl-l] Newbie: Format GenBank
Roy Chaudhuri
roy.chaudhuri at gmail.com
Wed Sep 23 16:27:26 UTC 2009
Hi Adlai,
In Perl you can open a string as if it was a file:
my $string;
open my $fh, '>', \$string or die $!;
my $seqOut=Bio::SeqIO->new(-fh=>$fh, -format=>'genbank';
$seqOut->write_seq($seq) should now write to the string.
However, are you sure this is your problem? Printing to STDOUT (which is
what SeqIO does if you don't specify a file) should work fine with a CGI
script. Your sequence is being displayed as one line because HTML
ignores newline characters, but you can get around that by using a <pre>
tag to specify pre-formatted text:
my $seqOut = new Bio::SeqIO(-format => 'genbank');
print "<pre>\n";
$seqOut->write_seq($seq);
Hope this helps.
Roy.
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
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
More information about the Bioperl-l
mailing list