[Bioperl-l] Using a hash reference in the SeqFeature tag system

Leo, Paul (NIH/NHGRI) pleo at mail.nih.gov
Wed Jul 14 13:52:04 EDT 2004


 
Hi,
I want to add additional information of a $seq object using the tag system.
The tag value I want to add is a reference to a hash of hashes (though I
don't think it worked for just a hash either).
I thought that so long as the tag value was a scalar (i.e. a reference) then
all would be ok?
Perhaps I have done something silly ....and this is a simple perl
programming mistake... But have been staring at this for too long!
Can someone tell me why the example below fails? If so, any ideas on how to
add this hash structure to a $seq object ??
 
 

use Bio::DB::GenPept;
use Bio::SeqFeature::Generic;
use Bio::Seq;
use Bio::SeqIO;


######## make a hash of hashes ###########
$Data{cage1}{mouse1}{legs}=1;
$Data{cage1}{mouse1}{tails}=10;

$Data{cage1}{mouse2}{legs}=2;
$Data{cage1}{mouse2}{tails}=20;

$Data{cage2}{mouse1}{legs}=3;
$Data{cage2}{mouse1}{tails}=30;

$Data{cage2}{mouse2}{legs}=4;
$Data{cage2}{mouse2}{tails}=40;

print $Data{cage1}{mouse2}{legs}, "\n"; #just a check :gives "2"
print map "$_ ",keys(%{$Data{cage2}{mouse2}});  #just a check gives "legs
tails"
print "\n";
########################################

#### make a hash reference and put in into tag ###
$href=\%{$Data{cage1}{mouse1}}; #make ref here to a hash since used in tests
below
$seqextra=new Bio::SeqFeature::Generic ( -tag => {
                  experiment_id => 1,
                  Cage =>  $href     });
 
###############Sanity Checks...             
print "Ref ok : \n";                
print map "$_ ",keys(%{$href}); #prints "legs tails" as expected
print "\n";
 
print "Ref in a simple hash ok : \n";
$hashtest{zero}=$href;
print map "$_ ",keys(%{$hashtest{zero}}); #prints "legs tails" as expected
############ This fails....
print "\n";
print "Tag in not ? \n";      
print map "$_ ",keys(%{$seqextra->get_tag_values('Cage')}); #NOTHING!

Any suggestions?
Thanks in advance
Paul
 


More information about the Bioperl-l mailing list