
    Ri-                     h    d Z ddlmZ ddlmZ ddlmZ  ej                  ddd      Z G d d      Z	y	)
zTrack module.

Provides:
 - Track - Container for a single track on the diagram, containing
   FeatureSet and GraphSet objects

For drawing capabilities, this module uses reportlab to draw and write
the diagram: http://www.reportlab.com
    )colors   )
FeatureSet)GraphSetg333333?c                       e Zd ZdZddddddddeddej                  ddd	d
dddddddddddfdZd ZddZ	d Z
d Zd Zd ZddZd Zd Zy)Tracka	  Track.

    Attributes:
     - height    Int describing the relative height to other trackscale_fontsizes
       in the diagram
     - name      String describing the track
     - hide      Boolean, 0 if the track is not to be drawn
     - start, end    Integers (or None) specifying start/end to draw just
       a partial track.
     - greytrack     Boolean, 1 if a grey background to the track is to be
       drawn
     - greytrack_labels  Int describing how many track-identifying labels
       should be placed on the track at regular intervals
     - greytrack_font    String describing the font to use for the greytrack
       labels
     - greytrack_fontsize    Int describing the font size to display the
       labels on the grey track
     - greytrack_font_rotation   Int describing the angle through which to
       rotate the grey track labels (Linear only)
     - greytrack_font_color     colors.Color describing the color to draw
       the grey track labels
     - scale     Boolean, 1 if a scale is to be drawn on the track
     - scale_format  String, defaults to None, when scale values are written
       as numerals.  Setting this to 'SInt' invokes SI
       unit-like multiples, such as Mbp, Kbp and so on.
     - scale_color  colors.Color to draw the elements of the scale
     - scale_font    String describing the font to use for the scale labels
     - scale_fontsize    Int describing the size of the scale label font
     - scale_fontangle   Int describing the angle at which to draw the scale
       labels (linear only)
     - scale_ticks       Boolean, 1 if ticks should be drawn at all on the
       scale
     - scale_largeticks  Float (0->1) describing the height of large
       scale ticks relative to the track height.
     - scale_smallticks  Float (0->1) describing the height of large
       scale ticks relative to the track height.
     - scale_largetick_interval  Int, describing the number of bases that
       should separate large ticks
     - scale_smalltick_interval  Int, describing the number of bases that
       should separate small ticks
     - scale_largetick_labels    Boolean describing whether position labels
       should be written over large ticks
     - scale_smalltick_labels    Boolean describing whether position labels
       should be written over small ticks
     - axis_labels       Boolean describing whether the value labels should
       be placed on the Y axes

    Nr   r         	Helvetica   -   g      ?g333333?g    .Ag     @c                    ||}	||}d| _         i | _        || _        |t        |      | _        nd| _        || _        || _        || _        || _        || _	        || _
        || _        || _        |	| _        |
| _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        y)a(
  Initialize.

        Arguments:
         - height    Int describing the relative height to other tracks in the
           diagram
         - name      String describing the track
         - hide      Boolean, 0 if the track is not to be drawn
         - greytrack     Boolean, 1 if a grey background to the track is to be
           drawn
         - greytrack_labels  Int describing how many track-identifying labels
           should be placed on the track at regular intervals
         - greytrack_font    String describing the font to use for the greytrack
           labels
         - greytrack_fontsize    Int describing the font size to display the
           labels on the grey track
         - greytrack_font_rotation   Int describing the angle through which to
           rotate the grey track labels (Linear only)
         - greytrack_font_color     colors.Color describing the color to draw
           the grey track labels (overridden by backwards compatible argument
           with UK spelling, colour).
         - scale     Boolean, 1 if a scale is to be drawn on the track
         - scale_color  colors.Color to draw the elements of the scale
           (overridden by backwards compatible argument with UK
           spelling, colour).
         - scale_font    String describing the font to use for the scale labels
         - scale_fontsize    Int describing the size of the scale label font
         - scale_fontangle   Int describing the angle at which to draw the scale
           labels (linear only)
         - scale_ticks       Boolean, 1 if ticks should be drawn at all on the
           scale
         - scale_largeticks  Float (0->1) describing the height of large
           scale ticks relative to the track height.
         - scale_smallticks  Float (0->1) describing the height of large
           scale ticks relative to the track height.
         - scale_largetick_interval  Int, describing the number of bases that
           should separate large ticks
         - scale_smalltick_interval  Int, describing the number of bases that
           should separate small ticks
         - scale_largetick_labels    Boolean describing whether position labels
           should be written over large ticks
         - scale_smalltick_labels    Boolean describing whether position labels
           should be written over small ticks
         - name          String to help identify the track
         - height        Relative height to draw the track
         - axis_labels       Boolean describing whether the value labels should
           be placed on the Y axes

        Nr   r   )_next_id_setsheightstrnamehidestartend	greytrackgreytrack_labelsgreytrack_fontsizegreytrack_fontgreytrack_font_rotationgreytrack_fontcolorscalescale_formatscale_color
scale_fontscale_fontsizescale_fontanglescale_ticksscale_largeticksscale_smallticksscale_largetick_intervalscale_smalltick_intervalscale_largetick_labelsscale_smalltick_labelsaxis_labels)selfr   r   r   r   r   r   r   r   greytrack_font_colorr   r   r   r    r!   r"   r$   r#   r%   r&   r'   r(   r)   r*   r   r   greytrack_font_colourscale_colours                               Y/home/agent/.friday_env/lib/python3.12/site-packages/Bio/Graphics/GenomeDiagram/_Track.py__init__zTrack.__init__R   s   ^ !,#8 #&K
 D	DIDI	
 # 0"4,'>$#7  
(&$,.& 0 0(@%(@%&<#&<#&    c                     | j                   |_        | |_        || j                  | j                   <   | xj                   dz  c_         y)z=Add a preexisting FeatureSet or GraphSet object to the track.r   N)r   idparentr   )r+   sets     r/   add_setzTrack.add_set   s4    
$'

4==!r1   c                     t         t        d} ||          }|D ]  }t        ||||           | j                  |_        | |_        || j                  | j                  <   | xj                  dz  c_        |S )zCreate a new FeatureSet or GraphSet object.

        Create a new FeatureSet or GraphSet object, add it to the
        track, and return for user manipulation
        )featuregraphr   )r   r   setattrr   r3   r4   r   )r+   typeargs	type_dictr5   keys         r/   new_setzTrack.new_set   sr     !+X>	io 	)CCd3i(	)
$'

4==!
r1   c                     | j                   |= y)z1Remove the set with the passed id from the track.Nr   )r+   set_ids     r/   del_setzTrack.del_set   s    JJvr1   c                 H    t        | j                  j                               S )z(Return the sets contained in this track.)listr   valuesr+   s    r/   get_setszTrack.get_sets   s    DJJ%%'((r1   c                 H    t        | j                  j                               S )z3Return the ids of all sets contained in this track.)rE   r   keysrG   s    r/   get_idszTrack.get_ids   s    DJJOO%&&r1   c                    g g }}| j                   |j                  | j                          | j                  |j                  | j                         | j                  j	                         D ]7  }|j                         \  }}|j                  |       |j                  |       9 |rt        |      }nd}|rt        |      }||fS d}||fS )z@Return the lowest and highest base (or mark) numbers as a tuple.N)r   appendr   r   rF   rangeminmax)r+   lowshighsr5   lowhighs         r/   rN   zTrack.range   s    "e::!KK

#88LL"::$$& 	C		ICKKLL	 d)CCu:D Dy DDyr1   c                    |s|  S d| j                    d| j                   dg}|j                  dt        | j                        z         | j                  D ]#  }|j                  d| j                  |           % dj                  |      S )zReturn a formatted string with information about the track.

        Arguments:
         - verbose - Boolean indicating whether a short or complete
           account of the track is required

        
<: >%d setszset: 
	__class__r   rM   lenr   join)r+   verboseoutstrr>   s       r/   	to_stringzTrack.to_string  s     VDNN+2dii[:;FMM)c$**o56zz 9djjo%678999V$$r1   c                      | j                   |   S )z"Return the set with the passed id.rA   )r+   r>   s     r/   __getitem__zTrack.__getitem__  s    zz#r1   c                     d| j                    d| j                   dg}|j                  dt        | j                        z         dj                  |      S )z;Return a formatted string with information about the Track.rV   rW   rX   rY   rZ   r[   )r+   r`   s     r/   __str__zTrack.__str__  sJ    'r$))A67i#djj/12yy  r1   )r8   )r   )__name__
__module____qualname____doc___greyr   blackr0   r6   r?   rC   rH   rK   rN   ra   rc   re    r1   r/   r   r       s    /f " !"LL!$!$  "9w'r )'*%"!r1   r   N)
ri   reportlab.libr   _FeatureSetr   	_GraphSetr   Colorrj   r   rl   r1   r/   <module>rq      s7    ! $ S#s#|! |!r1   