
^c           @   s%  d  d l  Z  d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l Z d  d l	 Z	 d  d l
 m Z d   Z d   Z d   Z d	 e j f d
     YZ d   Z d e j f d     YZ d e j f d     YZ d e j f d     YZ d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e  d  Z! d   Z" d   Z# d   Z$ d    Z% d!   Z& d"   Z' d#   Z( d$   Z) d d%  Z+ e  d d&  Z, e  d d'  Z- d(   Z. d)   Z/ d*   Z0 d+   Z1 d,   Z2 d-   Z3 d.   Z4 d S(/   iN(   t   gettext(   t   basename(   t   abspatht
   expanduser(   t   empty_configc          C   s]  d  }  t t j d  } t j } t j d t  } | j d d d d d | j d d d	 d d | j d
 d d d d | j d d d d d | j d d d d d | j |  \ } } | d k s | j	 r d	 }  nN | d k s | j
 rd }  n0 | j rd }  n | d k s)| j r2d }  n  | d k sP| j
 rY| j rYd }  n  |  S(   Ni    t   add_helps	   --isolatet   destt   isolatet   actiont
   store_trues   --rnat   rnas	   --plasmidt   plasmids   --metat   metas   --biot   bios   rnaspades.pys   plasmidspades.pyt   bgcs   metaspades.pys   metaplasmidspades.pyt   metaplasmid(   t   NoneR   t   options_storaget   first_command_linet   argparset   ArgumentParsert   Falset   add_argumentt   parse_known_argsR
   R   R   R   (   t   modet   script_basenamet   optionst   mode_parsert   nargst   unknown_args(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   get_mode   s*    							c         C   s   t    } | d k r! t |  _ nr | d k r9 t |  _ nZ | d k rZ t |  _ t |  _ n9 | d k rr t |  _ n! | d k r t |  _ t |  _ n  d  S(   NR
   R   R   R   R   (   R   t   TrueR
   R   R   R   (   t   argsR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_mode_to_args.   s    			c          C   s7   t    }  d t j } |  d  k	 r3 | d |  7} n  | S(   Ns   SPAdes genome assembler v%ss    [%sSPAdes mode](   R   R   t   spades_versionR   (   R   t   ver(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   version?   s
    	t   SpadesHelpFormatterc           B   s/   e  Z d  d d d  Z d   Z d d  Z RS(   i   i   id   c         C   s#   t  t |   j | | | |  d  S(   N(   t   superR%   t   __init__(   t   selft   progt   indent_incrementt   max_help_positiont   width(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR'   H   s    c         C   s
   | j    S(   N(   t
   splitlines(   R(   t   textR,   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   _split_linesK   s    c         C   s>   | d  k r" t t   d  } n  t j j |  | | | |  S(   Ns	   

Usage: (   R   R    R$   R   t   HelpFormattert   _format_usage(   R(   t   usaget   actionst   groupt   prefix(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR1   N   s    N(   t   __name__t
   __module__R'   R/   R   R1   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR%   G   s   	c           C   s   t    S(   N(   t   dict(    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   init_dataset_dataT   s    t   AddToDatasetActionc        	   B   s5   e  Z d d d d d e d d d   Z d d  Z RS(   c         C   s5   t  t |   j | | | | | | | | |	 |
 
 d  S(   N(   R&   R:   R'   (   R(   t   option_stringsR   R   t   constt   defaultt   typet   choicest   requiredt   helpt   metavar(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR'   Y   s    'c         C   sO  | d k r t  t _ n  | t j k r3 t t _ n  d | k r[ t   } t | d |  n  d } t	 |  d k rd | j
 d  d | d } t	 | j
 d   d k r| j
 d  d	 d
 k r | d | d 7} q| d | j
 d  d	 7} | d	 } q5| d	 } n% | } t	 |  d k r5| d } n  t j | | | j  d  S(   Ns   -st   dataset_datat    i   s   --t   -i    i   it   ori   (   R   t   supportt   old_style_single_readsR   t   OLD_STYLE_READS_OPTIONSR   t   only_old_style_optionsR9   t   setattrt   lent   splitt   add_to_datasetRC   (   R(   t   parsert	   namespacet   valuest   option_stringRC   t   argt   opt(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   __call__^   s(    	N(   R6   R7   R   R   R'   RU   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR:   X   s   t   StoreUniqueActionc        	   B   s5   e  Z d d d d d e d d d   Z d d  Z RS(   c         C   sS   t  t |   j d | d | d | d | d | d | d | d | d	 |	 d
 |
  
d  S(   NR;   R   R   R<   R=   R>   R?   R@   RA   RB   (   R&   RV   R'   (   R(   R;   R   R   R<   R=   R>   R?   R@   RA   RB   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR'      s    *c         C   sB   | j  |  j d  k	 r+ t j |  d   n  t | |  j |  d  S(   Ns#   option was specified at least twice(   t   __dict__R   R   R   t   ArgumentErrorRK   (   R(   RO   RP   RQ   RR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyRU      s    N(   R6   R7   R   R   R'   RU   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyRV   ~   s   t   ConcatenationActionc        	   B   s5   e  Z d d d d d e d d d   Z d d  Z RS(   c         C   sS   t  t |   j d | d | d | d | d | d | d | d | d	 |	 d
 |
  
d  S(   NR;   R   R   R<   R=   R>   R?   R@   RA   RB   (   R&   RY   R'   (   R(   R;   R   R   R<   R=   R>   R?   R@   RA   RB   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR'      s    *c         C   s   g  | D] } | D] } | ^ q q } t  |  d k rU | d d k rU | d } n3 t  |  d k r d | k r t j |  d   n  t | |  j |  d  S(   Ni   i    t   autos2   cann't set 'auto' and kmers' size at the same time(   RL   R   RX   RK   R   (   R(   RO   RP   RQ   RR   t   outert   x(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyRU      s    &"N(   R6   R7   R   R   R'   RU   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyRY      s   c         C   s   |  d k r |  g St  |   } | t j k  s= | t j k rb t j d | t j t j f   n  | d d k r t j d |   n  | g Sd  S(   NRZ   s:   wrong k value %d: all k values should be between %d and %di   i    s,   wrong k value %d: all k values should be odd(   t   intR   t   MIN_Kt   MAX_KR   t   ArgumentTypeError(   RS   t   k(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   kmer   s    	c         C   sk   |  } | d d k r# | d  } n  | j  d  } x2 t t |   D] } t | |  d | | <qE W| S(   Nit   ,i    (   RM   t   rangeRL   Rb   (   RS   t   k_merst   i(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   kmers   s    c         C   s   |  d k r |  St  |   Sd  S(   NRZ   (   R]   (   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   qvoffset   s    c         C   s^   |  d k s |  d k r |  St  j |   rG t |   d k rG t |   St j d |    d  S(   NRZ   t   offg        sG   wrong value %s (should be a positive float number, or 'auto', or 'off')(   RG   t   is_floatt   floatR   R`   (   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt
   cov_cutoff   s
    !
c         C   sB   t  j |   r+ t |   d k r+ t |   St j d |    d  S(   Ng        s2   wrong value %s (should be a positive float number)(   RG   Rj   Rk   R   R`   (   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   lcer_cutoff   s    !
c         C   sQ   |  t  j k rM |  t  j k rM |  j d  rM t j d |  t  j f   n  |  S(   NRa   s>   wrong value %s (should be 'ec', 'as', 'k<int>', 'mc', or '%s')(   R   t   SHORT_STAGES_NAMEt
   LAST_STAGEt
   startswithR   R`   (   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   restart_from   s    .c         C   s9   |  t  j k r5 |  j d  r5 t j d |    n  |  S(   NRa   s8   wrong value %s (should be 'ec', 'as', 'k<int>', or 'mc')(   R   Rn   Rp   R   R`   (   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt
   stop_after   s    c         C   sB   t  j |   r+ t |   d k r+ t |   St j d |    d  S(   Ni    s8   wrong value %s (should be a non-negative integer number)(   RG   t   is_intR]   R   R`   (   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   read_cov_threshold   s    !
c         C   s  xt  d d  D]} x d d d d g D] } |  j d | | f d d	 d
 d d t j d t |  j d | | f d d	 d
 d d t j d t |  j d | | f d d	 d
 d d t j d t q) Wx d d d g D] } |  j d | | f d
 d d t j d t |  j d | | f d
 d d t j d t |  j d | | f d
 d d t j d t q W|  j d | d d	 d
 d d t j d t |  j d | d d	 d
 d d t j d t |  j d | d d	 d
 d d t j d t |  j d | d d	 d
 d d t j d t q Wd  S(   Ni   i
   s   -12s   -1s   -2s   -ss   --pe%d%sRB   s
   <filename>R   RA   R   s   --mp%d%ss
   --hqmp%d%ss   -frs   -rfs   -ffi    s   --s%ds   --pe%d-ms   --nxmate%d-1s   --nxmate%d-2(   Rd   R   R   t   SUPPRESSR:   (   t   pgroup_input_datat   numt   sufixt   orientation(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_deprecated_input_data_args   sd    										c         C   s  t    } |  j d d d d d d t d d  d d	 d
 t | d  k	 } |  j d d d d | sd d n t j d
 d |  j d d d d | s d n t j d
 d |  j d d d d | s d n t j d
 d |  j d d d d | s d n t j d
 d |  j d d d d | sd n t j d
 d |  j d d d d | sJd n t j d
 d |  j d d d d d  d
 d |  j d! d d" d d# d
 d |  j d$ d% d d& d
 d |  j d' d( d d) d
 d* d* t   d  S(+   Ns   -oRB   s   <output_dir>RA   s5   directory to store all the resulting files (required)R>   R=   R   t
   output_dirR   s	   --isolateR   sM   this flag is highly recommended for high-coverage isolate and multi-cell dataR	   s   --sct   single_cells0   this flag is required for MDA (single-cell) datas   --metaR   s1   this flag is required for metagenomic sample datas   --bioR   s1   this flag is required for biosyntheticSPAdes modes   --rnaR
   s&   this flag is required for RNA-Seq datas	   --plasmidR   s1   runs plasmidSPAdes pipeline for plasmid detections   --iontorrentt
   iontorrents)   this flag is required for IonTorrent datas   --testt	   test_modes   runs SPAdes on toy datasets   -hs   --helps   prints this usage messages   -vs	   --versions   prints versionR$   (   R   R   t   strR   RV   R   Ru   R$   (   t   pgroup_basicR   t   help_hidden(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_basic_args  s`    	c      
   C   s  d | k rQ | j  d |  d d d d d | s> d	 | |  f n t j d
 t n  d | k r | j  d |  d d d d d | s d | |  f n t j d
 t n  d | k r | j  d |  d d d d d | s d | |  f n t j d
 t n  d | k rD| j  d |  d d d d d | s1d | |  f n t j d
 t n  d | k r| j  d |  d d d d d | sd | |  f n t j d
 t n  d | k r| j  d |  d d  d d d | sd | |  f n t j d
 t n  d  S(!   Nt   12s   --%s-12RB   s   <#>s
   <filename>R   i   RA   se   file with interlaced reads for %s library number <#>.
Older deprecated syntax is -%s<#>-12 <filename>R   t   1s   --%s-1sa   file with forward reads for %s library number <#>.
Older deprecated syntax is -%s<#>-1 <filename>t   2s   --%s-2sa   file with reverse reads for %s library number <#>.
Older deprecated syntax is -%s<#>-2 <filename>t   ss   --%s-ssb   file with unpaired reads for %s library number <#>.
Older deprecated syntax is -%s<#>-s <filename>t   ms   --%s-ms`   file with merged reads for %s library number <#>.
Older deprecated syntax is -%s<#>-m <filename>RF   s   --%s-ors   <or>sk   orientation of reads for %s library number <#> 
(<or> = fr, rf, ff).
Older deprecated syntax is -%s<#>-<or>(   s   <#>s
   <filename>(   s   <#>s
   <filename>(   s   <#>s
   <filename>(   s   <#>s
   <filename>(   s   <#>s
   <filename>(   s   <#>s   <or>(   R   R   Ru   R:   (   t   libidt   namet   suffixesRv   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_library_argsM  sF    




c         C   s  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 d d t |  j d d d d d d d d t t |   | d@ k } t d d d d d d d d g |   |  j d d dA d d d d d t t d d  d d d d d g |  |  t d! d" d d d d d g |  |  t d# d$ d d g |  |  |  j d% d d d d d | sd& n t j d t | d k } |  j d' d d d d d d( d t |  j d) d d d d d d* d t | d k } |  j d+ d d d d d | sBd, n t j d t | d k } |  j d- d d d d d | sd. n t j d t |  j d/ d d d d d | sd0 n t j d t | d k } |  j d1 d d d d d | sd2 n t j d t |  j d3 d d4 d5 d6 d7 d8 d9 g d | s6d: n t j d d; |  j d< d d4 d5 d6 d= d8 d t j d d> |  j d? d5 d6 d= d9 d t j d d> d  S(B   Ns   --12RB   s
   <filename>R   i   RA   s9   file with interlaced forward and reverse paired-end readsR   s   -1s"   file with forward paired-end readss   -2s"   file with reverse paired-end readss   -ss   file with unpaired readss   --mergeds5   file with merged forward and reverse paired-end readsR
   R   t   pes
   paired-endR   R   R   R   R   RF   s   --ss   <#>i   sj   file with unpaired reads for single reads library number <#>.
Older deprecated syntax is --s<#> <filename>t   mps	   mate-pairt   hqmps   high-quality mate-pairt   nxmates   Lucigen NxMates   --sangers   file with Sanger readss   --pacbios   file with PacBio readss
   --nanopores   file with Nanopore readss   --tslrs   file with TSLR-contigss   --trusted-contigss   file with trusted contigss   --untrusted-contigss   file with untrusted contigss   --fl-rnasF   file with PacBio/Nanopore/contigs that capture full-length transcriptss   --sss   <type>R   t   strand_specificityR?   t   frt   rfse   strand specific data, <type> = fr (normal) and rf (antisense).
Older deprecated syntax is --ss-<type>t   stores   --ss-frR<   t   store_consts   --ss-rf(   R
   R   (   s   <#>s
   <filename>(   R   R   R:   Rz   R   R   Ru   (   Rv   R   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_input_data_args  s    	
%%%		c         C   sE  t    } | d k } |  j d d d d d  d | s9 d n t j d d	 |  j d
 d d d d  d | sm d n t j d d	 | d* k } |  j   } | j d d d d d  d | s d n t j d d	 | j d d d d d  d t j d d |  j d d d d d d d d d |  j d d d d d d d	 d t j } | d k r^d t j } n  |  j d d d d d  d d  d! t d | d d |  j   } | j d" d d# d d  d d$ d d	 | j d% d d# d d  d t j d d |  j   } | j d& d d' d d  d d( d d	 | j d) d d' d d  d t j d d d  S(+   NR
   s   --only-error-correctionR   t   only_error_correctionR=   RA   s4   runs only read error correction (without assembling)R   R	   s   --only-assemblert   only_assemblers4   runs only assembling (without read error correction)R   s	   --carefult   carefuls5   tries to reduce number of mismatches and short indelss   --careful:falset   store_falses   --checkpointsRB   s   <last or all>t   checkpointss.   save intermediate check-points ('last', 'all')R   s
   --continuet   continue_modes0   continue run from the last available check-pointsf   restart run with updated options and from the specified check-point
('ec', 'as', 'k<int>', 'mc', '%s')sZ   restart run with updated options and from the specified check-point
('as', 'k<int>', '%s')s   --restart-froms   <cp>Rq   R>   s   --disable-gzip-outputt   disable_gzip_outputs;   forces error correction not to compress the corrected readss   --disable-gzip-output:falses   --disable-rrt
   disable_rrs.   disables repeat resolution stage of assemblings   --disable-rr:false(   R
   R   (	   R   R   R   R   Ru   t   add_mutually_exclusive_groupR   Ro   Rq   (   t   pgroup_pipelineR   R   t   careful_groupt   restart_from_helpt   disable_gzip_output_groupR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_pipeline_args  s    		
		c         C   s}  t    } |  j d d d d t j d d d d d	 d
 |  j d d d d d d d t d d t j d	 d
 |  j d d d d d t d d d d t j d	 d
 |  j d d d d d d d d	 d
 |  j d d d d d d d d t d d t j	 d d	 t
 | d) k } |  j d  d d! d t d" d  d d# d | s>d$ n t j d	 d
 |  j d% d d& d d' d t d d( d	 d
 d  S(*   Ns	   --datasetRB   s
   <filename>R>   R   t   dataset_yaml_filenameRA   s,   file with dataset description in YAML formatR   R   s   -ts	   --threadss   <int>t   threadss!   number of threads. [default: %s]
s   -ms   --memoryt   memorysC   RAM limit for SPAdes in Gb (terminates if exceeded). [default: %s]
s	   --tmp-dirs	   <dirname>s:   directory for temporary files. [default: <output_dir>/tmp]t   tmp_dirs   -kRe   R   t   +sD   list of k-mer sizes (must be odd and less than %d)
[default: 'auto']i   R
   R   s   --cov-cutoffs   <float>R=   Rl   sU   coverage cutoff value (a positive float number, or 'auto', or 'off')
[default: 'off']s   --phred-offsets
   <33 or 64>Rh   sJ   PHRED quality offset in the input reads (33 or 64),
[default: auto-detect](   R
   R   (   R   R   RG   t   check_file_existenceR]   R   t   THREADSt   MEMORYRg   R_   RY   Rl   R   R   Ru   Rh   (   t   pgroup_advancedR   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_advanced_argsA  s\    		c         C   st  d t  j k } |  j   } | j d d d d d  d | r? d n t j d d	 | j d
 d d d d  d t j d d |  j d d d d d d t d | r d n t j d d |  j d d d d d  d | r d n t j d d	 |  j   } | j d d d d d  d | rd n t j d d	 | j d d d d d  d t j d d |  j d d d d d d t j	 d | rzd n t j d d |  j d d d d d d t j	 d | rd  n t j d d |  j d! d d" d d# d t j
 d | rd$ n t j d d |  j d% d d& d d' d t d | r.d( n t j d d |  j d) d d* d t d | rbd+ n t j d d	 |  j d, d d- d d  d | rd. n t j d d	 |  j d/ d d0 d t d d1 d | rd2 n t j d d |  j d3 d d& d d4 d t d | r
d5 n t j d d |  j d6 d d7 d | r8d8 n t j d d	 |  j d d | r`d9 n t j d d d  S(:   Ns   --help-hiddens   --debugR   t   developer_modeR=   RA   s   runs SPAdes in debug modeR   R	   s   --debug:falseR   s   --stop-afterRB   s   <cp>Rr   R>   sR   runs SPAdes until the specified check-point ('ec', 'as', 'k<int>', 'mc') inclusiveR   s   --truseqt   truseq_modes   runs SPAdes in TruSeq modes   --mismatch-correctiont   mismatch_correctors>   runs post processing correction of mismatches and short indelss   --mismatch-correction:falses   --references
   <filename>t	   references:   file with reference for deep analysis (only in debug mode)s   --series-analysist   series_analysiss3   config for metagenomics-series-augmented reassemblys   --configs-dirs   <config_dir>t   configs_dirs   directory with configss   --read-buffer-sizes   <int>t   read_buffer_sizes/   sets size of read buffer for graph constructions   --large-genomet   large_genomes'   Enables optimizations for large genomess	   --save-gpt   save_gpsI   Enables saving graph pack before repeat resolution (even without --debug)s   --hidden-cov-cutoffs   <float>Rm   s   coverage cutoff value deeply integrated in simplification (a positive float number). Base coverage! Will be adjusted depending on K and RL!s   --read-cov-thresholdRt   s5   read median coverage threshold (non-negative integer)s   --only-generate-configt   only_generate_configs2   generate configs and print script to run_spades.shs1   prints this usage message with all hidden options(   t   syst   argvR   R   R   R   Ru   Rr   RG   R   t   check_dir_existenceR]   R   Rm   Rt   (   t   pgroup_hiddent   show_help_hiddent   debug_groupt   mismatch_correction_group(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_hidden_argsz  s    					c       	   C   s   t  j d d d t d d d t  }  |  j d  } |  j d  } |  j d	  } |  j d
  } |  j d  } t |  t |  t |  t |  t	 |  |  S(   NR)   s	   spades.pyt   formatter_classR2   s"   %(prog)s [options] -o <output_dir>R   s   Basic optionss
   Input datas   Pipeline optionss   Advanced optionss   Hidden options(
   R   R   R%   R   t   add_argument_groupR   R   R   R   R   (   RO   R   Rv   R   R   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   create_parser  s    




c         C   s@  t  j j r t j d |   n  t  j j r> t j d |   n  t  j j r] t j d |   n  t  j j r| t j d |   n  t  j j r t j d |   n  t  j j	 r t j d |   n  t  j j
 r t j d |   n  t  j j r t j d |   n  t  j j rt j d	 |   n  t  j j d  k	 r<t j d
 |   n  d  S(   Ns8   you cannot specify --dataset with --restart-from option!s3   you cannot specify --sc with --restart-from option!s5   you cannot specify --meta with --restart-from option!s8   you cannot specify --plasmid with --restart-from option!s4   you cannot specify --rna with --restart-from option!s8   you cannot specify --isolate with --restart-from option!s;   you cannot specify --iontorrent with --restart-from option!s?   you cannot specify --only-assembler with --restart-from option!sF   you cannot specify --only-error-correction with --restart-from option!sV   you cannot specify strand specificity (--ss-rf or --ss-fr) with --restart-from option!(   R   R    R   RG   t   errorR|   R   R   R
   R   R}   R   R   R   R   (   t   log(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   check_options_for_restart_from  s(    c         C   s.  |  j  r t |  n  t t j  |  j r | s d t j k rc t j j d  k	 rc t j	 d  n  t
 j j d  t j _ q n1 d t j k s t j j d  k r t j	 d  n  | s t t |  j   } | t j |  j <t j | d  | |  _ n  |  j d  k	 rIt t |  j   } | t j |  j <t j | d  | |  _ n  d |  k rp|  j d  k	 rpt |  _ n  |  j r|  j rt j	 d  n  |  j r|  j rt j	 d	 |  n  |  j r|  j rt j	 d
 |  n  |  j t k r
|  j t k r
t j	 d  n  |  j t k r8|  j t k r8t j	 d  n  |  j rf|  j sS|  j rft j	 d |  n  |  j r|  j s|  j rt j	 d |  n  |  j r|  j rt j d  n  |  j  d  k	 rt |  _ n  |  j d  k	 r|  j |  _ n  |  j rt   n  |  j s|  j r*|  j r*t |  _ n  d  S(   NR{   s/   you cannot specify -o and --test simultaneouslyt   spades_testsG   the output_dir is not set! It is a mandatory parameter (-o output_dir).s   output directorys   directory for temporary filesR   sN   you cannot specify --only-error-correction and --only-assembler simultaneouslys;   you cannot specify --only-error-correction in RNA-seq mode!s;   you cannot specify --only-error-correction in isolate mode!sK   you cannot specify --mismatch-correction and --careful:false simultaneouslysK   you cannot specify --mismatch-correction:false and --careful simultaneouslysF   you cannot specify --mismatch-correction or --careful in RNA-seq mode!sF   you cannot specify --mismatch-correction or --careful in isolate mode!sL   Isolate mode already implies --only-assembler, so this option has no effect.(    Rq   R   R!   R   R    R~   R{   R   RG   R   t   ost   pathR   R   t   dict_of_rel2abst   check_path_is_asciiR   R   R   R   R   R   R
   R   R   R   R   t   warningR   R   t   enable_truseq_modeR}   (   R    R   t   skip_output_dirR{   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   add_to_option  s\    		!!	
c            s  t    |  d <t    |  d <| j s3 t    |  d <n  | j sL t    |  d <n  | j |  d j d <| j |  d j d <| j |  d j d <| j |  d j d <| j |  d j d	 <| j	 |  d j d
 <| j
 r | j
 |  d j d <n  | j rht j j | t j      f d   } d j g  t j    D]' } | |  r*t j j   |  ^ q* |  d j d <n  | j |  d j d <| j	 r| j r| j |  d j d <n  | j s{t j j |  d j d  |  d j d <| j |  d j d <| j r
| j |  d j d <n  | j |  d j d <t j |  d j d <| j sD| j rXd |  d j d <n  | j r{| j |  d j d <q{n  | j s| j d k r| j d  k rd  | _ n  | j r| j |  d j d <n1 | j rd |  d j d <n t j |  d j d <| j  |  d j d <| j! |  d j d <| j" |  d j d <| j# |  d j d <| j ro| j |  d j d <n  t j$ |  d j d <n  | j r| j% rt    |  d  <d  |  d  j d! <t j j | d"  |  d  j d# <| j |  d  j d$ <| j |  d  j d% <n  t j& |  d& <d  S('   Nt   commont   datasett   error_correctiont   assemblyR   R{   R   t   max_threadst
   max_memoryR   R   c            s=   t  j j t  j j   |    o< |  j d  p< |  j d  S(   Nt   hmms   hmm.gz(   R   R   t   isfilet   joint   endswith(   t   hmmfile(   t   biosyntheticspades_hmms_path(    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   <lambda>e  s   !Rc   t   set_of_hmmst   yaml_filenameR   t	   correctedt   gzip_outputRh   R}   t   max_iterationsi   t   count_filter_singletonsR   RZ   t   iterative_KR   Rl   Rm   R   t   correct_scaffoldsR   s   skip-maskeds
   spades-bwat   bwaR   s
   output-dirt   run_truseq_postprocessing('   R   R   R   R   RW   R{   R   R   R   R   R   R   R   R   R   R   t   biosyntheticspades_hmmst   listdirR   R   R   Rh   R}   t
   ITERATIONSR   R   R   Re   Rq   R   R
   t   K_MERS_SHORTR   Rl   Rm   R   R   R   R   (   t   cfgR   t   bin_homet   spades_homeR    t
   is_hmmfileR   (    (   R   sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt
   add_to_cfgQ  sp    					8	'						 c         C   s  t  j j d  r! d d  l } n! t  j j d  rB d d  l } n  |  j r |  j r t j d t	 j
 j | d  |  t j d t	 j
 j | d  |  q t j d t	 j
 j | d  |  t j d t	 j
 j | d	  |  n  |  j r t |  _ n  |  j st j d
 |  n  t	 j
 j |  j  sW|  j rDt j d |  n  t	 j |  j  n  |  j sf| r|  j rt j |  st j d |  n  t   q)t   n |  j r)t j d t  }	 |	 j d d d d d |	 j d d t d d d t |	 j |  \ }
 } | r)t j d |  q)n  |  j rx|  j sb|  j  sb|  j! d k rx|  j! d  k	 rxt j d |  qxn  |  j# r|  j rt j d |  qn  |  j |  j$ |  j% |  j# |  j |  j& |  j' g j( t  } | d k r|  j |  j g j( t  d k  rt j d |  n | d k r5t j) d  n  |  j rBd  Sd  } t	 j
 j |  j d  } | rt	 j
 j* |  ry | j+ t, |   } Wq| j- k
 rd  } qXqn  | d  k	 r| } n |  j. r\y | j+ t, |  j.   } WnG | j- k
 r7t  j/   \ } } } t j d  |  j. t |   n Xt j0 | t	 j
 j1 |  j.   } n' t j2 |  } t j0 | t	 j3    } | |  _. t j4 | |  j5 p|  j# |  j6 |  t j7 | t8 j9  st j d!  n  |  j# r-t: |  t: t j7 | t8 j;   k r-t j d" d# j t8 j;  d$  q-n  |  j r|  j< rt: t j7 | d%   d k st: |  t= d t: t j7 | d& d' d( g    d k rt j d)  qn  | d  k rt, |  j. d*  / } | j> | | d+ t d, d- d. t? d/  Wd  QXn  t@   | S(0   Ns   2.is   3.s   -1s   test_dataset_plasmid/pl1.fq.gzs   -2s   test_dataset_plasmid/pl2.fq.gzs   test_dataset/ecoli_1K_1.fq.gzs   test_dataset/ecoli_1K_2.fq.gzsG   the output_dir is not set! It is a mandatory parameter (-o output_dir).sB   the output_dir should exist for --continue and for --restart-from!s4   you cannot specify reads with --restart-from option!R   s
   --continueR   R   R   R	   s   -oR>   R{   s   you cannot specify any option except -o with --continue option! Please use '--restart-from last' if you need to change some of the options from the initial run and continue from the last available checkpoint.Ri   sX   you cannot specify --careful, --mismatch-correction or --cov-cutoff in metagenomic mode!s-   you cannot specify --careful in RNA-Seq mode!i   i   s   you cannot simultaneously use more than one mode out of Isolate, Metagenomic, Large genome, Illumina TruSeq, RNA-Seq, Plasmid, and Single-cell (except combining Metagenomic and Plasmid)!i    sx   No assembly mode was sepcified! If you intend to assemble high-coverage multi-cell/isolate data, use '--isolate' option.s   input_dataset.yamls/   exception caught while parsing YAML file (%s):
sY   you should specify at least one unpaired, paired-end, or high-quality mate-pairs library!s)   you cannot specify any data types except s   , s    in RNA-Seq mode!s
   paired-endt   tslrt   pacbiot   nanopores   you cannot specify any data types except a single paired-end library (optionally accompanied by a single library of TSLR-contigs, or PacBio reads, or Nanopore reads) in metaSPAdes mode!t   wt   default_flow_stylet   default_stylet   "R,   t   inf(A   R   R$   Rp   t   pyyaml2t   pyyaml3R~   R   RG   RN   R   R   R   R   R   R   R{   R   t   isdirR   t   makedirsRq   t   dataset_is_emptyt   save_restart_optionst   load_restart_optionsR   R   R   R   R   RV   R   R   R   Rl   R   R
   R   R   R|   R   t   countR   R   t   loadt   opent	   YAMLErrorR   t   exc_infot   relative2abs_pathst   dirnamet   correct_datasett   getcwdt   check_dataset_readsR   R}   t   get_lib_ids_by_typeR   t    READS_TYPES_USED_IN_CONSTRUCTIONRL   t   READS_TYPES_USED_IN_RNA_SEQR   t   mint   dumpRk   t   set_default_values(   R    R   RC   R   R   t   load_processed_datasetRq   R   t   pyyamlt   continue_parserR   R   t   modes_countt   existing_dataset_datat   processed_dataset_fpatht   _t   exct   f(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   postprocessing  s    		"%"%				

			0			9-	
					%	!("c      	   C   s  t    } t   } | r3 t j j } t j j }	 n  | }
 | } | j |  \ t _ } t j j d  k	 r | r x( t j j	 D] } | j
 i d  | 6  q} W| j |  \ t _ } n  | r d } | j | d j |   n  | r | t j _ |	 t j _ n  t t j |  |
  d t j k r1t j j } n	 t   } t t j | | |  | | | |  } t j j rzt j d  d  f St | |  | | t j  t j | | f S(   NsI   Please specify option (e.g. -1, -2, -s, etc)) for the following paths: %ss   , RC   (   R8   R   R   R    R{   Rr   R   Rq   R   RW   t   set_defaultsR   R   R   RC   R9   R  R   R   (   R   R   R   t   secondary_fillingRq   R   R   RO   t   old_output_dirt   old_stop_afterR   R  R   RS   t   msgRC   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt
   parse_args  s8    			c         C   s   t    } | j   d  S(   N(   R   t
   print_help(   R"   t   show_hiddenR   RO   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR2   /  s    	c           C   se  t  j j d  k r$ t  j t  j _ n  t  j j d  k r{ t j   ri t t	 t  j
 t j     t  j _ q{ t  j
 t  j _ n  t  j j d  k r t t  j _ n  t  j j d  k r t t  j _ n  t  j j d  k r t t  j _ n  t  j j d  k r t t  j _ n  t  j j d  k r d t  j _ n  t  j j d  k rAt t  j _ n  t  j j d k rbd  t  j _ n  t  j j d  k rd t  j _ n  t  j j d  k rt j j t  j j t  j  t  j _ n  t  j j d  k rt t  j _ n  t  j j d  k rt t  j _ n  t  j j d  k rt t  j _ n  t  j j d  k r@t t  j _ n  t  j j d  k rat t  j _ n  d  S(   Nt   noneRZ   Ri   (   R   R    R   R   R   R   RG   t   get_available_memoryR]   R  R   R   R   R   R   R   R   R   Rh   Rl   R   R   R   R   R{   t   TMP_DIRR   R   R   R   R   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR  4  sD    ''c           C   sC   t  j t t j    t _ d  t j _ d  t j _ d  t j _	 d  S(   N(
   R   t	   Namespacet   varsR   R    t   restartR   R   Rq   R{   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR   Z  s    c          C   s   d t  j k rl t  j j rl t  j j t  _ t  j j d k rK d  t  j _ n t  j j t  j _ d  t  j _ n  xG t  j j D]9 }  t  j j |  d  k	 ry t  j j |  t  j j |  <qy qy Wd  S(   NRe   RZ   (   R   R%  Re   R    t   original_k_mersR   RW   (   t   option(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR   a  s    c           C   sy   d d d d g t  _ d d d d d g t  _ d d d d d d d g t  _ t t  j _ t t  _ t t  _ t t  j _	 d  S(   Ni   i!   i-   i7   iM   ic   i   (
   R   R   t
   K_MERS_150t
   K_MERS_250R   R    R   R   R   R   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyR   o  s    		c         C   s:   x3 |  D]+ \ } } | d k s. | j  d  r t Sq Wt S(   Ns
   --continues   --restart-from(   Rp   R   R   (   R   RT   RS   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt
   will_reruny  s
    	c       
   C   sy   t  j d t  }  |  j d d d d d |  j d d d d	 d  d
 t d d |  j   \ } } | j pw | j d  k	 S(   NR   s
   --continueR   R   R   R	   s   --restart-fromRq   R=   R>   R   (   R   R   R   R   R   Rq   R   R   (   R  R   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   is_first_run  s
    %c          C   si   t  j d t  }  |  j d d t d d d t |  j   \ } } | j d  k rV d  St	 t
 | j   S(   NR   s   -oR>   R   R{   R   (   R   R   R   R   R   RV   R   R{   R   R   R   (   t   output_parserR   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   get_output_dir_from_args  s    (5   R   R   R   R    t   os.pathR   R   R   RG   R   t   process_cfgR   R   R!   R$   R0   R%   R9   t   ActionR:   RV   RY   Rb   Rg   Rh   Rl   Rm   Rq   Rr   Rt   Rz   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R2   R  R   R   R   R*  R+  R-  (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/spades_pipeline/options_parser.pyt   <module>	   sZ   				&		
								7	:6	q	M	9	m			@	Hl*	&			
		