This elif(a == True and r == 3 and r == 4 or 7): will always evaluate to True because 7 is "truthy". Did you mean or r == 7? And once an or introduced, the expression will likely need parentheses. Same goes for the subsequent elif.
I found the fix finally:
if s.argv == 'databases/large.csv':
# NOTE - this is adapted from: https://stackoverflow.com/questions/61131768/how-to-count-consecutive-substring-in-a-string-in-python-3
for i in str_list:
expected = i
str_max = 0
while expected in read_s:
str_max += 1
Your observation[key] is an integer. row[key] is a string. When you do observation[key] != row[key], (In this case 4 != '4')it will be true, breaking the loop.
So to fix this issue, do observation[key] != int(row[key])
I found the problem. It turned out that I forgot the reset the counter in else condition. Also, my while loop should be less than or equal instead of just less than and I don't need if condition to check whether i + len(dna_str) > len(sequence) since I am already checking it in my while statement. Correct code of function get_max_str_repeats() is below.