def testRunSBiDer(directory_path, user_query, indirect=False): # Access database database_file = directory_path + "/SBiDer.db" conn, cur = db.db_open(database_file) # Dictionary of fragmented user inputs that satisfy user query logic_dictionary = parser.parse_logic(cur, user_query) # Dictionaries of: Operon <-> InputSpecies, Operon <-> OutputSpecies, and Operon <-> Repressor input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) #rint("** input dictionary") #BiDer_helper.printplus(input_dictionary) #rint("** output dictionary") #BiDer_helper.printplus(output_dictionary) #rint("** repressor dictionary") #BiDer_helper.printplus(repressor_dictionary) # Build operon path for each fragmented user input, which satisfies user query all_operon_path = [] for input_species, output_species_list in logic_dictionary.items(): operon_path_per_start_species = [input_species] for output_species in output_species_list: operon_path_list = searcher.get_sbider_path( input_dictionary, repressor_dictionary, output_dictionary, list(input_species), output_species, indirect) operon_path_per_start_species.extend(operon_path_list) all_operon_path.append(operon_path_per_start_species) return all_operon_path == [[('21', '22'), ['72-3'], ['82-1']]]
def test_searcher_indirect_2(self): """testing the following query ahl and laci = gfp for the indirect traverse""" conn, cur = db.db_open("sbider.db") user_query = "ahl and laci = gfp" logic_dictionary = parse.parse_logic(cur, user_query) input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) self.operon_path_list = search.get_sbider_path(input_dictionary, repressor_dictionary, output_dictionary, ['13', '22'], ['11'], True) for operon_path in self.operon_path_list: current_species = ['13', '22'] input_species_set = set(current_species) output_species_set = set(current_species) for operon in operon_path: input_species = helper.uniquely_merge_list_of_lists(input_dictionary[operon]) output_species = helper.uniquely_merge_list_of_lists(output_dictionary[operon]) for species in input_species: if species in output_species_set: input_species_set.add(species) for species in output_species: output_species_set.add(species) self.assertEquals(input_species_set.issubset(output_species_set), True) db.db_close(conn,cur)
def test_searcher_indirect_2(self): """testing the following query ahl and laci = gfp for the indirect traverse""" conn, cur = db.db_open("sbider.db") user_query = "ahl and laci = gfp" logic_dictionary = parse.parse_logic(cur, user_query) input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) self.operon_path_list = search.get_sbider_path(input_dictionary, repressor_dictionary, output_dictionary, ['13', '22'], ['11'], True) for operon_path in self.operon_path_list: current_species = ['13', '22'] input_species_set = set(current_species) output_species_set = set(current_species) for operon in operon_path: input_species = helper.uniquely_merge_list_of_lists( input_dictionary[operon]) output_species = helper.uniquely_merge_list_of_lists( output_dictionary[operon]) for species in input_species: if species in output_species_set: input_species_set.add(species) for species in output_species: output_species_set.add(species) self.assertEquals( input_species_set.issubset(output_species_set), True) db.db_close(conn, cur)
def test_searcher_direct(self): """testing the following query lara and arac to gfp for the direct traverse""" conn, cur = db.db_open("sbider.db") user_query = "lara and arac = gfp" logic_dictionary = parse.parse_logic(cur, user_query) input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) self.operon_path_list = search.get_sbider_path(input_dictionary,repressor_dictionary,\ output_dictionary, ['2', '38'], ['11'], False) for operon_path in self.operon_path_list: current_species = ['2', '38'] for operon in operon_path: self.assertEquals(current_species in input_dictionary[operon], True) current_species = output_dictionary[operon][0] db.db_close(conn,cur)
def test_searcher_direct(self): """testing the following query lara and arac to gfp for the direct traverse""" conn, cur = db.db_open("sbider.db") user_query = "lara and arac = gfp" logic_dictionary = parse.parse_logic(cur, user_query) input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) self.operon_path_list = search.get_sbider_path(input_dictionary,repressor_dictionary,\ output_dictionary, ['2', '38'], ['11'], False) for operon_path in self.operon_path_list: current_species = ['2', '38'] for operon in operon_path: self.assertEquals(current_species in input_dictionary[operon], True) current_species = output_dictionary[operon][0] db.db_close(conn, cur)
def build_sbider_network(directory_path, user_query, indirect=False): print("** build_sbider_network") # Access database database_file = directory_path + "/SBiDer.db" conn, cur = db.db_open(database_file) # Dictionary of fragmented user inputs that satisfy user query logic_dictionary = parser.parse_logic(cur, user_query) # Dictionaries of: Operon <-> InputSpecies & Operon <-> OutputSpecies input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) print("** input dictionary") SBiDer_helper.printplus(input_dictionary) print("** output dictionary") SBiDer_helper.printplus(output_dictionary) # Dictionary of: Operon <-> Repressor repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) print("** repressor dictionary") SBiDer_helper.printplus(repressor_dictionary) # Build operon path for each fragmented user input, which satisfies user query all_operon_path = [] for input_species, output_species_list in logic_dictionary.items(): operon_path_per_start_species = [input_species] for output_species in output_species_list: operon_path_list = searcher.get_sbider_path(input_dictionary, repressor_dictionary, output_dictionary, list(input_species), output_species, indirect) operon_path_per_start_species.extend(operon_path_list) all_operon_path.append(operon_path_per_start_species) # Create JSON file needed to display the found genetic circuit path_json = grapher.create_subnetwork_json_string(cur, operon_path_per_start_species, database_file) return path_json
def build_sbider_network(user_query, indirect=False): database_file = \ "/cellar/users/hyeerna/Dropbox/Project/20140601_sbider/UCSD_IGEM/SBiDer/SBiDer_Database/sbider.db" conn, cur = db.db_open(database_file) logic_dictionary = parser.parse_logic(cur, user_query) print "build_sbider_network: logic_dictionary", logic_dictionary input_dictionary, output_dictionary = db.make_ope_id_spe_id_dicts(cur) all_operon_path_list_per_start_species = [] file_name_idx = 1 for input_species, output_species_list in logic_dictionary.items(): operon_path_list_per_start_species = [input_species] for output_species in output_species_list: print "\t Path:", input_species, "--->", output_species, "=" operon_path_list = searcher.get_sbider_path(input_dictionary, output_dictionary, list(input_species), output_species, indirect) operon_path_list_per_start_species.extend(operon_path_list) for operon_path in operon_path_list: print "\t\t build_sbider_network: operon_path =>", operon_path all_operon_path_list_per_start_species.append(operon_path_list_per_start_species) file_name = "test_json_file_%d.json" % file_name_idx grapher.create_subnetwork_json(cur, operon_path_list_per_start_species, file_name) file_name_idx += 1
def testRunSBiDer(directory_path, user_query, indirect=False): # Access database database_file = directory_path + "/SBiDer.db" conn, cur = db.db_open(database_file) # Dictionary of fragmented user inputs that satisfy user query logic_dictionary = parser.parse_logic(cur, user_query) # Dictionaries of: Operon <-> InputSpecies, Operon <-> OutputSpecies, and Operon <-> Repressor input_dictionary, output_dictionary = db.make_ope_id_spe_id_dics(cur) repressor_dictionary = db.make_ope_id_rep_spe_id_dic(cur) #rint("** input dictionary") #BiDer_helper.printplus(input_dictionary) #rint("** output dictionary") #BiDer_helper.printplus(output_dictionary) #rint("** repressor dictionary") #BiDer_helper.printplus(repressor_dictionary) # Build operon path for each fragmented user input, which satisfies user query all_operon_path = [] for input_species, output_species_list in logic_dictionary.items(): operon_path_per_start_species = [input_species] for output_species in output_species_list: operon_path_list = searcher.get_sbider_path(input_dictionary, repressor_dictionary, output_dictionary, list(input_species), output_species, indirect) operon_path_per_start_species.extend(operon_path_list) all_operon_path.append(operon_path_per_start_species) return all_operon_path == [[('21', '22'), ['72-3'], ['82-1']]]