@@ -396,11 +396,12 @@ def __init__(self, group_name, transcripts_data, lineheight=5):
396396 self .group_name = group_name
397397 self .transcripts_data = transcripts_data # list of (parts, color, label, comment)
398398 self .lineheight = lineheight
399- self .a = START_POS + XOFFSET
399+ self .line_x_offset = 40 # 40 units to the left of 5'LTR start
400+ # Set component start to include the label area (80 units before 5'LTR start)
401+ self .a = 1 + XOFFSET - 80 # Start far enough left to include label
400402 self .b = END_POS + XOFFSET
401403 self .font_size = 9
402404 self .comment_font_size = 8
403- self .line_x_offset = 40 # 40 units to the left of 5'LTR start
404405 self .group_label_font_size = 10
405406
406407 # Calculate total height for all transcripts in the group
@@ -428,23 +429,25 @@ def draw(self, x=0, y=0, xscale=1.0):
428429 d = draw .Group (transform = "translate({} {})" .format (x * xscale , y ))
429430
430431 # Draw vertical line spanning the entire group height
431- # Position at 5'LTR start (position 1) minus offset, not START_POS
432432 line_x = (1 + XOFFSET - self .line_x_offset ) * xscale
433433 d .append (draw .Line (line_x , 0 , line_x , self .h ,
434434 stroke = 'black' , stroke_width = 2 ))
435435
436- # Draw group label vertically at the middle of the line
437- # Use absolute positioning (not scaled) to ensure label is visible
438- # Position to the left of the line
439- label_x = 20 # Fixed position 20 pixels from left edge
440- label_y = self .h / 2
436+ # Draw group label vertically centered on the line
437+ label_x = (1 + XOFFSET - self .line_x_offset - 10 ) * xscale
438+ # Calculate label text length (approximate, after rotation this is the vertical extent)
439+ label_text_length = len (self .group_name ) * self .group_label_font_size * CHAR_WIDTH_FACTOR
440+ # Position label so its center aligns with line center: start_position = center - length/2
441+ # Ensure label_y is at least 5 pixels from top to avoid clipping
442+ label_y = max (5 , (self .h / 2 ) - (label_text_length / 2 ))
443+ # Use text-anchor='start' so text extends downward (won't get clipped)
441444 d .append (draw .Text (text = self .group_name , font_size = self .group_label_font_size ,
442445 x = label_x , y = label_y ,
443446 font_family = 'sans-serif' , fill = 'black' ,
444- text_anchor = 'middle' ,
445- dominant_baseline = 'middle' ,
447+ text_anchor = 'start' ,
446448 transform = f'rotate(-90 { label_x } { label_y } )' ))
447449
450+
448451 # Draw all transcripts in this group (in reverse order to match expected top-to-bottom display)
449452 current_y = 0
450453 for i , (parts , color , label , comment ) in enumerate (self .transcripts_data ):
0 commit comments