
    DUf                        d dl Z d dlZddlmZ ddlmZ d dlZ ej                     e j        dded           e j	        d	d
ded           e j	        dde
dd           e j	        ddd           e j	        dde
dd           e j	        dddd           e j	        ddedd           e j	        dddde
           d!                                                                                                             ZdS )"    N   )cli   )api	cool_path	COOL_PATH)metavartypenargsz--outputz-oz?Specify output file name to store the coverage in a tsv format.F)helpr
   requiredz--ignore-diagszjThe number of diagonals to ignore. By default, equals the number of diagonals ignored during IC balancing.T)r   r
   defaultshow_defaultz--storezAppend columns with coverage (cov_cis_raw, cov_tot_raw), or (cov_cis_clr_weight_name, cov_tot_clr_weight_name) if calculating balanced coverage, to the cooler bin table. If clr_weight_name=None, also stores total cis counts in the cooler info)r   is_flagz--chunksizezsSplit the contact matrix pixel records into equally sized chunks to save memory and/or parallelize. Default is 10^7g    cAz--bigwigz`Also save output as bigWig files for cis and total coverage with the names <output>.<cis/tot>.bw)r   r   r   z--clr_weight_namezLName of the weight column. Specify to calculate coverage of balanced cooler.z-pz--nproczQNumber of processes to split the work between. [default: 1, i.e. no process pool])r   r   r
   c                 "   t          j        |           }t          j                            ||||||          \  }	}
|                                dd         g d         }|Kddg}|	                    t                    ||d         <   |
                    t                    ||d         <   nPd| d	| g}|	                    t                    ||d         <   |
                    t                    ||d         <   |r|                    |d
dd           n%t          |                    d
dd                     |rNt          j        ||j        | d|d                    t          j        ||j        | d|d                    dS dS )au  
    Calculate the sums of cis and genome-wide contacts (aka coverage aka marginals) for
    a sparse Hi-C contact map in Cooler HDF5 format.
    Note that the sum(tot_cov) from this function is two times the number of reads
    contributing to the cooler, as each side contributes to the coverage.

    COOL_PATH : The paths to a .cool file with a balanced Hi-C map.

    )ignore_diags	chunksizenprocstoreclr_weight_nameN)chromstartendcov_cis_rawcov_tot_rawr   r   cov_cis_cov_tot_	Fnan)sepindexna_repz.cis.bw)value_fieldz.tot.bw)coolerCoolerr   coveragebinsastypeintfloatto_csvprintbioframe	to_bigwig
chromsizes)r   outputr   r   r   bigwigr   r   clrcis_covtot_covcoverage_tablestore_namess                S/var/www/html/software/conda/lib/python3.11/site-packages/cooltools/cli/coverage.pyr&   r&      s   N -	
"
"C|,,,)5PUgv -  GW
 XXZZ]#<#<#<=N$m4)0)<)<{1~&)0)<)<{1~&&3/335Q5Q5QR)0)>)>{1~&)0)>)>{1~&  Jf$eEJJJJ 	n##E%#HHIII  
N#A		
 	
 	
 	
 	N#A		
 	
 	
 	
 	
 	

 
    )clickr$    r   r   r-   commandargumentstroptionr)   r&    r8   r7   <module>r@      s                  3a   	J	   
<	   
7    
7	   
,   
	   
*	  2
 2
         t2
 2
 2
r8   