[Bioperl-l] Question on BioPerl modules

Jason Stajich jason at bioperl.org
Sat Oct 23 15:33:49 UTC 2010


Lincoln overloaded the "" method for the objects that are returned from 
Bio::DB::Fasta so that attempts to print them directly will instead 
print out the display_id field.

If you want to know what kind of object you getting back you use 'ref', 
as in:
print ref($seq),"\n";

Tao Zhu wrote, On 10/23/10 5:53 AM:
> Dear Professor Stajich,
>
> Recently I was puzzled when using two BioPerl modules, Bio::Index::Fasta
> and Bio::DB::Fasta;
>
> For example, I have a fasta file: sequence.fa, on my computer. That is:
>
>> ORFN:87
> ATGGAAGCCCCTTCAGAAATTACCGATTCCAA
>
> I hope to make a local index, then I use Bio::Index::Fasta and write:
>
> use Bio::Index::Fasta;
> $file_name = "sequence.fa";
> $id = "ORFN:87";
> $inx = Bio::Index::Fasta->new (-filename =>  $file_name . ".idx", -write_flag =>  1);
> $inx->make_index($file_name);
> $seq_obj = $inx->fetch($id);
> print "$seq_obj\n";
>
> Running the perl script, it prints "Bio::Seq=HASH(0x66590a0)" on screen.
> That means the scalar "$seq_obj" is a Bio::Seq object.
>
> However, I try another method, using Bio::DB::Fasta,
>
> use Bio::DB::Fasta;
> ($file,$id) = ("sequence.fa","ORFN:87");
> $db = Bio::DB::Fasta->new($file);
> $seq_obj = $db->get_Seq_by_id($id);
> print "$seq_obj\n";
>
> I expect it should also print "Bio::Seq=HASH(sth)",because I also get a
> Bio::Seq object. Surprisingly it prints "ORFN:87"
>
> How it comes to be?
>

-- 
Jason Stajich
jason at bioperl.org




More information about the Bioperl-l mailing list