Module 12

Counting motifs

Counting occurrences with regex.

Counting patterns

re.findall() returns all matches. You can count them with len().

import re
seq = "AATATATGC"
count = len(re.findall("AT", seq))
print(count)
Your task

Count motifs

  • Count occurrences of AT in AATATATGC.