-
Exercise 6.1
-
Write a subroutine to concatenate two strings of DNA.
-
Exercise 6.2
-
Write a subroutine to report the percentage of each nucleotide in
DNA. You've seen the plus operator +. You
will also want to use the divide operator / and
the multiply operator *. Count the number of each
nucleotide, divide by the total length of the DNA, then multiply by
100 to get the percentage. Your arguments should be the DNA and the
nucleotide you want to report on. The int function
can be used to discard digits after the decimal point, if needed.
-
Exercise 6.3
-
Write a subroutine to prompt a user with any message, and collect the
user's answer. The subroutine's argument should be the
message, and the return value should be the (one-line) answer.
-
Exercise 6.4
-
Write a subroutine to look for command-line arguments such as
-help, -h, and
--help. Recall that command-line arguments appear
in the @ARGV array. Call your subroutine from a
main program. If you give the program any of the named command-line
arguments, when you pass them into the subroutine it should return a
true value. If this is the case, have the program print out a help
message in a $USAGE variable and exit.
-
Exercise 6.5
-
Write a subroutine to check if a file exists, is a regular file, and
is nonzero in size. Use the file test operators
(See Appendix B).
-
Exercise 6.6
-
Use Exercise 6.3 in a subroutine that keeps prompting until a valid
file is entered by the user or until five attempts have failed.
-
Exercise 6.7
-
Write a module that contains subroutines that report various
statistics on DNA sequences, for instance length, GC content,
presence or absence of poly-T sequences (long stretches of mostly
T's at the 5' (left) end of many $DNA
sequences), or other measures of interest.
-
Exercise 6.8
-
Write a subroutine to do something a biologist normally does.
(Here's an opportunity to look around the lab and write a
useful program!)
-
Exercise 6.9
-
Read the documentation about the debugger and become familiar with
its use by applying it during your programming.
-
Exercise 6.10
-
Write a subroutine that alters an array of lines in a file. Use pass
by reference for the array. Pass the subroutine a reference to the
array, a regular expression, and a string to replace the regular
expression. All the lines of the array should be altered by
substituting the matches found for the regular expression by the
replacement string.