Novice here!!
I am trying to search through a FASTA for a specific DNA sequence, but I keep getting a sytax error. The if statements work outside of the for loop, so I think it is how I have put them in, can anybody see the syntax error here, I can't work it out:
#!/bin/python
#My Mimp_finder
import re
from Bio import SeqIO
for seq in SeqIO.parse("Focub_mimp12rm_Chang_mimps.faa", "fasta"):
print(seq.id)
print(len(seq)
if re.search(r"CAGTGGG..GCAA[TA]AA", seq):
result_start = re.search(r"CAGTGGG..GCAA[TA]AA", seq)
match_1_start = result_start.start()
elif re.search(r"TT[TA]TTGC..CCCACTG", seq):
result_end = re.search(r"TT[TA]TTGC..CCCACTG", seq)
match_2_end = result_end.end()
mimp_lenth = match_2_end - match_1_start
print('---------------------------\n\n')
if mimp_lenth < 400 :
print('Mimp found at postion ' + str(match_1_start) + ' and ' + str(match_2_end) + ' in the sequence: \n\n' + seq + '. \n\nThe $
print('\n\n---------------------------\n\n')
Returned:
File "./My_mimp_finder.py", line 16
if re.search(r"CAGTGGG..GCAA[TA]AA", seq):
^
SyntaxError: invalid syntax
Python version 3.8.3