o
    Nrf%                     @   s`  d dl Z d dlm  mZ d dlZd dlmZ d dl	Z	d dl
mZ d dl
mZ d dl
mZ d dlmZ e  e de jddd	d
e jdddd
e jdddd
e jdddd
e jdddd
e jdddd
e jddddde jdddd
e jddddde jdddd
									d&d d!Z									d&d"d#Zd$d% ZdS )'    N)fill_filetype_and_datatype)import_file)get_temp_dir)_startfilenamez	--hg-namedefaultz8The name of the higlass container to import this file to)r   helpz
--filetypez(The type of file to ingest (e.g. cooler)z
--datatypez0The data type of in the input file (e.g. matrix)z
--assemblyz(The assembly that this data is mapped toz--namezThe name to use for this filez--uidzThe uuid to use for this filez--no-uploadTzYDo not copy the file to the media directory. File must already be in the media directory.)r   Zis_flagr   z--chromsizes-filenamez8A set of chromosome sizes to use for bed and bedpe filesz--has-headerFzYDoes the input file have column header information (only relevant for bed or bedpe files)z--project-namez;Group this tileset with others by specifying a project namec                 C   s    t | |||||||||	|
 dS )z
    Ingest a dataset
    N)_ingest)r   hg_namefiletypedatatypeassemblynamechromsizes_filename
has_headeruid	no_uploadproject_name r   ^/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/higlass_manage/ingest.pyingest   s   8r   c              
   C   s   zt | W n ty   td t|d Y nw |	s/t| s/t| s/td| tjd d S t	| ||\}}t |}t
| |||||	|\}}t||||||||	|
	S )Nz HiGlass not running. Starting...)r
   zFile not found:file)r   	Exceptionprintr   opexistsislinksysstderrr   aggregate_filer   )r   r
   r   r   r   r   r   r   r   r   r   temp_dir	to_importr   r   r   r	   T   s>   
r	   c           	      C   s  |dkrE|rt dtjd|d u r|d u rtdtjd d S t|t| d }td tj	| ||d|d dd |d	d
d |}d}||fS |dkr|rRt dtjd|d u rc|d u rctdtjd d S t|| d }td
| tj| ||d|d d|d
d	 |}d}||fS | |fS )NZbedfilezcBedfile files need to be aggregated and cannot be linked. Consider not using the --link-file optionr   zAn assembly or set of chromosome sizes is required when importing bed files. Please specify one or the other using the --assembly or --chromsizes-filename parametersz.beddbzAggregating bedfilerandom2   r   i   )importance_columnr   
chromosomemax_per_tile	delimiterr   offset	tile_sizeZbeddbZbedpezaBedpe files need to be aggregated and cannot be linked. Consider not using the --link-file optionz.bed2ddbz"Aggregating bedpe (output_file: {})r%   r   r&   r'   r   r*   Zbed2ddb)r   r   r   r   r   joinntpathbasenameccaZ_bedfileformatZ_bedpe)	r   r   r   r   r   r   Ztmp_dirZoutput_filer"   r   r   r   r       sv   r    )	NNNNNFNNN)ZclickZclodius.cli.aggregatecliZ	aggregater.   r,   Zos.pathpathr   r   Zhiglass_manage.commonr   r   r   Zhiglass_manage.startr   commandargumentoptionr   r	   r    r   r   r   r   <module>   s    ""
3