def make_primer_dictionaries():
import csv
cr = csv.reader(open("compiled_info_primer.txt", "rb"))
description = {}
sequence = {}
for row in cr:
str_id = str(row[0])
description[str_id] = row[1].lower()
sequence[str_id] = row[2].lower()
return [description, sequence]
def id_search(input, dict1, dict2):
if input in dict1:
if dict2[input] != "":
return [dict1[input], dict2[input]]
else:
return [dict1[input], "no sequence"]
else:
return False
def substr_search(input, dict1, dict2):
new = []
for key in dict2:
if input in dict2[key]:
if dict1[key] != "":
temporary = [key, dict1[key], dict2[key]]
new.append(temporary)
else:
temporary = [key, "no description", dict2[key]]
new.append(temporary)
if not new:
return False
else:
return new
def desc_search(input, dict1, dict2):
new = []
for key in dict1:
if input in dict1[key]:
if dict2[key] != "":
temporary = [key, dict1[key], dict2[key]]
new.append(temporary)
else:
temporary = [key, dict1[key], "no sequence"]
new.append(temporary)
if not new:
return False
else:
return new
def combo(input1, input2, dict1,dict2):
desc = desc_search(input1, dict1, dict2)
seq = substr_search(input2, dict1, dict2)
if desc== False and seq == False:
return False
if desc == False:
return [seq, "seq"]
if seq == False:
return [desc, "desc"]
new = []
for item in desc:
for value in seq:
if value[0] == item[0]:
temporary = value
new.append(temporary)
if not new:
return False
else:
return new
if __name__ == '__main__':
temp = combo("pspomi", "tttcct", description, sequence)
print temp