Skip to content
Snippets Groups Projects
Commit c9f90cbf authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

remove sum method to replace by a for: x2 speedup

parent 061f4092
No related branches found
No related tags found
No related merge requests found
...@@ -67,7 +67,8 @@ class CliqueDGFactory(AbstractDGFactory): ...@@ -67,7 +67,8 @@ class CliqueDGFactory(AbstractDGFactory):
observed_link = len(c1 & c2) # Intersections of the nodes are glued links observed_link = len(c1 & c2) # Intersections of the nodes are glued links
neighbor_intersection = clique_neighbors_set[c1_idx] & c2 neighbor_intersection = clique_neighbors_set[c1_idx] & c2
neighbors_multiset = clique_neighbors_multiset[c1_idx] 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 # Awaited links
d_approx = max(len(c1), len(c2)) d_approx = max(len(c1), len(c2))
......
...@@ -10,6 +10,8 @@ from deconvolution.dgraph.CliqueDGFactory import CliqueDGFactory ...@@ -10,6 +10,8 @@ from deconvolution.dgraph.CliqueDGFactory import CliqueDGFactory
def parse_arguments(): def parse_arguments():
parser = argparse.ArgumentParser(description="Tests on graph barcode") 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('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() args = parser.parse_args()
return args return args
...@@ -77,10 +79,10 @@ def analyse_clique_graph(barcode_graph): ...@@ -77,10 +79,10 @@ def analyse_clique_graph(barcode_graph):
return continuous, len(clique_graph.nodes()) return continuous, len(clique_graph.nodes())
def analyse_d_graphs(barcode_graph): def analyse_d_graphs(barcode_graph, threads=8, verbose=False):
# Generate udgs # Generate udgs
factory = CliqueDGFactory(barcode_graph, 1) 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 # Remove duplicate udgs
udgs = {} udgs = {}
for udg_node_lst in udg_per_node.values(): for udg_node_lst in udg_per_node.values():
...@@ -100,12 +102,12 @@ def analyse_d_graphs(barcode_graph): ...@@ -100,12 +102,12 @@ def analyse_d_graphs(barcode_graph):
def main(): def main():
args = parse_arguments() args = parse_arguments()
g = nx.read_gexf(args.barcode_graph) 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() prev_time = time.time()
continuous, total = analyse_clique_graph(g) continuous, total = analyse_d_graphs(g, threads=args.threads, verbose=args.verbose)
print("cliques", time.time() - prev_time)
print(continuous, "/", total)
prev_time = time.time()
continuous, total = analyse_d_graphs(g)
print("udgs", time.time() - prev_time) print("udgs", time.time() - prev_time)
print(continuous, "/", total) print(continuous, "/", total)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment