diff --git a/deconvolution/dgraph/CliqueDGFactory.py b/deconvolution/dgraph/CliqueDGFactory.py index c30309bffbae53fa7c2f20384841a6f8a333f819..9fd056470669608b6d5030184466b7657f212d4d 100644 --- a/deconvolution/dgraph/CliqueDGFactory.py +++ b/deconvolution/dgraph/CliqueDGFactory.py @@ -67,7 +67,8 @@ class CliqueDGFactory(AbstractDGFactory): observed_link = len(c1 & c2) # Intersections of the nodes are glued links neighbor_intersection = clique_neighbors_set[c1_idx] & c2 neighbors_multiset = clique_neighbors_multiset[c1_idx] - observed_link += sum(neighbors_multiset[x] for x in neighbor_intersection) # Sum the links between the cliques + for x in neighbor_intersection: + observed_link += neighbors_multiset[x] # Sum the links between the cliques # Awaited links d_approx = max(len(c1), len(c2)) diff --git a/experiments/clique_graph_eval.py b/experiments/clique_graph_eval.py index f9697a1ceef6f60d7623ac1cf8f928b2401d5d3d..3b85627cd1effe20ede1cd66432c8f16c415c800 100644 --- a/experiments/clique_graph_eval.py +++ b/experiments/clique_graph_eval.py @@ -10,6 +10,8 @@ from deconvolution.dgraph.CliqueDGFactory import CliqueDGFactory def parse_arguments(): parser = argparse.ArgumentParser(description="Tests on graph barcode") parser.add_argument('barcode_graph', help='The barcode graph file. Must be a gexf formatted file.') + parser.add_argument('--threads', '-t', type=int, help="Number of threads to use (Set 1 for profiling)") + parser.add_argument('--verbose', '-v', action='store_true', help="Set the verbose flag") args = parser.parse_args() return args @@ -77,10 +79,10 @@ def analyse_clique_graph(barcode_graph): return continuous, len(clique_graph.nodes()) -def analyse_d_graphs(barcode_graph): +def analyse_d_graphs(barcode_graph, threads=8, verbose=False): # Generate udgs factory = CliqueDGFactory(barcode_graph, 1) - udg_per_node = factory.generate_all_dgraphs(threads=1) + udg_per_node = factory.generate_all_dgraphs(threads=threads, verbose=verbose) # Remove duplicate udgs udgs = {} for udg_node_lst in udg_per_node.values(): @@ -100,12 +102,12 @@ def analyse_d_graphs(barcode_graph): def main(): args = parse_arguments() g = nx.read_gexf(args.barcode_graph) + # prev_time = time.time() + # continuous, total = analyse_clique_graph(g) + # print("cliques", time.time() - prev_time) + # print(continuous, "/", total) prev_time = time.time() - continuous, total = analyse_clique_graph(g) - print("cliques", time.time() - prev_time) - print(continuous, "/", total) - prev_time = time.time() - continuous, total = analyse_d_graphs(g) + continuous, total = analyse_d_graphs(g, threads=args.threads, verbose=args.verbose) print("udgs", time.time() - prev_time) print(continuous, "/", total)