Struggling with RE to search for sequences 'TAA' (triplets of 3 characters) 'TAA' again.
I tried the following:
re.findall('TAA...+?TAA',seq)
which of course does not give triplets but does give me sequences
re.findall('TAA([ATGC]{3})+?TAA' , seq)
however gives me a list as output
'AGG', 'TCT', 'GTG', 'TGG', 'TGA', 'TAT',
Any ideas? As I of course can check the output from
re.findall('TAA...+?TAA',seq)
if length % 3 == 0, but how to do this with RE?
You want a non-capturing group.
(?:...)
A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.
Try this:
re.findall('TAA(?:[ATGC]{3})+?TAA' , seq)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With