o
    Uݢg                     @  sz   U d dl mZ d dlZd dlmZ d dlmZ erd dlm	Z	 g dZ
ded< dddZdddZdddZdddZdS )    )annotationsN)TYPE_CHECKING)FastaIndexed)FastaRecord)Z10X_hg19_ucscZ10X_b37Z10X_GRCh38_no_alt_decoyz	list[str]KNOWN_GENOMESreference_pathstrreturndict[str, FastaRecord]c                 C  s>   t t| }i }| D ]\}}|jddd }|||< q|S )zJOpen a reference fasta and rename the contigs to strip any fasta comments.   )maxsplitr   )r   	get_fastaitemssplit)r   fastaZ	new_fastakvalueZ
key_prefix r   _/oak/stanford/groups/akundaje/marinovg/programs/cellranger-9.0.1/lib/python/tenkit/reference.pyopen_reference   s   
r   c                 C  s   t j| ddS )z?Convention for location of reference fasta in a reference path.r   z	genome.fa)ospathjoinr   r   r   r   r      s   r   
str | Noneboolc                 C  s   | d uo	t | tv S )N)
get_genomer   r   r   r   r   is_tenx#   s   r   c                 C  sX   d}t j| d}t j|r*t|}|  }W d   |S 1 s%w   Y  |S )ziLoad the canonical name of a reference.

    By convention this is stored in <reference_path>/genome
    Ngenome)r   r   r   existsopenreadlinestrip)r   r   Zgenome_name_filefr   r   r   r   '   s   

r   )r   r   r	   r
   )r   r   r	   r   )r   r   r	   r   )r   r   r	   r   )
__future__r   os.pathr   typingr   Zcommon.pyfastar   Zpyfaidxr   r   __annotations__r   r   r   r   r   r   r   r   <module>   s   


