My code works perfectly fine with the small database but gives "No Match" for the large one and I can't figure out why. Any help would be appreciated!
import csv
from sys import argv, exit
def main():
if len(argv) != 3:
print("Usage: python dna.py data.csv sequence.txt")
exit(1)
# Opening database to check against
with open(argv[1], "r") as data:
database = csv.reader(data)
database = list(database)
# Opening sequence to check
with open(argv[2], "r") as seq:
sequence = csv.reader(seq)
sequence = list(sequence)
a = len(database[0]) # a - 1 is no of STRs to check
l = [] # Counter for particular sequence
for j in range(1, len(database[0])): # Checks counts of each STR and adds to list
l.append(count(database[0][j], sequence))
for i in range(1, a):
x = 0
for j in range(1, len(database[0])):
if (int(database[i][j]) == l[j - 1]):
x += 1
if x == (a - 1):
print(database[i][0])
break
if x != (a - 1):
print("No Match")
def count(a, b): # b is sequence and a is STR
counter = 0
start = 0
end = 0
d = []
c = len(a)
i = 0
while True:
found = b[0][0].find(a, start)
if found == -1:
break
if start != found:
counter = 0
counter += 1
start = found + c
else:
counter += 1
start = found + c
d.append(counter)
d.sort()
x = len(d)
return d[x - 1]
main()