@@ -188,15 +188,24 @@ def create_elements(
188188 # If haplotype doesn't have population data but we have a mapping,
189189 # manually compute population counts from sample_ids
190190 # Only recalculate if pop_counts is empty or only contains 'Unassigned'
191- if (not pop_counts or (len (pop_counts ) == 1 and 'Unassigned' in pop_counts )) and population_mapping and hap .sample_ids :
191+ if (
192+ (
193+ not pop_counts
194+ or (len (pop_counts ) == 1 and 'Unassigned' in pop_counts )
195+ )
196+ and population_mapping
197+ and hap .sample_ids
198+ ):
192199 pop_counts = {}
193200 for sample_id in hap .sample_ids :
194201 if sample_id in population_mapping :
195202 pop = population_mapping [sample_id ]
196203 pop_counts [pop ] = pop_counts .get (pop , 0 ) + 1
197204 else :
198205 # Track unassigned samples
199- pop_counts ['Unassigned' ] = pop_counts .get ('Unassigned' , 0 ) + 1
206+ pop_counts ['Unassigned' ] = (
207+ pop_counts .get ('Unassigned' , 0 ) + 1
208+ )
200209
201210 # Generate pie chart for all nodes with population data (including single population)
202211 if pop_counts and len (pop_counts ) >= 1 :
@@ -255,15 +264,27 @@ def create_elements(
255264 # Get population counts (using same logic as above)
256265 hover_pop_counts = hap .get_frequency_by_population ()
257266 # Only recalculate if hover_pop_counts is empty or only contains 'Unassigned'
258- if (not hover_pop_counts or (len (hover_pop_counts ) == 1 and 'Unassigned' in hover_pop_counts )) and population_mapping and hap .sample_ids :
267+ if (
268+ (
269+ not hover_pop_counts
270+ or (
271+ len (hover_pop_counts ) == 1
272+ and 'Unassigned' in hover_pop_counts
273+ )
274+ )
275+ and population_mapping
276+ and hap .sample_ids
277+ ):
259278 hover_pop_counts = {}
260279 for sample_id in hap .sample_ids :
261280 if sample_id in population_mapping :
262281 pop = population_mapping [sample_id ]
263282 hover_pop_counts [pop ] = hover_pop_counts .get (pop , 0 ) + 1
264283 else :
265284 # Track unassigned samples in hover text too
266- hover_pop_counts ['Unassigned' ] = hover_pop_counts .get ('Unassigned' , 0 ) + 1
285+ hover_pop_counts ['Unassigned' ] = (
286+ hover_pop_counts .get ('Unassigned' , 0 ) + 1
287+ )
267288
268289 if hover_pop_counts :
269290 hover_lines .append ('Populations:' )
@@ -384,6 +405,7 @@ def create_stylesheet(
384405 'style' : {
385406 'border-width' : 4 ,
386407 'border-color' : '#ff0000' ,
408+ 'z-index' : 999 , # Bring to front
387409 },
388410 },
389411 ]
0 commit comments