It's often useful to generate random data for test purposes. Random DNA can also be used to study the organization of actual DNA from an organism. In this section, we'll write some programs to generate random DNA sequences.
Such random DNA sequences have proved useful in several ways. For instance, the popular BLAST program (see Chapter 12) depends on the properties of random DNA for the analytic and empirical results that underpin the sequence similarity scores, statistics that are used to rank the "hits" that BLAST returns to the user.
Let's assume what's needed is a set of random DNA fragments of varying length. Your program will have to specify a maximum and a minimum length, as well as how many fragments to generate.
In Example 7-2, you wrote the basic subroutines, then a subroutine that called the basic subroutines, and finally the main program. If you ignore the pseudocode, this is an example of bottom-up design; start with the building blocks, then assemble them into a larger structure.
Now let's see what it's like to start with the main program, with its subroutine calls, and write the subroutines after you find a need for them. This is called top-down design.
Given our goal of generating random DNA, perhaps what you want is a data-generating subroutine:
@random_DNA = make_random_DNA_set( $minimum_length, $maximum_length, $size_of_set );
This looks okay, but of course, it begs ...