The code runs for all 20 sequences on the terminal but during submit50/check50, it runs into an error with the following log:
the code is attached for reference.
import csv
import sys
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python dna.py [csv file] [sequence file]")
sys.exit()
dna_database = []
count_data = []
with open(sys.argv[1], 'r') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
dna_database.append((row))
with open(sys.argv[2], 'r') as sequencefile:
data = sequencefile.read()
for i in range(1, len(dna_database[0])):
count = 0
index = data.find(dna_database[0][i])
if index > -1:
# incrementing one count for first finding in each sequence of pattern
local_count = 1
while index > -1:
if data.find(dna_database[0][i], index+1) - data.find(dna_database[0][i], index) == len(dna_database[0][i]):
local_count += 1
else:
if local_count > count:
count = local_count
# incrementing one count for first finding in each sequence of pattern, hence local_count should start from 1
local_count = 1
index = data.find(dna_database[0][i], index + 1)
count_data.append(str(count))
# navigating through all the rows in list for checking the pattern
for i in range(1, len(dna_database)):
if dna_database[i][1::] == count_data:
print("{}".format(dna_database[i][0]))
sys.exit()
print("No match")
I am working in pset6/dna/ directory with code in file dna.py. Please suggest what can be the issue.