o
    Rŀg-                     @   sH   d Z ddlmZ ddlmZ ddlmZ edddZG dd dZ	d	S )
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                   @   s   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dZdd Zd#ddZ	dd Z
dd Zdd Zdd Zd$ddZdd  Zd!d" ZdS )%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                 C   s   |dur|}	|dur|}d| _ i | _|| _|durt|| _nd| _|| _|| _|| _|| _|| _	|| _
|| _|| _|	| _|
| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _dS )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_colour r,   U/var/www/html/myenv/lib/python3.10/site-packages/Bio/Graphics/GenomeDiagram/_Track.py__init__R   sB   O
zTrack.__init__c                 C   s,   | j |_| |_|| j| j < |  j d7  _ dS )z=Add a preexisting FeatureSet or GraphSet object to the track.r   N)r   idparentr   )r(   setr,   r,   r-   add_set   s   zTrack.add_setfeaturec                 K   sZ   t td}||  }|D ]
}t||||  q| j|_| |_|| j| j< |  jd7  _|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
        )r3   graphr   )r   r   setattrr   r/   r0   r   )r(   typeargs	type_dictr1   keyr,   r,   r-   new_set   s   

zTrack.new_setc                 C   s   | j |= dS )z1Remove the set with the passed id from the track.Nr   )r(   set_idr,   r,   r-   del_set   s   zTrack.del_setc                 C      t | j S )z(Return the sets contained in this track.)listr   valuesr(   r,   r,   r-   get_sets      zTrack.get_setsc                 C   r>   )z3Return the ids of all sets contained in this track.)r?   r   keysrA   r,   r,   r-   get_ids   rC   zTrack.get_idsc                 C   s   g g }}| j dur|| j  | jdur|| j | j D ]}| \}}|| || q |r:t|}nd}|rFt|}||fS d}||fS )z@Return the lowest and highest base (or mark) numbers as a tuple.N)r   appendr   r   r@   rangeminmax)r(   lowshighsr1   lowhighr,   r,   r-   rG      s"   




zTrack.rangec                 C   sb   |s|  S d| j  d| j dg}|dt| j  | jD ]}|d| j|   qd|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   rF   lenr   join)r(   verboseoutstrr9   r,   r,   r-   	to_string  s   

zTrack.to_stringc                 C   s
   | j | S )z"Return the set with the passed id.r;   )r(   r9   r,   r,   r-   __getitem__  s   
zTrack.__getitem__c                 C   s6   d| j  d| j dg}|dt| j  d|S )z;Return a formatted string with information about the Track.rN   rO   rP   rQ   rR   rS   )r(   rX   r,   r,   r-   __str__  s   
zTrack.__str__)r3   )r   )__name__
__module____qualname____doc___greyr   blackr.   r2   r:   r=   rB   rE   rG   rY   rZ   r[   r,   r,   r,   r-   r       sN    3
y

r   N)
r_   reportlab.libr   _FeatureSetr   	_GraphSetr   Colorr`   r   r,   r,   r,   r-   <module>   s   
