@@ -424,7 +424,6 @@ def build_stitcher_figure(logs: Iterable[events.EventType]) -> Figure:
424
424
temporary : Set [str ] = set ()
425
425
children_join_points : List [str ] = []
426
426
children_meet_points : List [str ] = []
427
- last_active : List [str ] = []
428
427
query_position_map : Dict [str , int ] = {}
429
428
430
429
def get_oldest_ancestors (recur , graph , ancestor_name ):
@@ -442,30 +441,27 @@ def get_oldest_ancestors(recur, graph, ancestor_name):
442
441
yield ancestor_name
443
442
return
444
443
445
- def reduced_closure (graph ):
444
+ def remove_intermediate_edges (graph ):
446
445
ret = {}
447
446
for parent , children in graph .items ():
448
447
lst = []
449
448
for child in children :
450
- for anc in get_oldest_ancestors (set (), graph , child ):
451
- if anc not in lst :
452
- lst .append (anc )
449
+ if all (other not in graph .get (child , []) for other in children ):
450
+ lst .append (child )
453
451
ret [parent ] = lst
454
452
return ret
455
453
456
454
def get_all_ancestors (recur , lst , graph , ancestor_name ):
457
- if ancestor_name in recur :
458
- assert RuntimeError (f"Recursion in graph { graph !r} " )
459
- else :
455
+ if ancestor_name not in recur :
460
456
recur = recur .copy ()
461
457
recur .add (ancestor_name )
462
458
463
- if ancestor_name not in lst :
464
- lst .append (ancestor_name )
459
+ if ancestor_name not in lst :
460
+ lst .append (ancestor_name )
465
461
466
- existing_ancestors = graph .get (ancestor_name , [])
467
- for existing in existing_ancestors :
468
- get_all_ancestors (recur , lst , graph , existing )
462
+ existing_ancestors = graph .get (ancestor_name , [])
463
+ for existing in existing_ancestors :
464
+ get_all_ancestors (recur , lst , graph , existing )
469
465
470
466
def transitive_closure (graph ):
471
467
ret = {}
@@ -593,10 +589,9 @@ def record_bad_contig(contig: GenotypedContig, lst: List[str]):
593
589
594
590
group_refs = {contig .group_ref : len (contig .ref_seq ) for contig in contig_map .values () if contig .ref_seq }
595
591
children_graph = inverse_graph (parent_graph )
596
- reduced_parent_graph = reduced_closure (parent_graph )
597
- reduced_children_graph = reduced_closure (children_graph )
598
592
transitive_parent_graph = transitive_closure (parent_graph )
599
593
transitive_children_graph = transitive_closure (children_graph )
594
+ reduced_parent_graph = remove_intermediate_edges (transitive_parent_graph )
600
595
eqv_parent_graph = reflexive_closure (symmetric_closure (transitive_parent_graph ))
601
596
sorted_roots = list (sorted (parent_name for
602
597
parent_name in contig_map
@@ -606,8 +601,9 @@ def record_bad_contig(contig: GenotypedContig, lst: List[str]):
606
601
if child_name not in children_graph ))
607
602
bad_contigs = anomaly + discarded + unknown
608
603
609
- eqv_morphism_graph = reflexive_closure (symmetric_closure (transitive_closure (morphism_graph )))
610
- reduced_morphism_graph = reduced_closure (morphism_graph )
604
+ transitive_morphism_graph = transitive_closure (morphism_graph )
605
+ reduced_morphism_graph = remove_intermediate_edges (transitive_morphism_graph )
606
+ eqv_morphism_graph = reflexive_closure (symmetric_closure (transitive_morphism_graph ))
611
607
612
608
for contig_name in overlaps_list :
613
609
temporary .add (contig_name )
0 commit comments