How do i write a Perl program code for this?

I've already written the code to discover a set of motifs of a DNA genome and save them in a hash table. Now I need find the top ten occurring motifs and print them out. They don't need to be saved anywhere, just printed out. Any suggestions? Something using a subroutine would be best but anything would work.

If it helps, this is a bioinformatics question.

Comments

  • When you "save" them into the hash, use the number of occurrences as the hash value. However, there is not an easy way to look through the values of a hash, so you just have to loop, printing the highest number each time until you've printed ten of them.

  • Oh, I love perl, unfortunately it has been too long. The usual way was to make the first script save the hashtable as a file, then the 2nd script went through taking out frequencies of 3, see if we have a list of 10, then take out frequencies of 4, then 5, until we get to a list of 10 items.

    If you google there are several bioinfometrics exercises, but by the nature of perl, you would be running down interesting trails but non-relevant to your cause.

Sign In or Register to comment.