[Bioperl-l] seq to fasta
Jason Stajich
jason at cgt.duhs.duke.edu
Sun May 23 19:21:16 EDT 2004
nope, $io is the handle, by doing ">$io" you're asking
for a filename called "$io" where $io will get dereferenced.
Do it like this:
my $io = IO::String->new();
my $out = Bio::SeqIO->new(-fh => $io,
-format => 'Fasta');
$out->write_seq($seq);
my $str = ${$io->string_ref};
-jason
On Mon, 24 May 2004, stephan rosecker wrote:
> Hi,
> thx Hilmar but no luck for me.
> I made somthing wrong...?
>
>
> sub test($)
> {
> use Bio::SeqIO;
> use IO::String;
> my $io = IO::String->new();
> my $out = Bio::SeqIO->new(-fh => ">$io",
> -format => 'Fasta');
> $out->write_seq($_);
> my $erg = $io;
> }
>
> result:
> Can't use string (">IO::String=GLOB(0x106c2018)") as a symbol ref while
> "strict refs" in use at
> /xprog/perl/perl-5.9.1_inst/lib/site_perl/5.9.1/IP27-irix/Bio/Root/IO.pm
> line 407.
>
> sorry... i'm a newbie -
>
> regards,
> stephan
>
>
>
>
> Hilmar Lapp wrote:
> > Use IO::String to create a stream that writes to a string, pass it to
> > SeqIO using -fh, call $out->write_seq($seq), and then print the string
> > used for creating the stream.
> >
> > -hilmar
> >
> > On Sunday, May 23, 2004, at 03:17 PM, stephan rosecker wrote:
> >
> >> Hi,
> >> is it possible to get the fasta format from a seqobject-sequence in a
> >> variable without using filhandles like below ?
> >>
> >> use Bio::SeqIO;
> >> $in = Bio::SeqIO->new(-file => "inputfilename",
> >> -format => 'EMBL');
> >> $out = Bio::SeqIO->new(-file => ">outputfilename",
> >> -format => 'Fasta');
> >> while ( my $seq = $in->next_seq() ) {$out->write_seq($seq); }
> >>
> >> e.g:
> >> I've a seqobject ($seq).
> >> and this is what i want:
> >>
> >> my $fastavar = $seq->seq_fastaformat();
> >> print $fastavar;
> >>
> >> result:
> >> >sp|P32234|128U_DROME GTP-binding protein 128UP - Drosophila
> >> melanogaster (Fruit fly).
> >> MITILEKISAIESEMARTQKNKATSAHLGLLKANVAKLRRELISPKGGGGGTGEAGFEVA
> >> KTGDARVGFVGFPSVGKSTLLSNLAGVYSEVAAYEFTTLTTVPGCIKYKGAKIQLLDLPG
> >> IIEGAKDGKGRGRQVIAVARTCNLIFMVLDCLKPLGHKKLLEHELEGFGIRLNKKPPNIY
> >> YKRKDKGGINLNSMVPQSELDTDLVKTILSEYKIHNADITLRYDATSDDLIDVIEGNRIY
> >> IPCIYLLNKIDQISIEELDVIYKIPHCVPISAHHHWNFDDLLELMWEYLRLQRIYTKPKG
> >> QLPDYNSPVVLHNERTSIEDFCNKLHRSIAKEFKYALVWGSSVKHQPQKVGIEHVLNDED
> >> VVQIVKKV
> >>
> >> regards,
> >> stephan
> >> _______________________________________________
> >> Bioperl-l mailing list
> >> Bioperl-l at portal.open-bio.org
> >> http://portal.open-bio.org/mailman/listinfo/bioperl-l
> >>
> >>
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu
More information about the Bioperl-l
mailing list