U
    _k                     @   s   d Z ddlZdddZdS )zB
Conversion functions that operate on :class:`FeatureDB` classes.
    NexonIDc                    s   t  tjr|   t|j |dd}dd |D } fdd|D } j jd  j j	|dgd  j
 j j jd	t|d
tt|d
tt|g}dtt|d S )ay  
    Given a top-level feature (e.g., transcript), construct a BED12 entry
    Parameters
    ----------
    f : Feature object or string
        This is the top-level feature represented by one BED12 line.  For
        a canonical GFF or GTF, this will generally be a transcript.
    db : a FeatureDB object
        This is need to get the children for the feature
    child_type : str
        Featuretypes that will be represented by the BED12 "blocks".  Typically
        "exon".
    name_field : str
        Attribute to be used in the "name" field of the BED12 entry.  Usually
        "ID" for GFF; "transcript_id" for GTF.
    start)ZfeaturetypeZorder_byc                 S   s   g | ]}t |qS  )len.0ir   r   /lib/python3.8/site-packages/gffutils/convert.py
<listcomp>   s     zto_bed12.<locals>.<listcomp>c                    s   g | ]}|j  j  qS r   )r   r   fr   r
   r      s        .r   z0,0,0,	
)
isinstancesixZstring_typeslistchildrenZchromr   stopZ
attributesgetZscoreZstrandr   joinmapstr)r   ZdbZ
child_typeZ
name_fieldr   ZsizesZstartsZfieldsr   r   r
   to_bed12   s&    r   )r   r   )__doc__r   r   r   r   r   r
   <module>   s   