Perl Problem Set for Scenario 5

P5P.1: In the FindMotif.pl program we find the following definition and comment:
my $threshold = -2**30;    # Save motifs with scores greater than $threshold
# Set initially to a very low number.
# Changes as hits are found.
However, the current program doesn't actually change $threshold. Add one statement to the program to set $threshold. Does the program run faster? Why?



P5P.2: Change the sort statement in FindMotif.pl. Remove the reverse function and change the code block so that the effect of the statement is unchanged.
   @hit_info = reverse sort { $$a[0] <=> $$b[0] } @hit_info;


P5P.3: The current program calculates @informational, the set of positions which are used in the search, based on a fixed number, $info_threshold. Suppose that instead you wanted to search using the 12 positions with the greatest information content. You'd need to change calc_information_content to keep an array (say @info_array) with the information content of each position, then sort the array, then discard all but the top 15 positions.

A: What would each row of @info_array look like?

B: Write a sort statement to sort @info_array so the items with the most information come first in the array. Explain why it works.

C: How would you get the top 12 positions out of @info_array and into @informational?

D: (For programmers.) Make this change to FindMotif.pl.