# PSET 6 - DNA.py faiils checks 2 out of 21 text files. (8.txt and 9.txt.)

My code works fine for 19 out of 21 SRT Counts but fails check on 8.txt and 9.txt files. I am not sure what I am doing wrong. Have tried many different approaches but to no change of luck.

please if anyone can find what's wrong with the code let me know. thanks.

z = (open(f"{data}"))

text = open(f"{seq}")

AATG = 1

GATA = 1

TATC = 1

GAAA = 1

TCTG = 1

TCTAG = 1

AGATC = 1

TTTTTTCT = 1

for i in range(len(seq)):

while (seq[i:i+4]  == (seq[i+4: (i + 8)])):

if seq[i:i+4] == 'A''A''T''G':

AATG +=1

elif seq[i:i+4] == 'G' 'A' 'T' 'A':

GATA +=1

elif seq[i:i+4] == 'T' 'A' 'T' 'C':

TATC +=1
elif seq[i:i+4] == 'G' 'A' 'A' 'A':
GAAA +=1

elif seq[i:i+4] == 'T' 'C' 'T' 'G':

TCTG +=1

break

while (seq[i:i+5]  == (seq[i+5: (i + 10)])):

if seq[i:i+5] == 'T' 'C' 'T' 'A' 'G':

TCTAG +=1

elif seq[i:i+5] == 'A' 'G' 'A' 'T' 'C':

AGATC +=1

break

while (seq[i:i+8]  == (seq[i+8: (i + 16)])):

if seq[i:i+8] == 'T' 'T' 'T' 'T' 'T' 'T' 'C' 'T':

TTTTTTCT += 1

break


print(f"GATA : {GATA}, GAAA = {GAAA}, TCTG = {TCTG}, AATG = {AATG}, TATC = {TATC}, TCTAG = {TCTAG}, AGATC = {AGATC}, TTTTTTCT = {TTTTTTCT}")

person = None

for row in f:

if int(row['AATG']) == AATG and int(row['AGATC']) == AGATC and


int(row['TATC']) == TATC:

    person = (row['name'])

elif int(row['AATG']) == AATG and int(row['AGATC']) == AGATC and int(row['TTTTTTCT']) == TTTTTTCT and int(row['GAAA']) == GAAA and int(row['TATC']) == TATC and int(row['GATA']) == GATA and int(row['TCTAG']) == TCTAG and int(row['TCTG']) == TCTG:

person = (row['name'])


if person != None:

print(f"{person}")


else:

print("No match")


z.close() text.close()