Can someone explain why my code is returning no match as I thought you can compare two dictionaries with "=="?
import csv
import sys
import copy
def main():
# TODO: Check for command-line usage
if len(sys.argv) != 3:
sys.exit(1)
# TODO: Read database file into a variable
database = []
key = []
database_file = sys.argv[1]
d = open(database_file, "r")
reader = csv.DictReader(d)
for name in reader:
database.append(name)
copy_database = copy.deepcopy(database)
for i in range(len(copy_database)):
del copy_database[i]["name"]
for i in range(len(copy_database)):
for k in copy_database[i]:
key.append(k)
remove_dup = list(set(key))
# TODO: Read DNA sequence file into a variable
sequence_file = sys.argv[2]
s = open(sequence_file, "r")
sequence = s.read()
# TODO: Find longest match of each STR in DNA sequence
match = {}
for i in range(len(remove_dup)):
match[remove_dup[i]] = longest_match(sequence,remove_dup[i])
# TODO: Check database for matching profiles
for i in range(len(database)):
if match == copy_database[i]:
print(database[i]["name"])
print("No Match")
I can see that i am putting the longest sequence in the match dict and it is the correct one but when im trying to compare it with the database copy without the name key im not getting any hits.