@@ -792,13 +792,6 @@ def is_ancestor(contig_name, other_names):
792
792
793
793
final_children_mapping [parent_name ] = children
794
794
795
- def overlaps (self , other ) -> bool :
796
- def intervals_overlap (x , y ):
797
- return x [0 ] <= y [1 ] and x [1 ] >= y [0 ]
798
-
799
- return intervals_overlap ((self .alignment .q_st , self .alignment .q_ei ),
800
- (other .alignment .q_st , other .alignment .q_ei ))
801
-
802
795
name_map = {}
803
796
for i , (parent , children ) in enumerate (sorted (final_children_mapping .items (), key = lambda p : p [0 ])):
804
797
name_map [parent ] = f"{ i + 1 } "
@@ -836,7 +829,7 @@ def get_neighbours(part, lookup):
836
829
yield contig_map [maybe_name ]
837
830
838
831
def get_final_version (contig ):
839
- name = reduced_morphism_graph .get (contig .name , [contig .name ])[ 0 ] # FIXME: why 0???
832
+ [ name ] = reduced_morphism_graph .get (contig .name , [contig .name ])
840
833
return contig_map [name ]
841
834
842
835
def get_neighbour (part , lookup ):
@@ -984,8 +977,7 @@ def add_section(title: str) -> None:
984
977
# Drawing part #
985
978
################
986
979
987
- landmarks_path = (Path (__file__ ).parent .parent / "data" /
988
- "landmark_references.yaml" )
980
+ landmarks_path = (Path (__file__ ).parent .parent / "data" / "landmark_references.yaml" )
989
981
landmark_groups = yaml .safe_load (landmarks_path .read_text ())
990
982
projects = ProjectConfig .loadDefault ()
991
983
figure = Figure ()
@@ -1130,24 +1122,12 @@ def add_section(title: str) -> None:
1130
1122
if anomaly :
1131
1123
add_section ("anomaly:" )
1132
1124
for parent_name in sorted_roots :
1133
- contigs = final_children_mapping .get (parent_name , [])
1134
- for contig_name in contigs :
1135
- if contig_name not in anomaly :
1136
- continue
1137
-
1138
- contig = contig_map [contig_name ]
1139
- (a_r_st , a_r_ei , f_r_st , f_r_ei ) = get_contig_coordinates (contig )
1140
- if isinstance (contig , AlignedContig ):
1141
- colour = "lightgray"
1142
- if contig .strand == "reverse" :
1143
- figure .add (Arrow (a_r_ei + position_offset , a_r_st + position_offset , elevation = - 20 , h = 1 ))
1144
- else :
1145
- figure .add (Arrow (a_r_st + position_offset , a_r_ei + position_offset , elevation = - 20 , h = 1 ))
1146
- else :
1147
- colour = "yellow"
1148
-
1149
- name = name_map .get (contig_name , contig_name )
1150
- figure .add (Track (a_r_st + position_offset , a_r_ei + position_offset , color = colour , label = name ))
1125
+ parts_names = final_children_mapping [parent_name ]
1126
+ parts_names = [name for name in parts_names if name in anomaly ]
1127
+ parts = [contig_map [name ] for name in parts_names ]
1128
+ parts = [part for part in parts if part .group_ref == group_ref ]
1129
+ for part in parts :
1130
+ figure .add (Multitrack (list (get_tracks ([part ]))))
1151
1131
1152
1132
###########
1153
1133
# Unknown #
@@ -1156,17 +1136,11 @@ def add_section(title: str) -> None:
1156
1136
if unknown :
1157
1137
add_section ("unknown:" )
1158
1138
for parent_name in sorted_roots :
1159
- contigs = final_children_mapping .get (parent_name , [])
1160
- for contig_name in contigs :
1161
- if contig_name not in unknown :
1162
- continue
1163
-
1164
- contig = contig_map [contig_name ]
1165
- r_st = 0
1166
- r_ei = len (contig .seq )
1167
- colour = "yellow"
1168
- name = name_map .get (contig_name , contig_name )
1169
- figure .add (Track (r_st + position_offset , r_ei + position_offset , color = colour , label = name ))
1139
+ parts_names = final_children_mapping [parent_name ]
1140
+ parts_names = [name for name in parts_names if name in unknown ]
1141
+ parts = [contig_map [name ] for name in parts_names ]
1142
+ for part in parts :
1143
+ figure .add (Multitrack (list (get_tracks ([part ]))))
1170
1144
1171
1145
if not figure .elements :
1172
1146
figure .add (Track (0 , max_position , label = '.' , color = 'none' ))
0 commit comments