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

create a molecule proxy in the path creation

parent c0bf8e4c
......@@ -48,6 +48,7 @@ def main():
solution.save_path_in_graph(f"{args.out_prefix}_d2_path.gexf")
solution.save_path(f"{args.out_prefix}_path.gexf")
solution.save_barcode_path(f"{args.out_prefix}_barcode_count.gexf")
print("Solution saved")
# from d2_path import d2_path_to_barcode_path
......
......@@ -282,12 +282,12 @@ def filter_dominated(d_graphs, overall=False, in_place=True):
""" Filter the d-graphs by node. In a list of d-graph centered on a node n, if a d-graph is
completly included in another and have a highest distance score to the optimal, then it is
completely included in another and have a highest distance score to the optimal, then it is
filtered out.
@param d_graphs All the d-graphs to filter, sorted by central node.
@param in_place If true, modify the content of d_graph with the filtered version. If False,
copy all the content in a new dictionnary.
@return The filtered dictionnary of d-graph per node.
copy all the content in a new dictionary.
@return The filtered dictionary of d-graph per node.
"""
def local_domination_filter(d_graphs, in_place=True):
filtered = d_graphs if in_place else {}
......
import random
from d2_path import Path
import networkx as nx
class Optimizer:
......@@ -54,3 +55,30 @@ class Solution(Path):
self.clear()
self.add_path([random_udg])
""" Only respect counts for now
"""
def to_barcode_path(self):
barcode_per_position = [set(udg.to_list()) for udg in self]
compressed_barcodes = []
for idx, barcodes in enumerate(barcode_per_position):
for barcode in barcodes:
offset = 1
while idx + offset < len(barcode_per_position) and barcode in barcode_per_position[idx + offset]:
barcode_per_position[idx + offset].remove(barcode)
offset += 1
compressed_barcodes.append(barcode)
return compressed_barcodes
def save_barcode_path(self, filename):
barcodes = self.to_barcode_path()
G = nx.Graph()
for idx, barcode in enumerate(barcodes):
G.add_node(idx)
G.nodes[idx]["center"] = barcode
nx.write_gexf(G, filename)
Markdown is supported
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