
Xgac           @   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 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	 rHd	 }  nl | d k s]| j
 rfd }  nN | d k s{| j rd }  n0 | j rd }  n | d k s| j rd }  n  | d k s| j r| j s| j rd }  n  | d k s| j rd }  n  | d k s| j r d }  n  |  S(    Ni    t   add_helps	   --isolatet   destt   isolatet   actiont
   store_trues   --rnat   rnas	   --plasmidt   plasmids   --metat   metas   --biot   bios   --metaviralt	   metavirals   --metaplasmidt   metaplasmids
   --rnaviralt   rnavirals   --coronat   coronas   rnaspades.pys   rnaviralspades.pys   plasmidspades.pyt   bgcs   metaspades.pys   metaplasmidspades.pys   metaviralspades.pys   coronaspades.py(   t   NoneR   t   options_storaget   first_command_linet   argparset   ArgumentParsert   Falset   add_argumentt   parse_known_argsR
   R   R   R   R   R   R   R   (   t   modet   script_basenamet   optionst   mode_parsert   nargst   unknown_args(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   get_mode   s>    							'			c         C   s  t    } | d k r! t |  _ n | d k r9 t |  _ n | d k rZ t |  _ t |  _ n | d k rr t |  _ n | d k r t |  _ t |  _ t |  _ nu | d k r t |  _ t |  _ t |  _ nK | d k r t |  _ t |  _ n* | d k rt |  _ t |  _ t |  _	 n  d  S(	   NR
   R   R   R   R   R   R   R   (
   R!   t   TrueR
   R   R   R   R   R   R   R   (   t   argsR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   add_mode_to_args8   s2    									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.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   versionU   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.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR*   ^   s    c         C   s
   | j    S(   N(   t
   splitlines(   R+   t   textR/   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   _split_linesa   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.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR4   d   s    N(   t   __name__t
   __module__R*   R2   R   R4   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR(   ]   s   	c           C   s   t    S(   N(   t   dict(    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   init_dataset_dataj   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.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR*   o   s    'c         C   s^  | d k r t  t _ n  | t j k r3 t t _ n  d | k sN | j d  k rj 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	 } qD| d	 } n% | } t |  d k rD| 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_optionsRF   R   R<   t   setattrt   lent   splitt   add_to_dataset(   R+   t   parsert	   namespacet   valuest   option_stringRF   t   argt   opt(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   __call__t   s(    	N(   R9   R:   R   R   R*   RX   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR=   n   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@   RA   RB   RC   RD   RE   (   R)   RY   R*   (   R+   R>   R   R   R?   R@   RA   RB   RC   RD   RE   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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   ArgumentErrorRN   (   R+   RR   RS   RT   RU   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyRX      s    N(   R9   R:   R   R   R*   RX   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyRY      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@   RA   RB   RC   RD   RE   (   R)   R\   R*   (   R+   R>   R   R   R?   R@   RA   RB   RC   RD   RE   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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(   RO   R   R[   RN   R   (   R+   RR   RS   RT   RU   t   outert   x(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyRX      s    &"N(   R9   R:   R   R   R*   RX   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR\      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(   NR]   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(   RV   t   k(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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    (   RP   t   rangeRO   Re   (   RV   t   k_merst   i(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   kmers   s    c         C   s   |  d k r |  St  |   Sd  S(   NR]   (   R`   (   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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(   NR]   t   offg        sG   wrong value %s (should be a positive float number, or 'auto', or 'off')(   RJ   t   is_floatt   floatR   Rc   (   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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)(   RJ   Rm   Rn   R   Rc   (   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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(   NRd   s>   wrong value %s (should be 'ec', 'as', 'k<int>', 'mc', or '%s')(   R   t   SHORT_STAGES_NAMEt
   LAST_STAGEt
   startswithR   Rc   (   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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(   NRd   s8   wrong value %s (should be 'ec', 'as', 'k<int>', or 'mc')(   R   Rq   Rs   R   Rc   (   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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)(   RJ   t   is_intR`   R   Rc   (   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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 q Wd  S(   Ni   i
   s   -12s   -1s   -2s   -ss   --pe%d%sRE   s
   <filename>R   RD   R   s   --mp%d%ss
   --hqmp%d%ss   -frs   -rfs   -ffi    s   --s%ds   --pe%d-m(   Rg   R   R   t   SUPPRESSR=   (   t   pgroup_input_datat   numt   sufixt   orientation(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   add_deprecated_input_data_args   sP    								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 | sx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 d, d
 d |  j d- d d. d d/ d
 d |  j d0 d1 d d2 d
 d |  j d3 d4 d d5 d
 d6 d6 t   d  S(7   Ns   -oRE   s   <output_dir>RD   s5   directory to store all the resulting files (required)RA   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   s*   this flag is required for metagenomic datas   --bioR   s1   this flag is required for biosyntheticSPAdes modes   --coronaR   s+   this flag is required for coronaSPAdes modes   --rnaR
   s&   this flag is required for RNA-Seq datas	   --plasmidR   s1   runs plasmidSPAdes pipeline for plasmid detections   --metaviralR   s1   runs metaviralSPAdes pipeline for virus detections   --metaplasmidR   so   runs metaplasmidSPAdes pipeline for plasmid detection in metagenomic datasets (equivalent for --meta --plasmid)s
   --rnaviralR   s9   this flag enables virus assembly module from RNA-Seq datas   --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   RY   R   Rx   R'   (   t   pgroup_basicR   t   help_hidden(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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-12RE   s   <#>s
   <filename>R   i   RD   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>RI   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   Rx   R=   (   t   libidt   namet   suffixesRy   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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 |   | dB k } t d d d d d d d d g |   |  j d d dC d d d d d t t d d  d d d d d g |  |  t d! d" d 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 | s&d* n t j d t |  j d+ d d d d d | sZ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 d0 d1 d2 d3 d4 d5 g d | sd6 n t j d d7 |  j d8 d d0 d1 d2 d9 d4 d t j d d: |  j d; d1 d2 d9 d5 d t j d d: | d< k om| d= k om| d> k om| d? k } |  j d@ d d d d d | sdA n t j d t d  S(D   Ns   --12RE   s
   <filename>R   i   RD   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   RI   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-pairs   --sangers   file with Sanger readss   --pacbios   file with PacBio readss
   --nanopores   file with Nanopore readss   --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_specificityRB   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-rfR   R   R   R   s   --assembly-graphs   file with assembly graph(   R
   R   (   s   <#>s
   <filename>(   R!   R   R=   R}   R   R   Rx   (   Ry   R   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   add_input_data_args  s    	
%%%		0c         C   sQ  t    } | d k p | d k } |  j d d d d d  d | sE d n t j d	 d
 |  j d d d d d  d | sy 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 rj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
   R   s   --only-error-correctionR   t   only_error_correctionR@   RD   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   --checkpointsRE   s   <last or all>t   checkpointss.   save intermediate check-points ('last', 'all')R   s
   --continuet   continue_modesN   continue run from the last available check-point (only -o should be specified)sf   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>Rt   RA   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!   R   R   R   Rx   t   add_mutually_exclusive_groupR   Rr   Rt   (   t   pgroup_pipelineR   R   t   careful_groupt   restart_from_helpt   disable_gzip_output_groupR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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
 |  j d* d d d d+ d d, d	 d
 d  S(.   Ns	   --datasetRE   s
   <filename>RA   R   t   dataset_yaml_filenameRD   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   -kRh   R   t   +sD   list of k-mer sizes (must be odd and less than %d)
[default: 'auto']i   R
   R   R   s   --cov-cutoffs   <float>R@   Ro   sU   coverage cutoff value (a positive float number, or 'auto', or 'off')
[default: 'off']s   --phred-offsets
   <33 or 64>Rk   sJ   PHRED quality offset in the input reads (33 or 64),
[default: auto-detect]s   --custom-hmmst   custom_hmmssE   directory with custom hmms that replace default ones,
[default: None](   R
   R   R   (   R!   R   RJ   t   check_file_existenceR`   R   t   THREADSt   MEMORYRj   Rb   R\   Ro   R   R   Rx   Rk   (   t   pgroup_advancedR   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   add_advanced_args`  sf    		c         C   s  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 | 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 d  d | r	d n t j d d	 |  j   } | j d d d d d  d | rI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 | 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 j
 d | r(d' n t j d d |  j d( d d) d d* d t d | rbd+ n t j d d |  j d, d d- d t d | rd. n t j d d	 |  j d/ d d0 d d  d | rd1 n t j d d	 |  j d2 d d3 d t d d4 d | rd5 n t j d d |  j d6 d d) d d7 d t d | r>d8 n t j d d |  j d9 d d: d | rld; n t j d d	 |  j d< d d= d | rd> n t j d d	 |  j d d | rd? n t j d d d  S(@   Ns   --help-hiddens   --debugR   t   developer_modeR@   RD   s   runs SPAdes in debug modeR   R	   s   --debug:falseR   s   --trace-timet   time_tracers   enable time trackers   --stop-afterRE   s   <cp>Ru   RA   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>Rp   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-thresholdRw   s5   read median coverage threshold (non-negative integer)s   --only-generate-configt   only_generate_configs2   generate configs and print script to run_spades.shs   --no-clear-aftert   no_clear_afters5   don't delete tmp files after SPAdes pipeline finisheds1   prints this usage message with all hidden options(   t   syst   argvR   R   R   R   Rx   Ru   RJ   R   t   check_dir_existenceR`   R   Rp   Rw   (   t   pgroup_hiddent   show_help_hiddent   debug_groupt   mismatch_correction_group(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   add_hidden_args  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_classR5   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   (   RR   R   Ry   R   R   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   create_parser  s    




c         C   st  d t  j k r4 t  j j d  k	 r4 t j d |   n  t  j j rS t j d |   n  t  j j rr 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 rKt j d |   n  t  j j d  k	 rpt j d |   n  d  S(   NRF   s[   you cannot specify input data (-1, -2, -12, --pe-1, --pe-2 ...) with --restart-from option!s8   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#   RF   R   RJ   t   errorR   R   R   R   R
   R   R   R   R   R   (   t   log(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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  |  j d  k	 rt t |  j   } t j | d  | |  _ n  d |  k r|  j d  k	 rt |  _ n  |  j rt |  _ n  |  j r|  j rt j	 d	  n  |  j s|  j r|  j rt j	 d
 |  n  |  j r:|  j r:t j	 d |  n  |  j t k rh|  j t k rht j	 d  n  |  j t k r|  j t k rt j	 d  n  |  j r|  j s|  j rt j	 d |  n  |  j r|  j s|  j rt j	 d |  n  |  j r|  j rt j d  n  |  j r6|  j r6t j d  n  |  j  d  k	 rQt |  _ n  |  j d  k	 ro|  j |  _ n  |  j  rt!   n  |  j s|  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 filess   directory with custom hmmsR   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.sH   RNA mode already implies --only-assembler, so this option has no effect.(#   Rt   R   R$   R   R#   R   R~   R   RJ   R   t   ost   pathR   R   t   dict_of_rel2abst   check_path_is_asciiR   R   R   R"   R   R   R   R   R
   R   R   R   R   R   t   warningR   R   t   enable_truseq_modeR   (   R#   R   t   skip_output_dirR~   R   R   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   add_to_optionD  sl    		!!		
%c   	      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
 |  d j d <| j r | j |  d j d <n  d  } | j d  k	 r| j } nH | j r=t j j | t j  } n$ | j rat j j | t j  } n  | d  k	 r.d } d   } t j j |  rd j g  t j |  D]6 } | t j j | |   rt j j | |  ^ q } n | |  r| } n  | d k rt j d |  n  | |  d j d <n  | j |  d j d <| j	 rk| j rk| j |  d j d <n  | j sA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  s
| j! rd |  d j d <n  | j" rA| j" |  d j d <qAn  | j sU| j# d k rt| j$ d  k rtd  | _# n  | j# r| j# |  d j d <n: | j% s| 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" r>| 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   R   RG   c         S   sL   t  j j |   oK |  j d  pK |  j d  pK |  j d  pK |  j d  S(   Nt   hmms   hmm.gzt   aas   aa.gz(   R   R   t   isfilet   endswith(   t   hmmfile(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   <lambda>  s   Rf   sX   Custom HMM folder does not contain any HMMs. They should have .hmm or .hmm.gz extension.t   set_of_hmmst   yaml_filenameR   t	   correctedt   gzip_outputRk   R   t   max_iterationsi   t   count_filter_singletonsR   R]   t   iterative_KR   Ro   Rp   R   t   correct_scaffoldsR   s   skip-maskeds
   spades-bwat   bwaR   s
   output-dirt   run_truseq_postprocessing(/   R   R   R   R   RZ   R~   R   R   R   R   R   R   R   R   R   R   R   t   joinR   t   biosyntheticspades_hmmsR   t   coronaspades_hmmst   isdirt   listdirRJ   R   R   R   R   Rk   R   t
   ITERATIONSR   R   R   Rh   Rt   R
   R   t   K_MERS_SHORTR   Ro   Rp   R   R   R   R   (	   t   cfgR   t   bin_homet   spades_homeR#   t	   hmms_patht   hmmst
   is_hmmfileR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt
   add_to_cfg  s    							<		'					 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 s |  j r t |  _ n  |  j st j d
 |  n  t	 j
 j |  j  s`|  j rMt j d |  n  t	 j |  j  n  |  j so| r|  j rt j |  st j d |  n  t   q2t   n |  j r2t j d t  }	 |	 j d d d d d |	 j d d t d d d t |	 j |  \ }
 } | r2t j d |  q2n  |  j r|  j  sk|  j! sk|  j" d k r|  j" d  k	 rt j d |  qn  |  j$ s|  j r|  j  rt j d |  qn  |  j |  j% |  j& |  j$ |  j |  j' |  j( |  j g j) t  } | d k rs|  j |  j g j) t  d k  rs|  j |  j g j) t  d k  rs|  j |  j g j) t  d k  rst j d |  n | d k rt j* d  n  |  j rd  Sd  } t	 j
 j |  j d  } | rt	 j
 j+ |  ry | j, t- |   } Wq| j. k
 rd  } qXqn  | t/ _0 |  j1 ry | j, t- |  j1   t/ _0 WnG | j. k
 rt  j2   \ } } } t j d  |  j1 t |   n Xt j3 t/ j0 t	 j
 j4 |  j1   t/ _0 n3 t j5 t/ j0  t/ _0 t j3 t/ j0 t	 j6    t/ _0 | d  k	 r| } n	 t/ j0 } | |  _1 t j7 | |  j8 p%|  j$ |  j9 |  t j: | t/ j;  sWt j d!  n  |  j$ rt< |  t< t j: | t/ j=   k rt j d" d# j t/ j=  d$  qn  |  j ra|  j> ra|  j rat? d t< t j: | d%    } t? d t< t j: | d&    } t? d t< t j: | d' d( g    } t< |  | | | k rat j d)  qan  | d  k rt- |  j1 d*  / } | j@ | | d+ t d, d- d. tA d/  Wd  QXn  tB   | 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   -oRA   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.Rl   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 specified! 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-ends   assembly-grapht   pacbiot   nanopores   you cannot specify any data types except a single paired-end library (optionally accompanied by a single library of PacBio reads or Nanopore reads) in metaSPAdes mode!t   wt   default_flow_stylet   default_stylet   "R/   t   inf(C   R   R'   Rs   t   pyyaml2t   pyyaml3R   R   RJ   RQ   R   R   R   R   R   R"   R   R~   R   R   R   t   makedirsRt   t   dataset_is_emptyt   save_restart_optionst   load_restart_optionsR   R   R   R   R   RY   R   R   R   Ro   R   R
   R   R   R   R   t   countR   R   t   loadt   opent	   YAMLErrorR   t   original_dataset_dataR   t   exc_infot   relative2abs_pathst   dirnamet   correct_datasett   getcwdt   check_dataset_readsR   R   t   get_lib_ids_by_typet    READS_TYPES_USED_IN_CONSTRUCTIONRO   t   READS_TYPES_USED_IN_RNA_SEQR   t   maxt   dumpRn   t   set_default_values(   R#   R   RF   R   R   t   load_processed_datasetRt   R   t   pyyamlt   continue_parserR   R    t   modes_countt   existing_dataset_datat   processed_dataset_fpatht   _t   exct   paired_end_libst
   graph_libst   long_read_libst   f(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   postprocessing  s    		"%"%			

			0		?o	
						%	!!!'"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   , RF   (   R;   R   R   R#   R~   Ru   R   Rt   R   RZ   t   set_defaultsR   R   R   RF   R<   R"  R   R   (   R   R   R   t   secondary_fillingRt   R   R   RR   t   old_output_dirt   old_stop_afterR   R  R   RV   t   msgRF   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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   RR   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR5     s    	c           C   s  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t t  j _ n  t  j j d k r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 rat t  j _ n  t  j j d  k rt t  j _ n  d  S(   Nt   noneR]   Rl   (    R   R#   R   R   R   R   RJ   t   get_available_memoryR`   t   minR   R   R   R   R   R   R   R   R   Rk   Ro   R   R   R   R   R~   t   TMP_DIRR   R   R   R   R   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR    sH    ''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   Rt   R~   (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR    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(   NRh   R]   (   R   R1  Rh   R#   t   original_k_mersR   RZ   (   t   option(    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR    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.15.4-Linux/share/spades/spades_pipeline/options_parser.pyR     s    		c         C   s:   x3 |  D]+ \ } } | d k s. | j  d  r t Sq Wt S(   Ns
   --continues   --restart-from(   Rs   R"   R   (   R   RW   RV   (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt
   will_rerun  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-fromRt   R@   RA   R   (   R   R   R   R   R   Rt   R   R   (   R  R   R    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-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   -oRA   R   R~   R   (   R   R   R   R   R   RY   R   R~   R   R   R   (   t   output_parserR   R    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   get_output_dir_from_args  s    (5   R   R   R   R    t   os.pathR   R   R   RJ   R   t   process_cfgR   R!   R$   R'   R3   R(   R<   t   ActionR=   RY   R\   Re   Rj   Rk   Ro   Rp   Rt   Ru   Rw   R}   R   R   R   R   R   R   R   R   R   R   R   R   R"  R(  R5   R  R  R  R   R6  R7  R9  (    (    (    sr   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/spades_pipeline/options_parser.pyt   <module>	   sZ   	$			&		
								-	N6	p	M	@	x			K	Zs*	(			
		