0

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}"))

f = csv.DictReader(z)

text = open(f"{seq}")

seq = text.read()

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()

2 Answers 2

1

I don't think you should hard-code any sequences, but take them from the first row of the CSV file.

  • You may assume that the first row of the CSV file will be the column names. The first column will be the word name and the remaining columns will be the STR sequences themselves.
0

i also do same type of coding getting same error as yours when i print if seq[i:i+4] == 'A''A''T''G': AATG +=1 found that it cal value AATG = 9 rather than 8 so watched the video again it say save str with consecutive sequence now what to add ?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .