|Pathologically Eclectic Rubbish Lister|
search and extract from a large hashby reubs85 (Acolyte)
|on Jun 07, 2011 at 10:54 UTC||Need Help??|
reubs85 has asked for the
wisdom of the Perl Monks concerning the following question:
Hello Monks, may I request your consummate wisdom on a wee question I have?
I have a hash, where the key is a unique ID tag and the value is the genetic data for the gene corresponding to that ID. In the kinds of analyses I do I am generally dealing with relatively large hashes, maybe ~15000 key/value pairs kinda thing. I want to extract the sequence information for a given subset of genes for which I have the ID's stored in an array. I can do it with the following code, which works pretty well (it uses a bit of BioPerl...):
So I am getting to the sequence data for the IDs I want by looping through the '@data_in' array, then using a 'while each' on the %goodProteins_hash followed by an if... Perhaps not surprisingly this takes quite a long time per input ID, and if I want to get out a lot of sequences it takes ages!
So my question is: is there a quicker and more efficient way of doing something like this?? I tried playing around with grep and exists etc but I couldn't get it to do what I wanted...
Your responses, as always, are very much appreciated!