[Bioperl-l] Bio::AlignIO::Pfam

James Thompson tex at biosysadmin.com
Sat Jun 5 14:11:50 EDT 2004


Tariq,

You want to use IO::String. Here's a quick example:

use IO::String;
use Bio::AlignIO;

my ($input, $output); # strings to hold results of AlignIO parsing
my $in_stringfh  = new IO::String($input);
my $out_stringfh = new IO::String($input);

my $in  = Bio::AlignIO->new(-fh => $in_stringfh,  -format => 'stockholm');
my $out = Bio::AlignIO->new(-fh => $out_stringfh, -format => 'pfam');


See section 2.4 of the FAQ for more information.

Tex Thompson





On Sat, 5 Jun 2004, Tariq Shafi wrote:

> Hello all
> 
> I am trying to submit a sequence in Perl to a pfam flat file database and 
> get a classification for the family that a peptide sequence belongs to, and 
> analysis of its domains.
> 
> I am thus using the Bio::AlignIO::Pfam module in Perl but all examples I can 
> find is taking input from a file. I want to (dynamically) create a Bio::Seq 
> object and use that as an argument in Bio::AlignIO::Pfam and get output as I 
> would do as if I submitted the sequence in the Pfam database website.
> 
> I am using CGI and dynamic web pages and want to avoid creating new files 
> when a Pfam alignment is requested as that will be a little messy and 
> expensive on memory.
> 
> The relevant chunk of my code so far for this is as below:
> 
> use CGI qw(:standard);
> use DBI;
> use Bio::AlignIO;
> 
> etc....
> 
> 
> # Using a statement handle in Perl DBI
> while ($sth->fetch())
> {
> 	print b("PAD ID: "), b($id), p(), b("Swiss-Prot ID: "), $swissProtId,br(), 
> b("Sequence:"),  br();
> 	   # Creating Bio::Seq object
>                    $seq = Bio::Seq->new(-seq => $sequence,
> 		     -desc => $swissProtId,
> 		     -id => $id
>                     );
> }
> 
> $sth->finish();
> 
> print b("Pfam classification:"), p();
> 
> # This is the problem area
> # I don't want files involved here. Instead of file and format I simply want 
> the argument to be a
> # Bio::Seq object
> 
> $in = Bio::AlignIO->new(
>         '-file' => $ARGV[0],
>         '-format' => 'stockholm' );
> 
> # Here I don't want files involved either. I want $out to be something 
> different but have nothing
> # to do with a file.
> 
> $out = Bio::AlignIO->new(
>         '-file' => ">$ARGV[1]",
>         '-format' => 'pfam');
> 
> $align = $in->next_aln();
> $out->write_aln($align);
> 
> Regards
> 
> Tariq
> 
> _________________________________________________________________
> It's fast, it's easy and it's free. Get MSN Messenger today! 
> http://www.msn.co.uk/messenger
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
> 




More information about the Bioperl-l mailing list