Hi Monks
I'm enjoying you wisdom for quite some time now
and first of all I wanted to thank you for making my life easier and me a better perl user!
Now I ran into a problem I just can't figure out and hope you can again share your wisdom with me.
In my current script I am building an IntervalTree with the
package Set::IntervalTree of a file containing genomic
coordinates together with some other info I want to retrieve for coordinate ranges.
This works just perfect and does what I need, but now I
would like to store the built tree to disk and retrieve
it later on so that I do not have to rebuild it every
time I search for coordinates.
I used Storable already in several scripts and thought it
would be a great idea to do so again, from what I have
read in your great Object Serialization Basics this looked very promising.
So I create a hash of trees for each chromosome that is
found in my input file like this
while (<FILE>){ my @line = split (/\t/,$_); ## tab separated file my @tmp = split(/\./,$line[1]); ## chromosome name in field 2, as +part of a dot separated string $chr{"$tmp[1]"} = new Set::IntervalTree() unless (defined $chr{"$ +tmp[1]"}); $chr{"$tmp[1]"} -> insert($count,$line[2]-1,$line[3]+1); ## fields + 3 and 4 contain the coordinates, -1 and +1 to allow search for direc +t overlaps at start and end }
store (\%chr, "$file.coordinates") or die "Can't store %chr in file.co +ordinates!\n";
my $hashref; %chr = %{$hashref = retrieve("$file.coordinates")};
In reply to Storing and retrieving a hash of objects by Frnak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |