@@ -971,12 +971,17 @@ def get_all_arrows(group_ref, labels):
971
971
label = LeftLabel (text = f"discards:" , x = 0 , font_size = 12 )
972
972
pos = position_offset / 2
973
973
figure .add (Track (pos , pos , h = 40 , label = label ))
974
- for contig_name in discarded :
975
- contig = contig_map [contig_name ]
976
- (r_st , r_ei , f_r_st , f_r_ei ) = get_contig_coordinates (contig )
977
- name = name_mappings .get (contig .name , contig .name )
978
- figure .add (Arrow (r_st , r_ei , elevation = - 20 , h = 1 ))
979
- figure .add (Track (f_r_st , f_r_ei , label = name ))
974
+ for parent_name in sorted_roots :
975
+ contigs = final_parent_mapping .get (parent_name , [])
976
+ for contig_name in contigs :
977
+ if contig_name not in discarded :
978
+ continue
979
+
980
+ contig = contig_map [contig_name ]
981
+ (r_st , r_ei , f_r_st , f_r_ei ) = get_contig_coordinates (contig )
982
+ name = name_mappings .get (contig .name , contig .name )
983
+ figure .add (Arrow (r_st , r_ei , elevation = - 20 , h = 1 ))
984
+ figure .add (Track (f_r_st , f_r_ei , label = name ))
980
985
981
986
#############
982
987
# Anomalies #
@@ -986,20 +991,25 @@ def get_all_arrows(group_ref, labels):
986
991
label = LeftLabel (text = f"anomaly:" , x = 0 , font_size = 12 )
987
992
pos = position_offset / 2
988
993
figure .add (Track (pos , pos , h = 40 , label = label ))
989
- for contig_name in anomaly :
990
- contig = contig_map [contig_name ]
991
- (a_r_st , a_r_ei , f_r_st , f_r_ei ) = get_contig_coordinates (contig )
992
- if isinstance (contig , AlignedContig ):
993
- colour = "lightgray"
994
- if contig .strand == "reverse" :
995
- figure .add (Arrow (a_r_ei , a_r_st , elevation = - 20 , h = 1 ))
994
+ for parent_name in sorted_roots :
995
+ contigs = final_parent_mapping .get (parent_name , [])
996
+ for contig_name in contigs :
997
+ if contig_name not in anomaly :
998
+ continue
999
+
1000
+ contig = contig_map [contig_name ]
1001
+ (a_r_st , a_r_ei , f_r_st , f_r_ei ) = get_contig_coordinates (contig )
1002
+ if isinstance (contig , AlignedContig ):
1003
+ colour = "lightgray"
1004
+ if contig .strand == "reverse" :
1005
+ figure .add (Arrow (a_r_ei , a_r_st , elevation = - 20 , h = 1 ))
1006
+ else :
1007
+ figure .add (Arrow (a_r_st , a_r_ei , elevation = - 20 , h = 1 ))
996
1008
else :
997
- figure .add (Arrow (a_r_st , a_r_ei , elevation = - 20 , h = 1 ))
998
- else :
999
- colour = "red"
1009
+ colour = "red"
1000
1010
1001
- name = name_mappings .get (contig .name , contig .name )
1002
- figure .add (Track (a_r_st , a_r_ei , color = colour , label = name ))
1011
+ name = name_mappings .get (contig .name , contig .name )
1012
+ figure .add (Track (a_r_st , a_r_ei , color = colour , label = name ))
1003
1013
1004
1014
###########
1005
1015
# Unknown #
@@ -1009,13 +1019,18 @@ def get_all_arrows(group_ref, labels):
1009
1019
label = LeftLabel (text = f"unknown:" , x = 0 , font_size = 12 )
1010
1020
pos = position_offset / 2
1011
1021
figure .add (Track (pos , pos , h = 40 , label = label ))
1012
- for contig_name in unknown :
1013
- contig = contig_map [contig_name ]
1014
- r_st = position_offset
1015
- r_ei = position_offset + len (contig .seq )
1016
- colour = "red"
1017
- name = name_mappings .get (contig .name , contig .name )
1018
- figure .add (Track (r_st , r_ei , color = colour , label = name ))
1022
+ for parent_name in sorted_roots :
1023
+ contigs = final_parent_mapping .get (parent_name , [])
1024
+ for contig_name in contigs :
1025
+ if contig_name not in unknown :
1026
+ continue
1027
+
1028
+ contig = contig_map [contig_name ]
1029
+ r_st = position_offset
1030
+ r_ei = position_offset + len (contig .seq )
1031
+ colour = "red"
1032
+ name = name_mappings .get (contig .name , contig .name )
1033
+ figure .add (Track (r_st , r_ei , color = colour , label = name ))
1019
1034
1020
1035
if not figure .elements :
1021
1036
figure .add (Track (1 , max_position , label = 'No contigs found.' , color = 'none' ))
0 commit comments