|Perl Monk, Perl Meditation|
Re: Using hash keys to separate databy wfsp (Abbot)
|on Jun 29, 2011 at 06:04 UTC||Need Help??|
Nearly there. :-)
The first while loop creates a lookup table (%Chr). The source file only has 1 field per record so there is no need for the split.
The second while loop creates a hash of arrays (%R) from your input file. The key is the first field (chromosome) and the value is an array of records. That's what the push is doing.
Finaly we print the records for each chromosome if it exists in the lookup table. In your case you want to print to a file rather than STDOUT as we do here.
As an aside, you could rewrite the first while loop with map.
Hope that helps.
hashKey.txt gives a list of all the possible chromosome values there could be in a given input file.If that is the case why do you need the lookup table? I could see it being useful if there could be values in your input that you weren't interested in.