Write a script that produces formatted output.
Affinity and Nucleotide Sequences
The affinity between two nucleotide sequences can be measured by comparing the sequences for complementarity base by base. For instance, take a look at the following two sequences:
aagctgacga --|||--|-| agcgaaagatAs you can see when the two nucleotide sequences are compared one nucleotide at a time, there are five pairs of complementary nucleotides. It would not be difficult to convert this into a percentage. In this case, you could say that the two sequences have an affinity of .50 or 50%. The greater the affinity between two sequences the more likely they are to anneal when they come in contact with each other. Recall that two hydrogen bonds form between G and C nucleotides and three hydrogen bonds form between A and T nucleotides.
(We are ignoring the fact that DNA sequences have 3' and 5' ends here. In reality, one sequence will anneal with another in the opposite direction so that one strand is going in the 3' to 5' direction and the other in the 5' to 3' direction. We ignore that little detail here.)
Formatted Output
The following example shows one way to print formatted output. Notice that the function is called printf (instead of just print) and that the variables are plugged into little place holders (%s).
Specifier | Description |
---|---|
%c | Single character |
%d | Integer in decimal (base-10) format |
%e | Floating-point number in scientific notation |
%f | Floating-point number in "normal" (fixed-point) notation |
%g | Floating-point number in compact format |
%o | Integer in octal (base-8) format |
%s | Character string |
%u | Unsigned integer |
%x | Integer in hexadecimal (base-16) format |
ASSIGNMENT:
Your job will be to create an affinity report with the following format:
gcgttagatc ccctttagag atgctgatgc gagcactata cgtgtcatat gagatttgcc gcgttagatc 0 5 1 1 4 2 ccctttagag 5 0 2 5 1 5 atgctgatgc 1 2 0 5 2 3 gagcactata 1 5 5 0 7 1 cgtgtcatat 4 1 2 7 0 2 gagatttgcc 2 5 3 1 2 0The numbers represent the number of complementary nucleotides between each sequence. Notice that the sequences listed vertically on the left side of the table are the same as those listed horizontally along the top.