o
    Nrf                     @   s   d dl Z ddlmZ ddlmZ ddlmZ e e jde j	dd	d
e jdde j	dd	de j
dddeeddde j
ddedde j
dddddddd ZdS )    N   )merge_coolers   )cliparse_field_paramout_pathF)exists)typein_paths)nargsr
   z--chunksizez-cz7Size of the merge buffer in number of pixel table rows.g    sAT)helpr
   defaultZshow_defaultz--fieldzSpecify the names of value columns to merge as '<name>'. Repeat the `--field` option for each one. Use '<name>,dtype=<dtype>' to specify the dtype. Include ',agg=<agg>' to specify an aggregation function different from 'sum'.)r   r
   Zmultiplez--appendz-az_Pass this flag to append the output cooler to an existing file instead of overwriting the file.)Zis_flagr   r   c           
   	   C   s   t |r(dd |D }t| \}}}}	dd t||D }dd t||	D }	n	dgdd}}}	t| |||||	|r<dnd	d
 dS )a  
    Merge multiple coolers with identical axes.

    OUT_PATH : Output file path or URI.

    IN_PATHS : Input file paths or URIs of coolers to merge.

    **Notes**

    Data columns merged:

        pixels/bin1_id, pixels/bin2_id, pixels/<value columns>

    Data columns preserved:

        chroms/name, chroms/length
        bins/chrom, bins/start, bins/end

    Additional columns in the the input files are not transferred to the output.

    c                 S   s   g | ]}t |d dqS )F)Zincludes_colnumr   ).0arg r   Y/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/cooler/cli/merge.py
<listcomp>=   s    zmerge.<locals>.<listcomp>c                 S      i | ]\}}|d ur||qS Nr   )r   coldtr   r   r   
<dictcomp>A       zmerge.<locals>.<dictcomp>c                 S   r   r   r   )r   r   fr   r   r   r   B   r   countNaw)Zmergebufcolumnsdtypesaggmode)lenzipr   )
r   r   	chunksizefieldappendZfield_specifiersr   _r    r!   r   r   r   merge   s"   4

r)   )Zclickreducer    r   Z_utilr   commandargumentPathoptionintstrr)   r   r   r   r   <module>   s:    	