ó
?îec           @   st   d  d l  Z  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 S(   iÿÿÿÿN(   t   __version__c         C   sD  |  j  } t ƒ  } | d k r@ d d l m } d GH| |  ƒ n | d k rn 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| |  ƒ nv| d k rø d d l
 m } d GH| |  ƒ nH| d k r@| j t t d d |  j d |  j d |  j d |  j d |  j d |  j g ƒ ƒ } | j d d |  j d d |  j g ƒ }	 d d |  j d |  j d |  j d t |  j ƒ d |  j d d |  j d d |  j d |  j d |  j d g }
 |  j r|
 j d g ƒ n  | j |
 ƒ } | j d d  |  j d! d" |  j d# d |  j g ƒ } | j d d |  j d |  j d d$ |  j d% d |  j d |  j d |  j d |  j g ƒ } d d l m } d d l m } d d	 l m } d d l m	 } d d l
 m } d& GH| | ƒ d' GH| |	 ƒ d( GH| | ƒ d) GH| | ƒ d* GH| | ƒ n  d+ S(,   s.   The Main function for calling nucleoatac

    t   occiÿÿÿÿ(   t   run_occsP   ---------Computing Occupancy and Nucleosomal Insert Distribution----------------t   vprocess(   t   run_vprocesssP   ---------Processing VPlot-------------------------------------------------------t   nuc(   t   run_nucsP   ---------Obtaining nucleosome signal and calling positions----------------------t   merge(   t	   run_mergesP   ---------Merging----------------------------------------------------------------t   nfr(   t   run_nfrsP   ---------Calling NFR positions--------------------------------------------------t   runs   --beds   --bams   --fastas   --pwms   --outs   --coress   --sizess   .nuc_dist.txts   --occ_tracks   .occ.bedgraph.gzs   --vmats   .VMats   .fragmentsizes.txts   --write_alls
   --occpeakss   .occpeaks.bed.gzs   --nucposs   .nucpos.bed.gzs   --callss   .nucmap_combined.bed.gzsP   ---------Step1: Computing Occupancy and Nucleosomal Insert Distribution---------sP   ---------Step2: Processing Vplot------------------------------------------------sP   ---------Step3: Obtaining nucleosome signal and calling positions---------------sP   ---------Step4: Making combined nucleosome position map ------------------------sP   ---------Step5: Calling NFR positions-------------------------------------------N(   t   callt   nucleoatac_parsert   nucleoatac.run_occR   t   nucleoatac.run_vprocessR   t   nucleoatac.run_nucR   t   nucleoatac.mergeR   t   nucleoatac.run_nfrR
   t
   parse_argst   mapt   strt   bedt   bamt   fastat   pwmt   outt   corest	   write_allt   extend(   t   argsR   t   parserR   R   R   R   R
   t   occ_argst   vprocess_argst   nuc_args_listt   nuc_argst
   merge_argst   nfr_args(    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyt   nucleoatac_main   sj    		!(-%	#"



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
 | ƒ |  S(   s   Prepares argparse object

    t   descriptions+   %(prog)s -- Nucleosome Calling for ATAC-Seqt   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_run_parsert   add_occ_parsert   add_vprocess_parsert   add_nuc_parsert   add_merge_parsert   add_nfr_parser(   t	   argparsert
   subparsers(    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR   E   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 d d d d
 t ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d d d ƒ| j d d ƒ } | j d d 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 d0 ƒ| j d1 d d! d d2 d$ t d d3 ƒ| j d4 d d. d d5 d$ t d d6 ƒ| j d7 d d! d d8 d$ t d d9 ƒd: S(;   s.   Add argument parsers for the occ utility

    R   t   helps/   nucleoatac function:  Call nucleosome occupancyt   Requireds   Necessary argumentss   --bedt   metavart   bed_files   Peaks in bed formatt   requireds   --bamt   bam_files   Sorted (and indexed) BAM files   --outt   basenames   give output basenames   Bias calculation informationsE   Highly recommended. If fasta is not provided, will not calculate biass   --fastat
   genome_seqs   Indexed fasta files   --pwmt   Tn5_PWMsA   PWM descriptor file. Default is Human.PWM.txt included in packaget   defaultt   Humans   General Optionst    s   --sizest   fragmentsizes_filesU   File with fragment size distribution.  Use if don't want calculation of fragment sizes   --corest   inti   s   Number of cores to uset   types   Occupancy parameters   Change with cautions   --upperiû   s*   upper limit in insert size. default is 251s   --flanki<   sR   Distance on each side of dyad to include for local occ calculation. Default is 60.s	   --min_occt   floatgš™™™™™¹?sH   Occupancy cutoff for determining nucleosome distribution. Default is 0.1s	   --nuc_sepix   s:   minimum separation between occupany peaks. Default is 120.s   --confidence_intervalgÍÌÌÌÌÌì?s`   confidence interval level for lower and upper bounds.  default is 0.9, should be between 0 and 1s   --stepi   sa   step size along genome for comuting occ. Default is 5.  Should be odd, or will be subtracted by 1N(   t
   add_parsert   add_argument_groupR.   t   TrueRE   RG   (   R7   R   t   group1t   group4t   group2t   group3(    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR1   \   s<    c         C   sÒ   |  j  d d d ƒ} | j 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 ƒ| j d d d d d d d ƒ| j d d d d d d d ƒd S(   s%   Add argument parser for merge utilityR   R8   s,   nucleoatac function: Merge occ and nuc callsR9   s   Necessary argumentss
   --occpeaksR:   t   occpeaks_fileR<   s   Output from occ utilitys   --nucpost   nucpos_files   Output from nuc utilityt   Optionst   optionals   --outt   out_basenames   output file basenames   --sept   min_separationRA   ix   s   minimum separation between calls	   --min_occt   min_occgš™™™™™¹?s_   minimum lower bound occupancy of nucleosomes to be considered for excluding NFR. default is 0.1N(   RH   RI   R.   RJ   (   R7   R   RK   RM   (    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR4      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 d d
 t d d ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d ƒ| j d d ƒ } | j d d d d d ƒ| j d d d d d  d! d" ƒ| j d# d$ ƒ } | j d% d d& d d' ƒ| j d( d d) d! d* d d+ d, t ƒ| j d- ƒ } | j d. d d/ d! d0 d d1 d, t ƒ| j d2 d d/ d! d3 d d4 d, t ƒd5 S(6   s)   Add argument parser for nfr utility

    R	   R8   s   nucleoatac function: Call NFRsR9   s   Necessary argumentss   --bedR:   R;   s   Peaks in bed formatR<   s   --occ_trackt   occ_filesD   bgzip compressed, tabix-indexed bedgraph file with occcupancy track.s   --callsRP   s%   bed file with nucleosome center callss   Insertion track optionss'   Either input insertion track or bamfiles   --ins_trackt   ins_filese   bgzip compressed, tabix-indexed bedgraph file with insertion track. will be generated if not includeds   --bamR=   s   Sorted (and indexed) BAM files   Bias calculation informationsE   Highly recommended. If fasta is not provided, will not calculate biass   --fastaR?   s   Indexed fasta files   --pwmR@   sA   PWM descriptor file. Default is Human.PWM.txt included in packageRA   RB   s   General optionsRR   s   --outRS   s   output file basenames   --corest	   num_coresi   s   Number of cores to useRF   s   NFR determination parameterss	   --max_occRG   gš™™™™™¹?s.   Maximum mean occupancy for NFR. Default is 0.1s   --max_occ_upperg      Ð?sE   Maximum for minimum of  upper bound occupancy in NFR. Default is 0.25N(   RH   RI   R.   RJ   RE   RG   (   R7   R   RK   t   group6RL   RM   t   group5(    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR5   Ž   s2    c      
   C   sk  |  j  d d d ƒ} | j d d ƒ } | j d d d d	 t ƒ| j d
 d ƒ } | j d d d d d ƒ| j d d d d d d t j j ƒ| 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 d d t ƒ| j d  d! ƒ } | j d" d d# d d$ d t d d% ƒ| j d& d' d( d t	 d d) ƒd* S(+   s3   Add argument parsers for the vprocess utility

    R   R8   sH   nucleoatac function:  Make processed vplot to use for nucleosome callingR9   s   Necessary argumentss   --outR:   t   output_basenameR<   s   VPlot and Insert Size Optionst   Optionals   --sizest   files   Insert distribution files   --vplott	   vmat_files1   Accepts VMat file.  Default is Vplot from S. Cer.RA   s   Size parameerss   Use sensible valuess   --lowerRE   ii   s6   lower limit (inclusive) in insert size. default is 105RF   s   --upperiû   s3   upper limit (exclusive) in insert size. default 251s   --flanki<   s(   distance on each side of dyad to includeRQ   RC   s   --smoothRG   g      è?s:   SD to use for gaussian smoothing.  Use 0 for no smoothing.s   --plot_extraR)   t
   store_trues   Make some additional plotsN(
   RH   RI   R.   RJ   t
   nucleoatact   Magict   default_vplotRE   RG   t   False(   R7   R   RK   RM   RN   RL   (    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR2   ­   s*    c      
   C   si  |  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 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 d d ƒ| j d d ƒ } | j d  d d! d d" ƒ| j d# d d$ d d% ƒ| j d& d d' d d( d d) d* t ƒ| j d+ d, d- d t d d. ƒ| j d/ d0 d1 d, d2 d t d d3 ƒ| j d4 d5 ƒ } | j d6 d d7 d d8 d d9 d* t ƒ| j d: d d7 d d; d d< d* t ƒ| j d= d d> d d? d* t d d@ ƒ| j dA d d> d dB d* t d dC ƒ| j dD d d> d* t d dE d dF ƒdG S(H   s.   Add argument parsers for the nuc utility

    R   R8   sF   nucleoatac function:  Call nucleosome positions and make signal tracksR9   s   Necessary argumentss   --bedR:   R;   s&   Regions for which         to do stuff.R<   s   --vmatt   vdensity_files   VMat objects   --bamR=   s   Accepts sorted BAM files   --outR>   s   give output basenames   Bias optionss,   If --fasta not provided, bias not calculateds   --fastaR?   s   Indexed fasta files   --pwmR@   sA   PWM descriptor file. Default is Human.PWM.txt included in packageRA   RB   s   General optionsRC   s   --sizesRD   sU   File with fragment size distribution.  Use if don't want calculation of fragment sizes   --occ_trackRV   st   bgzip compressed, tabix-indexed bedgraph file with occcupancy track. Otherwise occ not determined for nuc positions.s   --coresRX   i   s   Number of cores to useRF   s   --write_allR)   R_   s   write all trackss
   --not_atacR+   t   atact   store_falses   data is not atac-seqs   Nucleosome calling parameterss   Change with cautions   --min_zRG   i   s4   Z-score threshold for nucleosome calls. Default is 3s   --min_lri    sA   Log likelihood ratio threshold for nucleosome calls. Default is 0s	   --nuc_sepRE   ix   sD   Minimum separation between non-redundant nucleosomes. Default is 120s   --redundant_sepi   s_   Minimum separation between redundant nucleosomes. Not recommended to be below 15. Default is 25s   --sdi
   s´   Standard deviation for smoothing. Affect the         resolution at which nucleosomes can be positioned. Not recommended to         exceed 25 or to be smaller than 10. Default is 10N(   RH   RI   R.   RJ   RE   Rc   RG   (   R7   R   RK   RM   RN   RZ   (    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR3   Ç   sJ    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 d d d d
 t ƒ| j d d d d d d
 t ƒ| j d d ƒ } | j d d d d d d d ƒ| j d d ƒ } | j d d d d d d d d  t ƒ| j d! d" d# d t d d$ ƒd% S(&   s.   Add argument parsers for the run utility

    R   R8   sV   Main nucleoatac utility-- runs through occupancy determination & calling nuc positionsR9   s   Necessary argumentss   --bedR:   R;   s&   Regions for which         to do stuff.R<   s   --bamR=   s   Accepts sorted BAM files   --outR[   s   give output basenames   --fastaR?   s   Indexed fasta files   Bias calculation parametersRC   s   --pwmR@   sA   PWM descriptor file. Default is Human.PWM.txt included in packageRA   RB   s   General optionss   --coresRX   i   s   Number of cores to useRF   s   --write_allR)   R_   s   write all tracksN(   RH   RI   R.   RJ   RE   Rc   (   R7   R   RK   RL   RN   (    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyR0   ó   s$    (   R,   t   nucleoatac.MagicR`   R    R&   R   R1   R4   R5   R2   R3   R0   (    (    (    s4   /tmp/pip-install-bGcd2k/NucleoATAC/nucleoatac/cli.pyt   <module>   s   	>		#				,