62
62
CONFIG .register ('map.paternal-background' , (0.833 , 0.845 , 0.92 , 1.0 ))
63
63
CONFIG .register ('map.legend-single-chromosome-y-offset' , 25 )
64
64
CONFIG .register ('map.show-centromere' ,0 )
65
+ CONFIG .register ('map.legend-char-height' ,12 )
66
+ CONFIG .register ('map.include-citation-notes' ,1 )
65
67
66
68
CONFIG .init ()
67
69
@@ -116,6 +118,7 @@ def main(self):
116
118
segmap .gender = active .gender
117
119
segmap .active = active
118
120
segmap .relationship = self .relationship
121
+ include_citation_notes = segmap ._config .get ('map.include-citation-notes' )
119
122
120
123
for assoc in active .get_person_ref_list ():
121
124
if assoc .get_relation () == 'DNA' :
@@ -142,13 +145,14 @@ def main(self):
142
145
assoc_handle = assoc .ref
143
146
self .write_chromo (line , side , rgb_color , assoc , note , segmap )
144
147
# Get Notes attached to Citation which is attached to the Association
145
- for citation_handle in assoc .get_citation_list ():
146
- citation = self .dbstate .db .get_citation_from_handle (citation_handle )
147
- for handle in citation .get_note_list ():
148
- note = self .dbstate .db .get_note_from_handle (handle )
149
- for line in note .get ().split ('\n ' ):
150
- assoc_handle = assoc .ref
151
- self .write_chromo (line , side , rgb_color , assoc , note , segmap )
148
+ if include_citation_notes :
149
+ for citation_handle in assoc .get_citation_list ():
150
+ citation = self .dbstate .db .get_citation_from_handle (citation_handle )
151
+ for handle in citation .get_note_list ():
152
+ note = self .dbstate .db .get_note_from_handle (handle )
153
+ for line in note .get ().split ('\n ' ):
154
+ assoc_handle = assoc .ref
155
+ self .write_chromo (line , side , rgb_color , assoc , note , segmap )
152
156
if len (segmap .segments ) > 0 :
153
157
segmap .show ()
154
158
self .vbox .pack_start (segmap , True , True , 0 )
@@ -158,12 +162,17 @@ def write_chromo(self, line, side, rgb_color, assoc, note, segmap):
158
162
if "\t " in line :
159
163
# Tabs are the field separators. Now determine THOUSEP and RADIXCHAR. Use Field 2 (Stop Pos) to see if there are THOUSEP there. Use Field 3 (SNPs) to see if there is a radixchar
160
164
field = line .split ('\t ' )
161
- if "," in field [2 ]:
162
- line = line .replace ("," , "" )
163
- elif "." in field [2 ]:
164
- line = line .replace ("." , "" )
165
- if "," in field [3 ]:
166
- line = line .replace ("," , "." )
165
+ if len (field ) > 3 :
166
+ if "," in field [2 ]:
167
+ line = line .replace ("," , "" )
168
+ elif "." in field [2 ]:
169
+ line = line .replace ("." , "" )
170
+ if "," in field [3 ]:
171
+ line = line .replace ("," , "." )
172
+ else :
173
+ associate = segmap .dbstate .db .get_person_from_handle (assoc .ref )
174
+ id_str = _ (_nd .display (associate ) )
175
+ print ("Skipping: " ,id_str ,line )
167
176
line = line .replace ("\t " , "," )
168
177
# If Tab is not the field separator, then comma is. And point is the radixchar.
169
178
field = line .split (',' )
@@ -239,6 +248,7 @@ def __init__(self):
239
248
self .paternal_background = self ._config .get ('map.paternal-background' )
240
249
self .legend_single_chromosome = self ._config .get ('map.legend-single-chromosome-y-offset' )
241
250
self .show_centromere = self ._config .get ('map.show-centromere' )
251
+ self .legend_char_height = self ._config .get ('map.legend-char-height' )
242
252
self ._config .save ()
243
253
self .chromosomesThirtySeven = (
244
254
('1' , 249250621 ),
@@ -477,7 +487,7 @@ def do_draw(self, cr):
477
487
label_width = width
478
488
offset_x = - (len (label )- 2 )* 6
479
489
cr .move_to (offset_x , i * 2 * (chr_height + spacing ) + offset + 7 )
480
- self .__chrrects .append ((offset_x , i * 2 * (chr_height + spacing ) + offset + 7 , 12 , chr_height ))
490
+ self .__chrrects .append ((offset_x , i * 2 * (chr_height + spacing ) + offset + 7 , chr_height , chr_height ))
481
491
PangoCairo .show_layout (cr , layout )
482
492
483
493
self .set_axis (_ ('Chr' ))
@@ -625,6 +635,7 @@ def do_draw(self, cr):
625
635
cr .set_source_rgba (* fg_color )
626
636
PangoCairo .show_layout (cr , layout )
627
637
legend_offset_y += chr_height + 2 * spacing
638
+ legend_chr_height = self .legend_char_height
628
639
chromo_count = - 1
629
640
row_num = 0
630
641
maximum = self .maximum
@@ -706,21 +717,21 @@ def do_draw(self, cr):
706
717
cr .set_source_rgba (* fg_color )
707
718
cr .stroke ()
708
719
# Legend
709
- cr .rectangle (legend_offset_x - chr_height - 2 * spacing ,
720
+ cr .rectangle (legend_offset_x - legend_chr_height - 2 * spacing ,
710
721
legend_offset_y + self .legend_swatch_offset_y ,
711
- chr_height ,
712
- chr_height )
722
+ legend_chr_height ,
723
+ legend_chr_height )
713
724
cr .set_source_rgba (rgb_color [0 ], rgb_color [1 ], rgb_color [2 ], 1 )
714
725
cr .fill_preserve ()
715
726
cr .stroke ()
716
727
layout = self .create_pango_layout (last_name )
717
728
cr .move_to (legend_offset_x , legend_offset_y )
718
- self .__legendrects .append ((legend_offset_x , legend_offset_y ,len (assoc_name ) * 6 , chr_height ))
729
+ self .__legendrects .append ((legend_offset_x , legend_offset_y ,len (assoc_name ) * 6 , legend_chr_height ))
719
730
self .__associates .append (associate )
720
731
self .__assoc_handle .append (handle )
721
732
self .__legend_str .append (last_name )
722
733
cr .set_source_rgba (* fg_color )
723
- legend_offset_y += chr_height + 2 * spacing
734
+ legend_offset_y += legend_chr_height + 2 * spacing
724
735
PangoCairo .show_layout (cr , layout )
725
736
# Segment Info
726
737
chr_offset = row_num * 2 * (chr_height + spacing ) + offset
@@ -748,22 +759,22 @@ def do_draw(self, cr):
748
759
if last_name != assoc_name :
749
760
last_name = assoc_name
750
761
751
- cr .rectangle (legend_offset_x - chr_height - 2 * spacing ,
762
+ cr .rectangle (legend_offset_x - legend_chr_height - 2 * spacing ,
752
763
legend_offset_y ,
753
- chr_height ,
754
- chr_height )
764
+ legend_chr_height ,
765
+ legend_chr_height )
755
766
cr .set_source_rgba (rgb_color [0 ], rgb_color [1 ], rgb_color [2 ], 1 / chr_mult )
756
767
cr .fill_preserve ()
757
768
cr .stroke ()
758
769
759
770
layout = self .create_pango_layout (last_name )
760
771
cr .move_to (legend_offset_x , legend_offset_y )
761
- self .__legendrects .append ((legend_offset_x , legend_offset_y ,len (assoc_name ) * 6 , chr_height ))
772
+ self .__legendrects .append ((legend_offset_x , legend_offset_y ,len (assoc_name ) * 6 , legend_chr_height ))
762
773
self .__associates .append (associate )
763
774
self .__assoc_handle .append (handle )
764
775
self .__legend_str .append (last_name )
765
776
cr .set_source_rgba (* fg_color )
766
- legend_offset_y += chr_height + 2 * spacing
777
+ legend_offset_y += legend_chr_height + 2 * spacing
767
778
PangoCairo .show_layout (cr , layout )
768
779
else : # Drawing all chromosome segments
769
780
for chromo , start , stop , side , cms , snp , assoc_name , rgb_color , associate , handle , note in self .segments :
@@ -796,22 +807,22 @@ def do_draw(self, cr):
796
807
# Legend entry
797
808
if last_name != assoc_name :
798
809
last_name = assoc_name
799
- cr .rectangle (legend_offset_x - chr_height - 2 * spacing ,
810
+ cr .rectangle (legend_offset_x - legend_chr_height - 2 * spacing ,
800
811
legend_offset_y + self .legend_swatch_offset_y ,
801
- chr_height ,
802
- chr_height )
812
+ legend_chr_height ,
813
+ legend_chr_height )
803
814
cr .set_source_rgba (rgb_color [0 ], rgb_color [1 ], rgb_color [2 ], 1 / chr_mult )
804
815
cr .fill_preserve ()
805
816
cr .stroke ()
806
817
807
818
layout = self .create_pango_layout (last_name )
808
819
cr .move_to (legend_offset_x , legend_offset_y )
809
- self .__legendrects .append ((legend_offset_x , legend_offset_y ,len (assoc_name ) * 6 , chr_height ))
820
+ self .__legendrects .append ((legend_offset_x , legend_offset_y ,len (assoc_name ) * 6 , legend_chr_height ))
810
821
self .__associates .append (associate )
811
822
self .__assoc_handle .append (handle )
812
823
self .__legend_str .append (last_name )
813
824
cr .set_source_rgba (* fg_color )
814
- legend_offset_y += chr_height + 2 * spacing
825
+ legend_offset_y += legend_chr_height + 2 * spacing
815
826
PangoCairo .show_layout (cr , layout )
816
827
817
828
self .set_size_request (- 1 , bottom + height + 5 )
0 commit comments