Hi there I am having an issue comparing the data I have extracted from the sequence and the database files for now I am doing a sort of in efficient way but later I will fix it I am not sure really how to fix my code.
so for now I am kind of testing out if it works for the small db but when i run my code all I get is the output "nooo" instead of "yaaa" which is just for testing.
if anyone could help me and give me a better way to check because I dont think my is the best way possible please help me because I have been stuck on this question for a while now thank you :D
this is my code:
from sys import argv
import csv
import re
db_file = argv[1]
dna_sequence = argv[2]
if len(argv) > 3:
print("Oops! there are 2 arguments")
dna_data = []
# reads from database
with open(db_file, 'r') as f:
reader = csv.reader(f)
next(reader)
for row in reader:
for col in row:
dna_data.append(col)
# reads dna sequence from the files
with open(dna_sequence, 'r') as sq_file:
dna_sequence = sq_file.readline().rstrip("\n")
# for calculating the amount of formations in the txt file
formation_count_large=[]
dna_formations_large = ["AGATC","TTTTTTCT","TCTAG","AATG","GATA","TATC","GAAA","TCTG"]
formation_count_small=[]
dna_formations_small = ["AGATC","AATG","TATC"]
if db_file == "databases/small.csv":
for i in range(3):
formation_count_small.append(len(re.findall(dna_formations_small[i], dna_sequence)))
else:
for i in range(8):
formation_count_large.append(len(re.findall(dna_formations_large[i], dna_sequence)))
if db_file == "databases/small.csv":
for i in range(len(dna_data)):
for j in range(3):
if dna_data[i] == formation_count_small[j]:
print("yaaa")
else:
print("nooo")