@@ -516,19 +516,15 @@ def graph_sum(graph_a, graph_b):
516
516
def symmetric_closure (graph ):
517
517
return graph_sum (graph , inverse_graph (graph ))
518
518
519
- def hits_to_insertions (contig : GenotypedContig , hits : List [CigarHit ]):
520
- for hit in hits :
521
- # yield CigarHit.from_default_alignment(q_st=0, q_ei=hit.q_st - 1, r_st=hit.r_st, r_ei=hit.r_st - 1)
522
- yield from hit .insertions ()
523
- # yield CigarHit.from_default_alignment(q_st=hit.q_ei + 1, q_ei=len(contig.seq) - 1, r_st=hit.r_ei + 1, r_ei=hit.r_ei)
524
-
525
- def record_unaligned_parts (contig : GenotypedContig , connected : List [CigarHit ]):
526
- all_insertions = list (hits_to_insertions (contig , connected ))
527
- nonempty_insertions = [gap for gap in all_insertions if gap .query_length > 0 ]
528
- for insertion in nonempty_insertions :
529
- query = dataclasses .replace (contig , name = f"u{ len (complete_contig_map )} " , seq = 'A' * insertion .query_length )
519
+ def record_unaligned_parts (result : AlignedContig , original : AlignedContig ):
520
+ length = abs (result .alignment .query_length - original .alignment .query_length )
521
+ if length > 0 :
522
+ q_st = max (result .alignment .q_st , original .alignment .q_st )
523
+ r_st = min (result .alignment .r_st , original .alignment .r_st )
524
+ insertion = CigarHit .from_default_alignment (q_st = q_st , q_ei = q_st + length - 1 , r_st = r_st , r_ei = r_st - 1 )
525
+ query = dataclasses .replace (original , name = f"u{ len (complete_contig_map )} " , seq = 'A' * insertion .query_length )
530
526
fake_aligned = AlignedContig .make (query = query , alignment = insertion , strand = "forward" )
531
- record_contig (fake_aligned , [contig ])
527
+ record_contig (fake_aligned , [original ])
532
528
record_bad_contig (fake_aligned , unaligned )
533
529
record_alive (fake_aligned )
534
530
@@ -583,16 +579,17 @@ def record_rstrip(result: GenotypedContig, original: GenotypedContig):
583
579
record_contig (event .result , [event .contig ])
584
580
record_alive (event .result )
585
581
elif isinstance (event , events .HitNumber ):
586
- record_unaligned_parts (event .contig , event .connected )
587
582
record_alive (event .contig )
588
583
elif isinstance (event , events .Munge ):
589
584
record_contig (event .result , [event .left , event .right ])
590
585
elif isinstance (event , events .LStrip ):
591
586
record_contig (event .result , [event .original ])
592
587
record_lstrip (event .result , event .original )
588
+ record_unaligned_parts (event .result , event .original )
593
589
elif isinstance (event , events .RStrip ):
594
590
record_contig (event .result , [event .original ])
595
591
record_rstrip (event .result , event .original )
592
+ record_unaligned_parts (event .result , event .original )
596
593
elif isinstance (event , events .Overlap ):
597
594
overlaps_list .append (event .left_overlap .name )
598
595
overlaps_list .append (event .right_overlap .name )
@@ -793,10 +790,11 @@ def intervals_overlap(x, y):
793
790
all_other = [contig_map [name ] for name in aligned_names ]
794
791
aligned_other = [contig for contig in all_other if isinstance (contig , AlignedContig )]
795
792
current = contig_map [contig_name ]
796
- if isinstance (current , AlignedContig ) and \
797
- not any (overlaps (current , other ) for other in aligned_other ):
798
- todo_names .append (contig_name )
799
- discarded .append (contig_name )
793
+ # if isinstance(current, AlignedContig) and \
794
+ # not any(overlaps(current, other) for other in aligned_other):
795
+ # if any(aligned in parent_graph.get(contig_name, []) for aligned in aligned_names):
796
+ todo_names .append (contig_name )
797
+ discarded .append (contig_name )
800
798
801
799
todo_names = list (sorted (todo_names , key = lambda name : query_position_map .get (name , (- 1 , - 1 ))))
802
800
for k , child_name in enumerate (todo_names ):
0 commit comments