Homework 8 (DNA) FAQ

Q: Where do I start?

A: Try to break the problem into pieces. First try to read a record (a name and its sequence of nucleotides) from the file. Then try to count the nucleotides. Look at the diagram of the lists on the HW7 spec for inspiration. If you aren't very familiar with lists, perhaps try looking at practice problems about them first until you feel comfortable.

Q: How do I read two lines at a time?

A: Well, the thing that you do to read one line at a time.... do that twice in a row.

Q: How do I examine the letters of the line to see which nucleotide they are (A, C, G, or T)?

A: Look over section 7 problems about text processing.

Q: How do I place the nucleotide into the right element of the list, when counting the occurrences of nucleotides?

A: Look at the lecture example on section attendance. It's okay to use if/else statements to express the mapping between the characters and the list indexes, as long as you avoid redundancy as much as possible.

Q: Why are my mass percentages way off?

A: Are you sure that you are weighting each nucleotide by its mass as listed in the handout? For example, adenine has a molar mass of 135.128.

Q: Why are my mass percentages SLIGHTLY off (0.1 or so)?

A: Usually that's because you didn't round correctly

Q: I have a lot of repetitive code. How do I make it less redundant?

A: You must work especially hard on this assignment to eliminate redundancy. Use techniques we've practiced in the past, such as factoring common code out of an if/else statement, or creating a helping function to hold common code. Look at the "Sections" program from lecture to learn how to write good functions that use lists as parameters/returns.