Commit beef8eba authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

barcode graph evaluation

parent 2403e42b
......@@ -12,7 +12,7 @@ def parse_args():
parser = argparse.ArgumentParser(description='Process a d2 graph (complete graph or path) to evaluate its quality.')
parser.add_argument('filename', type=str,
help='The file to evalute')
parser.add_argument('--type', '-t', choices=["d2", "path", "d2-2annotate", "dgraphs"], default="path", required=True,
parser.add_argument('--type', '-t', choices=["d2", "path", "bg", "d2-2annotate", "dgraphs"], default="path", required=True,
help="Define the data type to evaluate. Must be 'd2' or 'path' or 'd2-2annotate' (Rayan's hack).")
parser.add_argument('--light-print', '-l', action='store_true',
help='Print only wrong nodes and paths')
......@@ -43,6 +43,20 @@ def save_graph(g, filename):
print("Wrong file format. Require graphml or gefx format", file=sys.stderr)
def transform_bg(graph):
idx = 0
node_names = {}
nx.set_node_attributes(graph, 0, 'score')
nx.set_node_attributes(graph, "", 'barcode_edges')
for node in graph.nodes():
graph.nodes[node]['udg'] = f"[{node}][][]"
node_names[node] = str(idx)
idx += 1
graph = nx.relabel_nodes(graph, node_names)
return graph
......@@ -655,7 +669,11 @@ def main():
elif args.type == "dgraphs":
udg_per_node = parse_udg_qualities(graph)
# print(udg_per_node)
elif args.type == "d2":
elif args.type == "bg" or args.type == "d2":
if args.type == "bg":
graph = transform_bg(graph)
components = list(nx.connected_components(graph))
components.sort(key=lambda x: -len(x))
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