ó
?îec           @   sŒ   d  d l  Z  d  d l m Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z	 d
 „  Z
 d „  Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   __version__c         C   s2  |  j  } | d k r7 d d l m } d GH| |  ƒ n÷| d k r¾ d d l m } |  j d" k r† |  j d" k r† d GHt j	 d ƒ n  |  j d" k	 r¬ |  j d" k	 r¬ d	 GHn  d
 GH| |  ƒ np| d k rì d d l
 m } d GH| |  ƒ nB| d k rd d l m } d GH| |  ƒ n| d k rHd d l m } d GH| |  ƒ næ | d k rvd d l m } d GH| |  ƒ n¸ | d k r¤d d l m } d GH| |  ƒ nŠ | d k rÒd d l m }	 d GH|	 |  ƒ n\ | d k r d d l m }
 d GH|
 |  ƒ n. | d k r.d d  l m } d! GH| |  ƒ n  d" S(#   s*   The Main function for calling pyatac

    t   vplotiÿÿÿÿ(   t
   make_vplotsP   ---------Making VPlot-----------------------------------------------------------t
   bias_vplot(   t   make_bias_vplots.   
Must input either --bg or --fasta! Exiting...i   sY   Warning-- both --bg and --fasta provided-- will us --bg for bias track and inrore --fastasP   ---------Making Bias VPlot------------------------------------------------------t   signal(   t
   get_signalsP   ---------Getting signal around sites--------------------------------------------t   ins(   t   get_inssP   ---------Getting insertions to make track---------------------------------------t   cov(   t   get_covt
   nucleotide(   t   get_nucleotidesJ   ---------Getting nucleotide content---------------------------------------t   bias(   t   make_bias_tracksE   ---------Making Tn5 Bias Track---------------------------------------t   pwm(   t   get_pwmsC   ---------Making PWM from bam---------------------------------------t   sizes(   t	   get_sizessF   ---------Getting fragment sizes---------------------------------------t   counts(   t
   get_countssG   ---------Getting fragment counts---------------------------------------N(   t   callt   pyatac.make_vplotR   t   pyatac.make_bias_vplotR   t   bgt   Nonet   fastat   syst   exitt   pyatac.signal_around_sitesR   t   pyatac.get_insR   t   pyatac.get_covR
   t   pyatac.get_nucleotideR   t   pyatac.make_bias_trackR   t   pyatac.get_pwmR   t   pyatac.get_sizesR   t   pyatac.get_countsR   (   t   argsR   R   R   R   R   R
   R   R   R   R   R   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyt   pyatac_main   s\    	c          C   s¯   t  j d d d d ƒ }  |  j d d d d d t ƒ|  j d	 d
 ƒ } t | ƒ t | ƒ t | ƒ t | ƒ t	 | ƒ t
 | ƒ t | ƒ t | ƒ t | ƒ t | ƒ |  S(   s   Prepares argparse object

    t   descriptions3   %(prog)s -- Utilitis for working with ATAC-Seq datat   epilogsC   For command line options for each command, type %(prog)s COMMAND -hs	   --versiont   actiont   versions	   %(prog)s t   destR   (   t   argparset   ArgumentParsert   add_argumentR    t   add_subparserst   add_nucleotide_parsert   add_vplot_parsert   add_bias_vplot_parsert   add_pwm_parsert   add_signal_parsert   add_ins_parsert   add_cov_parsert   add_bias_parsert   add_sizes_parsert   add_counts_parser(   t	   argparsert
   subparsers(    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyt   pyatac_parser;   s    	









c      
   C   s  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d d d
 t d d ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d d t d d ƒ| j d d ƒ } | j d d d d d d d d  t ƒ| j d! d d d d" d d# d  t ƒd$ S(%   s0   Add argument parsers for the sizes utility

    R   t   helps8   pyatac function-- compute fragment counts within windowst   Requireds   Necessary argumentss   --bamt   metavart   bam_files   Aligned readst   requireds   --bedt   bed_files"   Windows in which to compute countst   Optionss   Optional settingss   --outt   output_basenames   Basename for outputs
   --not_atacR)   t   store_falseR+   t   atact   defaults   Don't use atac offsetss   Fragment size bounds options   Upper and lower limitss   --lowert   ints0   lower limit on insert         size. Default is 0i    t   types   --uppers3   upper limit on insert         size.  Default is 500iô  N(   t
   add_parsert   add_argument_groupR.   t   TrueRH   (   R;   t   parsert   group0t   group3t   group4(    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR9   Z   s    %c      
   C   sO  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d ƒ } | j d d d d d ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d d t d d ƒ| j d d ƒ } | j d d d d d d d  d! t ƒ| j d" d d d d# d d$ d! t ƒ| j d% d& ƒ } | j d' d d( d t d d) ƒd* S(+   s0   Add argument parsers for the sizes utility

    R   R=   s4   pyatac function-- compute fragment size distributionR>   s   Necessary argumentss   --bamR?   R@   s   Aligned readsRA   s-   Find only fragmentsizes for regions of genomes   --bedRB   sO   Only compute size distribution for fragment centered within regions in bed fileRC   s   Optional settingss   --outRD   s   Basename for outputs
   --not_atacR)   RE   R+   RF   RG   s   Don't use atac offsetss   Fragment sizs bounds options   Upper and lower limitss   --lowerRH   s0   lower limit on insert         size. Default is 0i    RI   s   --uppers3   upper limit on insert         size.  Default is 500iô  s   Plot optionss   Make plots?s	   --no_plott
   store_trues   Don't plot outputN(   RJ   RK   R.   RL   RH   t   False(   R;   RM   RN   t   group2RO   RP   t   group5(    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR8   o   s"    %c      
   C   só   |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d ƒ } | j d d d d d d d ƒ| j d ƒ } | j d d d d d ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d d d d t ƒd  S(!   s/   Add argument parsers for the bias utility

    R   R=   s(   pyatac function-- compute Tn5 bias scoreR>   s   Necessary argumentss   --fastaR?   t
   fasta_files   Accepts fasta fileRA   s
   PWM options*   Designate PWM file or default will be useds   --pwmt   Tn5_PWMsA   PWM descriptor file. Default is Human.PWM.txt included in packageRG   t   Humans$   Find only bias for regions of genomes   --bedRB   s<   Positions around which         to get nucleotide frequenciesRC   s   Optional settingss   --outRD   s   Basename for outputs   --coresRH   s   number of cores to usei   RI   N(   RJ   RK   R.   RL   RH   (   R;   RM   RN   t   group1RS   RO   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR7   …   s    c      
   C   s¼  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d d d d d
 t ƒ| j d d ƒ } | j d d d d d ƒ| j d d ƒ } | j d d d d d d t ƒ| j d d d d d d d d t ƒ| j d d d d d  d d! d t ƒ| j d" d d d d# d d$ d t ƒ| j d% d d& d' d( d t d d) ƒ| j d* d d& d' d+ d t d d, ƒ| j d- d d. d d/ ƒ| j d0 d d d d1 d d2 d t ƒd3 S(4   s5   Add argument parsers for the nucleotide utility

    R   R=   sH   pyatac function-- get nucleotide (or di-nucleotide) content around sitesR>   s   Necessary argumentss   --fastaR?   RU   s   Accepts fasta fileRA   s   --bamR@   s)   Reads around which to get nucleotide freqs   Input sitessQ   If bed provided, find nucleotide frequencies around read starts within bed regions   --bedRB   s   Regions from which to use readsRC   s   Optional settingss   --dinucleotideR)   RQ   s=   Compute dinucleotide frequencies instead of single nucleotideRG   s   --flankRH   sD   Bases away from insertion site to get frequencies for. Default is 10i
   RI   s   --lowers(   lower limit on insert size. default is 0i    s   --uppers+   upper limit on insert size. default is 2000iÐ  s
   --not_atacRE   R+   RF   s   Don't use atac offsetss   --no_symt   syms   Don't symmetrize PWMs   --outRD   s   Basename for outputs   --coress   number of cores to usei   N(   RJ   RK   R.   RL   RR   RH   (   R;   RM   RX   RS   RO   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR3   ™   s"    %%%%%c      
   C   s`  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d d d d d
 t ƒ| j d d ƒ } | j d d d d d d t ƒ| j d d d d d d d d t ƒ| j d d d d d d d d t ƒ| j d d d d d d t ƒ| j d d d d d  ƒ| j d! d d d d" d d# d t ƒ| j d$ d d d t d d% ƒd& S('   s5   Add argument parsers for the nucleotide utility

    R   R=   sH   pyatac function-- get nucleotide (or di-nucleotide) content around sitesR>   s   Necessary argumentss   --fastaR?   RU   s   Accepts fasta fileRA   s   --bedRB   s<   Positions around which         to get nucleotide frequenciesRC   s   Optional settingss   --dinucleotideR)   RQ   s=   Compute dinucleotide frequencies instead of single nucleotideRG   s   --upRH   s-   Bases upstream of site to get frequencies foriú   RI   s   --downs/   Bases downstream of site to get frequencies fors   --strands,   Column in bedfile with strand info (1-based)s   --outRD   s   Basename for outputs   --coress   number of cores to usei   s   --norms#   Normalize by background frequenciesN(   RJ   RK   R.   RL   RR   RH   (   R;   RM   RX   RO   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR0   ¯   s    %%c      
   C   s  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d d d d d
 t ƒ| j d d ƒ } | j d d d ƒ| j d d d d d d d d t ƒ| j d d ƒ } | j d d d d d d d d t ƒ| j d d d d d d d d t ƒ| j d  d d d d! d t d d ƒ| j d" d# d$ d t d d% ƒ| j d& d d d t d d' ƒ| j d( d d d t d d) ƒ| j d* d# d+ d, d- d t d d. ƒ| j d/ d0 ƒ } | j d1 d# d$ d t d d2 ƒ| j d3 d# d$ d t d d4 ƒd5 S(6   s0   Add argument parsers for the vplot utility

    R   R=   s   pyatac function-- make vplotR>   s   Necessary argumentss   --bedR?   RB   s0   Positions around which         to generate VPlotRA   s   --bamR@   s   Accepts sorted BAM files   General optionst    s   --outt   basenames   --coresRH   RG   i   s   Number of cores to useRI   s   VMat options   Size, scaling of VPlots   --lowers"   lower limit on insert         sizei    s   --uppers"   upper limit on insert         sizeiú   s   --flanksB   how many bases on each side of site (or center of site) to includes   --scaleR)   RQ   s   Scale each sites   --weights.   column in which weight information is includeds   --strands.   column in which strand information is includeds
   --not_atacRE   R+   RF   s   Don't use atac offsetss   Plot optionss   Make plots?s	   --no_plots   Don't plot outputs   --plot_extras   Make some extra plotsN(   RJ   RK   R.   RL   RH   RR   (   R;   RM   RX   RS   RO   RT   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR1   Æ   s6    %c      
   C   s>  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d d d d d
 t ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d ƒ| j d d d d d d d ƒ| j d d ƒ } | j d d d ƒ| j d d d  d d! d d" d# t ƒ| j d$ d% ƒ } | j d& d d  d d' d d( d# t ƒ| j d) d d  d d* d d+ d# t ƒ| j d, d d  d d- d# t d d+ ƒ| j d. d/ d0 d t ƒ| j d1 d d  d# t d d2 ƒ| j d3 d d  d# t d d4 ƒ| j d5 d6 ƒ } | j d7 d/ d0 d t d d8 ƒ| j d9 d/ d0 d t d d: ƒd; S(<   s5   Add argument parsers for the bias vplot utility

    R   R=   s   pyatac function-- make vplotR>   s   Necessary argumentss   --bedR?   RB   s0   Positions around which         to generate VPlotRA   s   --sizest
   sizes_files,   Accepts sizes file from pyatac sizes commands   Bias OptionssA   Must either submit a tabix-indexed bedgraph file or a fasta file.s   --bgt	   bias_files   Accepts tabix indexed files   --fastaRU   s   Accepts indexed fasta files   --pwmRV   sA   PWM descriptor file. Default is Human.PWM.txt included in packageRG   RW   s   General optionsRZ   s   --outR[   s   --coresRH   i   s   Number of cores to useRI   s   VMat options   Size, scaling of VPlots   --lowers"   lower limit on insert         sizei    s   --uppers"   upper limit on insert         sizeiú   s   --flanksB   how many bases on each side of site (or center of site) to includes   --scaleR)   RQ   s   --weights.   column in which weight information is includeds   --strands.   column in which strand information is includeds   Plot optionss   Make plots?s	   --no_plots   Don't plot outputs   --plot_extras   Make some extra plotsN(   RJ   RK   R.   RL   RH   RR   (   R;   RM   RN   RX   RS   RO   RP   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR2   è   s@    		c      
   C   sJ  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d d d d d
 t ƒ| j d d d d
 t d d ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d t d d d d ƒ| j d d d d t d d ƒ| j d  d d d t d d! ƒ| j d" d# ƒ } | j d$ d d d d% d t d d& ƒ| j d' d d d d( d t d d& ƒ| j d) d d d t d d7 d d* ƒ| j d+ d d d t d d7 d d, ƒ| j d- d. ƒ } | j d/ d d d t d d0 ƒ| j d1 d d d t d d2 ƒ| j d3 d d d t d d4 ƒ| j d5 d d d t d d6 ƒd7 S(8   s1   Add argument parsers for the signal utility

    R   R=   s)   pyatac function-- get signal around sitesR>   s   Necessary argumentss   --bedR?   RB   s0   Positions around which         to generate VPlotRA   s   --bgt   bg_files+   Accepts bedgraph file that is tabix indexeds   --sizest   genome_sizes_files3   File with chromosome names in 1st col, sizes in 2nds   General optionsRZ   s   --outR[   s   basename for outputs   --coresRH   RI   RG   i   s   Number of cores to uses   --allR)   RQ   sO   output csv file (gzipped) with signal track around                    all sitess   --no_aggs7   Don't make a plot of aggregate or write up of aggregates   Bed optionss    Options related to bed intervalss   --ups   bases upstream of site to lookiú   s   --downs   bases dowstream site to looks   --weightsX   Column with weight information. Signal for interval  will be weighted by value in columns   --strandsF   Column in which strand information is included if strand is to be useds   Signal optionss   Options related to signals   --exps   take exponent of values
   --positives   Only include positive signals   --scalesD   scale each individual track by total                    signal values   --norms0   normalize aggregate track by number of intervalsN(   RJ   RK   R.   RL   RH   RR   R   (   R;   RM   RX   RS   RO   RP   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR4     sB    c      
   C   sM  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d ƒ } | j d d d d d ƒ| j d d d ƒ| j d d d d d d d d t ƒ| j d d ƒ } | j d d d d d d d d t ƒ| j d d d d d d d d t ƒ| j d  d d d t d d! ƒ| j d" d# d$ d% d& d t d d' ƒd( S()   s.   Add argument parsers for the ins utility

    R   R=   s    pyatac function-- get insertionsR>   s   Necessary argumentss   --bamR?   R@   s   Accepts sorted BAM fileRA   s   General optionsRZ   s   --bedRB   s"   Regions in which to get insertionss   --outR[   s   --coresRH   RG   i   s   Number of cores to useRI   s   insertion options   Size range, smoothings   --lowers"   lower limit on insert         sizei    s   --uppers"   upper limit on insert         sizeiÐ  s   --smoothsA   smoothing window for guassian smoothing.  default is no smoothings
   --not_atacR)   RE   R+   RF   s   Don't use atac offsetsN(   RJ   RK   R.   RL   RH   (   R;   RM   RX   RS   RO   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR5   6  s"    %c      
   C   sx  |  j  d d d ƒ} | j d d ƒ } | j d d d d d	 d
 t ƒ| j d d ƒ } | j d d d d d ƒ| j d d d ƒ| j d d d d d d d d t ƒ| j d d ƒ } | j d d d d d d d d t ƒ| j d d d d d d d d t ƒ| j d  d d d t d d! d d" ƒ| j d# d d$ d t d d% d d& ƒ| j d' d( d) d* d+ d t d d, ƒd- S(.   s.   Add argument parsers for the cov utility

    R	   R=   s   pyatac function-- get coverageR>   s   Necessary argumentss   --bamR?   R@   s   Accepts sorted BAM fileRA   s   General optionsRZ   s   --bedRB   s"   Regions in which to get insertionss   --outR[   s   --coresRH   RG   i   s   Number of cores to useRI   s   insertion options   Size range, smoothings   --lowers"   lower limit on insert         sizei    s   --uppers"   upper limit on insert         sizeiÐ  s   --windowiy   sE   window for flat smoothing of coverage.  default is 121, should be odds   --scalet   floati
   s‡   scaling value.  default is 10, corresponding to signal corresponding to # of fragment centers  per 10 bp. Use 1 for fragments per 1 bp.s
   --not_atacR)   RE   R+   RF   s   Don't use atac offsetsN(   RJ   RK   R.   RL   RH   R`   (   R;   RM   RX   RS   RO   (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyR6   M  s&    %(   R,   t   pyatacR    R&   R<   R9   R8   R7   R3   R0   R1   R2   R4   R5   R6   (    (    (    s0   /tmp/pip-install-bGcd2k/NucleoATAC/pyatac/cli.pyt   <module>   s   	7							"	&	(	