def test_textfile_read_and_propagate(self): from nampy.manipulation import manipulation from nampy.monopartiteanalysis import prince the_network = create_test_model(test_network_file = test_network_text_filename) the_node_pairs = [x.get_node_pair() for x in the_network.edges] the_node_pairs_1 = the_node_pairs[0:16] the_node_ids_1 = [] for the_node_pair in the_node_pairs_1: the_node_ids_1 += [the_node_pair[0].id, the_node_pair[1].id] the_node_ids_1 = list(set(the_node_ids_1)) the_subnetwork_1 = manipulation.make_subnetwork(the_network, the_node_ids_1, 'subnetwork_1') for the_node in the_subnetwork_1.nodetypes[0].nodes: the_node.source = 1 the_result, the_permutations = prince.prince(the_subnetwork_1, n_permutations = 10, verbose = False) self.assertEqual(len(the_permutations[the_node_ids_1[0]]), 10)
# e.g. the database might not requrn the id's we query with counter = 0 # Just have one nodetype for the_node in humannet.nodetypes[0].nodes: if len(the_node.notes["Entrez Gene (GeneID)"]) == 0: the_node.notes["Entrez Gene (GeneID)"].append(the_node.id) counter +=1 print(counter) # APMS host targets from # Jäger, S., Cimermancic, P., Gulbahce, N., Johnson, J. R., McGovern, K. E., Clarke, S. C., # … Krogan, N. J. (2012). Global landscape of HIV-human protein complexes. # Nature, 481(7381), 365–70. doi:10.1038/nature10719 hiv_apms_file = data_dir + "published_hiv_apms_factors.txt" apms_source = networkio.create_source_dict_from_textfile(hiv_apms_file) apms_source_dict = idmapping.get_more_source_dict_ids(apms_source, "UniProtKB ACC/ID", mapping_types = ["Entrez Gene (GeneID)", "UniProtKB ACC", "UniProtKB ID"]) counter = 0 for the_key in apms_source_dict.keys(): if len(apms_source_dict[the_key]["UniProtKB ACC"]) == 0: apms_source_dict[the_key]["UniProtKB ACC"].append(the_key) counter +=1 print(counter) humannet, unmatched_ids_dict = manipulation.add_source(humannet, apms_source_dict, match_key_type = 'Entrez Gene (GeneID)') # Just 10 permutations done here for demonstration purposes, to establish statistics you will need more the_result, the_permutations = prince.prince(humannet, n_permutations = 10, verbose = True) # The propagation scores are stored in the_result