Read a DNA sequence from a text file Calculate the %GC content
If you add the line Use strict to your program, it will require you to initialize all variables with "My" names. That is too much hassle for this exercise, so we will not bother with that unless you want to.
Write the output to the screen and to a file use append so that the file will grow as you run this program on additional sequences
HINTS:
@DNA = <FILE>;
$DNA = join('', @DNA);
$base = substr($DNA, $count, 1);
What about non-DNA characters in the file?
- carriage returns and blank spaces
- N's or X's or unexpected letters
Your program would be much more useful if it asked for a filename of the DNA sequence to be entered from the keyboard, rather than requiring you to edit the Perl code each time you want to run it on a new sequence.
If you try to read a file from a name that is typed in at the keyboard, what if there is no such file?
Send me your program and the results from running it on these 3 sequence files: