o
    Uݢg<                     @  sj   d dl mZ d dlmZ d dlZd dlZd dlm	Z	m
Z
 dd	d
ZdddZddddZ	ddddZdS )    )annotations)IterableN)ensure_binary
ensure_strpathstrreturn	list[str]c                 C  s   t tj| ddjS )zGets the headers of csv files with # as comments.

    Args:
        path (Union[str, bytes]): path of the csv

    Returns:
        List[str]: List of column names of probe_set.csv
    #)comment)listpdread_csvcolumns)r    r   `/oak/stanford/groups/akundaje/marinovg/programs/cellranger-9.0.1/lib/python/cellranger/csv_io.pyload_csv_columnnames   s   	r   csv_filestr | bytes%np.ndarray[int, np.dtype[np.object_]]c                 C  s,   t tjt| dgdtiddj }|S )Nr   F)usecolsZ
convertersZ	na_filter)npZ
atleast_1dr   r   r   r   valuesZsqueeze)r   Zrownamesr   r   r   load_csv_rownames   s   r   feature_intsIterable[int]Nonec                 C  sd   t | d#}|dur|t|d  |D ]
}|| d qW d   dS 1 s+w   Y  dS )zWrite a list of ints to a file.wN
)openwriter   )r   r   headerZoutfir   r   r   write_target_features_csv$   s   "r#   r!   str | int | Nonelist[int | str]c                 K  s\   |durt jt| fi |}||  }|S t jt| fdgdd|}|d  }|S )zRead feature IDs from a file.Nr   )r   r!   )r   r   r   tolist)r   r!   kwargsZfeature_idsr   r   r   read_target_features_csv-   s   r(   )r   r   r   r	   )r   r   r   r   )N)r   r   r   r   r   r   )r   r   r!   r$   r   r%   )
__future__r   collections.abcr   Znumpyr   Zpandasr   Zsixr   r   r   r   r#   r(   r   r   r   r   <module>   s   

	
