Module 12

Searching motifs

Finding patterns across sequences.

Pattern matching

You can search for a motif across many sequences and count how many contain it.

seqs = ["ATGCGTA", "CCATGGC", "TTTTTT"]
motif = "ATG"
matches = [s for s in seqs if motif in s]
print(len(matches), "sequences contain", motif)
Your task

Search motifs

  • Find sequences containing ATG.