Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lists
#9
(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))
Reply


Messages In This Thread
Lists - by Tink - Nov-27-2020, 03:48 PM
RE: Lists - by deanhystad - Nov-27-2020, 04:21 PM
RE: Lists - by perfringo - Nov-27-2020, 06:02 PM
RE: Lists - by Tink - Nov-28-2020, 01:47 PM
RE: Lists - by Larz60+ - Nov-27-2020, 06:07 PM
RE: Lists - by jefsummers - Nov-28-2020, 02:07 PM
RE: Lists - by Tink - Nov-28-2020, 02:39 PM
RE: Lists - by jefsummers - Nov-29-2020, 01:20 PM
RE: Lists - by Tink - Dec-01-2020, 02:12 PM
RE: Lists - by deanhystad - Dec-01-2020, 03:43 PM
RE: Lists - by jefsummers - Dec-02-2020, 12:02 AM
RE: Lists - by perfringo - Dec-02-2020, 01:52 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020