I'm kind of lost I don't know how I can compare the max number of occurrences with the database. My program here can get the max number of it stored in a list called counts to get it I used a function that uses re stuff. So what I have is a list of the max number of STR's like
counts = [4, 1, 5] but once I have this how will I compare it with the database I don't quite get for loops in python.
from sys import exit, argv import csv import re def main(): # exit file if missing com-line arguments if len(argv) != 3: print("Usage... [python file.py database.csv sequence.txt]") exit(1) #open the csv file that serves as the database then store them # within a list wherein each row is a list with open(argv, newline='') as database: # read the file then store them as a list read = csv.reader(database) # store the first line of the database in a list headers = next(read) # store the read database into a 2d list data = list(read) # remove name in the headers list del headers # open the sequence file dna = open(argv, "r") # read the sequence file and store into sequence and strip the trailing new line sequence = dna.read().rstrip('\n') # list that will store the max counts of each header counts =  # create a function that counts the max number of consecutive occurrences # of the STR's in the sequence for x in range(len(headers)): # traverse through the header list then call count_occurences function # to return the max number of occurrences of each STR then store it # into counts list counts.append(count_occurrences(sequence, headers[x])) print(counts) # function that will find the max number of occurences by # using the re library and regular expressions def count_occurrences(sequence, STR): pattern = "(?=((" + re.escape(STR) + ")+))" matches = re.findall( pattern, sequence ) return max( len( m ) // len( STR ) for m in matches ) main()