write a function to parse the below pattern onto a text file and highlight the matched pattern using the sliding window concept. AATAA,ATTAAA,TATA,CAT,ATAGTCGC and slicing by 32 bases
REG = 'AATAA,ATTAAA,TATA,CAT,ATAGTCGC'
def find_reg(path_file, reg = REG):
res = []
with open(path_file, 'r') as f:
text = f.read()
size = len(text) - len(reg)
for i in range(size):
for j in reg:
if text[i] != j:
break
else:
res.append([i,i+len(reg)])
# example work
file = input('Enter path and file name')
result = find_reg(file)
print('The pattern was found in the following positions [start, end]')
for i in result:
print(i)
Comments
Dear clash coders there are no error in the code
when the program compiles and it shows an error The pattern was found in the following positions [start, end] Traceback (most recent call last): File "function3.py", line 22, in for i in result: TypeError: 'NoneType' object is not iterable
Leave a comment