Dec-01-2020, 02:12 PM
(Nov-29-2020, 01:20 PM)jefsummers Wrote: Write out in English the series of steps you would use to solve the problem, as detailed as you can. Then write the code for each step
To get you started -
1. Define a function with one parameter, the DNA sequence
2. Define a string with the valid nucleotide bases (ATGC)
3. Define a string that will be your output from the function
4. Start your loop through the DNA sequence, one letter (nucleotide) at a time
5. If the nucleotide is in the list of valid bases, add it to the output string
6. Once the loop has completed, return the output string
7. Test it on a test DNA sequence
Note that you do not want to modify the original DNA string when going through the loop. Leads to lots of hard to find errors. Bad mojo.
This sort of works but not really.
def filter_seq(dna_seqs): for dna in dna_seqs: if len(dna) == 72 and 'N, n' not in dna: print(filter_seq(test_seqs_N))