Commit be448d6c authored by rchikhi's avatar rchikhi
Browse files

some debug info to d2 graph construction

parent 47b4117e
......@@ -59,7 +59,7 @@ class D2Graph(nx.Graph):
import debug_disct as dd
# Compute all the d-graphs
if verbose:
print("Compute the unit d-graphs")
print("Computing the unit d-graphs..")
self.d_graphs_per_node = compute_all_max_d_graphs(self.barcode_graph, debug=debug)
if verbose:
counts = sum(len(x) for x in self.d_graphs_per_node.values())
......@@ -242,6 +242,8 @@ def compute_all_max_d_graphs(graph, debug=False):
# Find all the cliques (equivalent to compute all the candidate half d-graph)
cliques = list(nx.find_cliques(neighbors_graph))
if debug: print("node",node,"has",len(cliques),"cliques")
# Pair halves to create d-graphes
for idx, clq1 in enumerate(cliques):
for clq2_idx in range(idx+1, len(cliques)):
......@@ -10,25 +10,41 @@ import d2_graph as d2
def parse_arguments():
parser = argparse.ArgumentParser(description='Transform a 10X barcode graph into a d2 graph. The program dig for the d-graphs and then merge them into a d2-graph.')
parser.add_argument('barcode_graph', help='The barcode graph file. Must be a gefx formated file.')
parser.add_argument('--output_prefix', '-o', default="d2_graph", help="Output file prefix.")
parser.add_argument('--output_prefix', '-o', default="d2_graph", help="Output file prefix.")
parser.add_argument('--debug', '-d', action='store_true', help="Debug")
args = parser.parse_args()
return args
def main():
# Parsing the input file
args = parse_arguments()
debug = args.debug
filename = args.barcode_graph
if not filename.endswith('.gexf'):
print("Input file must be gexf formatted", file=sys.stderr)
def dprint(s):
from datetime import datetime
t ='%Y-%m-%d %H:%M:%S')
if debug: print(t,"[debug]",s)
dprint("loading barcode graph")
if filename.endswith('.gexf'):
G = nx.read_gexf(filename)
elif filename.endswith('.graphml'):
G = nx.read_graphml(filename)
print("Input file must be gexf or graphml formatted", file=sys.stderr)
dprint("barcode graph loaded")
G = nx.read_gexf(filename)
# Index size must be changed for general purpose. 8 is good for d=5
dprint("creating D2graph object")
d2g = d2.D2Graph(G)
dprint("D2 graph object created")
dprint("constructing d2 graph from barcode graph")
d2g.construct_from_barcodes(index_size=8, debug=debug)
dprint("[debug] d2 graph constructed")"{args.output_prefix}.tsv")
nx.write_gexf(d2g, f"{args.output_prefix}.gexf")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment