I've been doing this for quite some time now, but I'm struggling to get the appropriate output. In the below code (which is incomplete as of now, but the main pieces are all on the board), I'm not able to print out cells corresponding to the right number of consecutive STRs, which is weird because if I try to print agatc_count for instance, it will give me the number of consecutive AGATCs which should have been detected by the program but isn't (in the nested for loop in the last block of code). I'm sure that me using a nested loop to scan through each and every cell of the table is correct, is it not? Where else the could the problem be?
from sys import argv, exit
import csv
from csv import reader, DictReader
import re
agatc_count = 0
tttct_count = 0
aatg_count = 0
tatc_count = 0
if len(argv) != 3:
print("missing command-line argument")
exit(1)
f = open(argv[2], "r")
s = f.readline()
str = len(s)
while True:
agatc = re.findall(r'(?:AGATC)+', s)
if not agatc:
break
largest = max(agatc, key=len)
agatc_count = len(largest) // 5
break
while True:
tttct = re.findall(r'(?:TTTTTTCT)+', s)
if not tttct:
break
largest = max(tttct, key=len)
tttct_count = len(largest) // 5
break
while True:
aatg = re.findall(r'(?:AATG)+', s)
if not aatg:
break
largest = max(aatg, key=len)
aatg_count = len(largest) // 4
break
while True:
tatc = re.findall(r'(?:TATC)+', s)
if not tatc:
break
largest = max(tatc, key=len)
tatc_count = len(largest) // 4
break
with open(argv[1], 'r') as temp:
reader = csv.reader(temp)
for row in reader:
for column in row:
if column == agatc_count:
print(column)
exit(1)
if column == tttct_count:
print(column)
exit(1)
if column == aatg_count:
print(column)
exit(1)
if column == tatc_count:
print(column)
exit(1)