Hi rambosauce and welcome to the monastery.
I'm a perl noviceI wouldn't have guessed that, your code is quite well written.
To answer your question, here is something you can do:
(Edit: untested for lack of input data)my %transcripts; { open(my $transcripts_fh, "<", $transcripts_qfn) or die("Can't open \"$transcripts_qfn\": $!\n"); while (<$transcripts_fh>) { chomp; my @refs = split(/\t/, $_); my ($ref_chr, $ref_strand) = @refs[0, 6]; $transcripts{$ref_chr}{$ref_strand} = {start => $refs[3], end => + $refs[4], info => $refs[8]}; } }
That's assuming that $ref_chr and $ref_strand are a unique pair. If you can have several start/end/info values for a given chr-strand pair, you'll have to use an intermediate array (I didn't want to give the more complex solution if the simple one is enough).my $transcript = $transcripts{$chr}{$strand}; my $start = $transcript->{start}; my $end = $transcript->{end}; my $info = $transcript->{info};
FYI, for debugging you can easer have something like:
oruse Data::Dump "pp"; ... say pp \%transcripts; # debug the content of %transcripts
The first looks nicer, but Data::Dumper doesn't require an installation.use Data::Dumper; ... say Dumper \%transcripts;
In reply to Re: How to make a hash to evaluate columns between large datasets
by Eily
in thread How to make a hash to evaluate columns between large datasets
by rambosauce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |