
:>"^                 @   s  d  Z  d d l m Z d d l m Z m Z m Z Gd d   d e  Z Gd d   d e  Z Gd d	   d	 e  Z	 Gd
 d   d e  Z
 Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd  d!   d! e  Z Gd" d#   d# e  Z Gd$ d%   d% e  Z Gd& d'   d' e  Z Gd( d)   d) e  Z Gd* d+   d+ e  Z Gd, d-   d- e  Z Gd. d/   d/ e  Z Gd0 d1   d1 e  Z Gd2 d3   d3 e  Z Gd4 d5   d5 e  Z Gd6 d7   d7 e  Z  Gd8 d9   d9 e  Z! e" d: k rd d; l# m$ Z$ e$   d< S)=zCode to interact with and run various EMBOSS programs.

These classes follow the AbstractCommandline interfaces for running
programs.
    )print_function)_Option_SwitchAbstractCommandlinec               @   s%   e  Z d  Z d Z d d d  Z d S)_EmbossMinimalCommandLinea  Base Commandline object for EMBOSS wrappers (PRIVATE).

    This is provided for subclassing, it deals with shared options
    common to all the EMBOSS tools:

    Attributes:
     - auto               Turn off prompts
     - stdout             Write standard output
     - filter             Read standard input, write standard output
     - options            Prompt for standard and additional values
     - debug              Write debug output to program.dbg
     - verbose            Report some/full command line options
     - help               Report command line options. More
                          information on associated and general
                          qualifiers can be found with -help -verbose
     - warning            Report warnings
     - error              Report errors
     - fatal              Report fatal errors
     - die                Report dying program messages

    Nc             K   s  | d  k	 s t   t d d g d  t d d g d  t d d g d	  t d
 d g d  t d d g d  t d d g d  t d d g d  t d d g d  t d d g d  t d d g d  g
 } y | |  j |  _ Wn t k
 r | |  _ Yn Xt j |  | |  d  S)Nz-autoZautozTurn off prompts.

                    Automatic mode disables prompting, so we recommend you set
                    this argument all the time when calling an EMBOSS tool from
                    Biopython.
                    z-stdoutstdoutzWrite standard output.z-filterfilterz+Read standard input, write standard output.z-optionsoptionszPrompt for standard and additional values.

                    If you are calling an EMBOSS tool from within Biopython,
                    we DO NOT recommend using this option.
                    z-debugdebugz"Write debug output to program.dbg.z-verboseverbosez%Report some/full command line optionsz-helphelpzReport command line options.

                    More information on associated and general qualifiers can
                    be found with -help -verbose
                    z-warningwarningzReport warnings.z-errorerrorzReport errors.z-dieZdiezReport dying program messages.)AssertionErrorr   
parametersAttributeErrorr   __init__)selfcmdkwargsextra_parameters r   </tmp/pip-build-ww9dw3qa/biopython/Bio/Emboss/Applications.pyr   ,   s4    z"_EmbossMinimalCommandLine.__init__)__name__
__module____qualname____doc__r   r   r   r   r   r      s   r   c               @   s1   e  Z d  Z d Z d d d  Z d d   Z d S)_EmbossCommandLinezBase Commandline object for EMBOSS wrappers (PRIVATE).

    This is provided for subclassing, it deals with shared options
    common to all the EMBOSS tools plus:

     - outfile            Output filename

    Nc             K   sy   | d  k	 s t   t d d g d d d g } y | |  j |  _ Wn t k
 ra | |  _ Yn Xt j |  | |  d  S)Nz-outfileoutfilezOutput filenamefilenameT)r   r   r   r   r   r   )r   r   r   r   r   r   r   r   e   s    z_EmbossCommandLine.__init__c             C   s4   |  j  p |  j p |  j s' t d   t j |   S)Nz]You must either set outfile (output filename), or enable filter or stdout (output to stdout).)r   r   r   
ValueErrorr   	_validate)r   r   r   r   r!   u   s    z_EmbossCommandLine._validate)r   r   r   r   r   r!   r   r   r   r   r   [   s   r   c               @   s%   e  Z d  Z d Z d d d  Z d S)Primer3Commandlinea  Commandline object for the Primer3 interface from EMBOSS.

    The precise set of supported arguments depends on your version of EMBOSS.
    This version accepts arguments current at EMBOSS 6.1.0, but in order to
    remain backwards compatible also support the old argument names as well.

    e.g. Using EMBOSS 6.1.0 or later,

    >>> cline = Primer3Commandline(sequence="mysequence.fas", auto=True, hybridprobe=True)
    >>> cline.explainflag = True
    >>> cline.osizeopt=20
    >>> cline.psizeopt=200
    >>> cline.outfile = "myresults.out"
    >>> cline.bogusparameter = 1967     # Invalid parameter
    Traceback (most recent call last):
        ...
    ValueError: Option name bogusparameter was not found.
    >>> print(cline)
    eprimer3 -auto -outfile=myresults.out -sequence=mysequence.fas -hybridprobe=True -psizeopt=200 -osizeopt=20 -explainflag=True

    The equivalent for anyone still using an older version of EMBOSS would be:

    >>> cline = Primer3Commandline(sequence="mysequence.fas", auto=True, hybridprobe=True)
    >>> cline.explainflag = True
    >>> cline.oligosize=20              # Old EMBOSS, instead of osizeopt
    >>> cline.productosize=200          # Old EMBOSS, instead of psizeopt
    >>> cline.outfile = "myresults.out"
    >>> print(cline)
    eprimer3 -auto -outfile=myresults.out -sequence=mysequence.fas -hybridprobe=True -productosize=200 -oligosize=20 -explainflag=True

    Zeprimer3c          J   K   s6  t  d d g d d d t  d d g d  t  d	 d
 g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d   t  d! d" g d#  t  d$ d% g d&  t  d' d( g d)  t  d* d+ g d,  t  d- d. g d/  t  d0 d1 g d2  t  d3 d4 g d5  t  d6 d7 g d8  t  d9 d: g d;  t  d< d= g d>  t  d? d@ g dA  t  dB dC g dD  t  dE dF g dG  t  dH dI g dJ  t  dK dL g dM  t  dN dO g dP  t  dQ dR g dS  t  dT dU g dV  t  dW dX g dY  t  dZ d[ g d\  t  d] d^ g d_  t  d` da g db  t  dc dd g de  t  df dg g dh  t  di dj g dk  t  dl dm g dn  t  do dp g dq  t  dr ds g dt  t  du dv g dw  t  dx dy g dz  t  d{ d| g d}  t  d~ d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  gH |  _ t j |  | |  d S)zInitialize the class.z	-sequencesequencez Sequence to choose primers from.is_requiredTz-taskZtaskz#Tell eprimer3 what task to perform.z-hybridprobeZhybridprobez-Find an internal oligo to use as a hyb probe.z
-numreturnZ	numreturnz)Maximum number of primer pairs to return.z-includedregionZincludedregionz3Subregion of the sequence in which to pick primers.z-targettargetz(Sequence to target for flanking primers.z-excludedregionZexcludedregionz'Regions to exclude from primer picking.z-forwardinputZforwardinputz&Sequence of a forward primer to check.z-reverseinputZreverseinputz&Sequence of a reverse primer to check.z-gcclampZgcclampz:The required number of Gs and Cs at the 3' of each primer.z-osizeZosizez!Optimum length of a primer oligo.z-minsizeZminsizez!Minimum length of a primer oligo.z-maxsizemaxsizez!Maximum length of a primer oligo.z-otmZotmzMelting temperature for primer oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.6.0 by -opttm
                    z-opttmZopttmzOptimum melting temperature for a primer oligo.

                    Option added in EMBOSS 6.6.0, replacing -otm
                    z-mintmZmintmz/Minimum melting temperature for a primer oligo.z-maxtmZmaxtmz/Maximum melting temperature for a primer oligo.z
-maxdifftmZ	maxdifftmzOMaximum difference in melting temperatures between forward and reverse primers.z-ogcpercentZ
ogcpercentzOptimum GC% for a primer.z-mingcZmingczMinimum GC% for a primer.z-maxgcZmaxgczMaximum GC% for a primer.z	-saltconcZsaltconcz)Millimolar salt concentration in the PCR.z-dnaconcZdnaconcz7Nanomolar concentration of annealing oligos in the PCR.z	-maxpolyxZmaxpolyxz;Maximum allowable mononucleotide repeat length in a primer.z-productosizeZproductosizezOptimum size for the PCR product (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -psizeopt
                    z	-psizeoptZpsizeoptzOptimum size for the PCR product.

                    Option added in EMBOSS 6.1.0, replacing -productosize
                    z-productsizerangeZproductsizerangezAcceptable range of length for the PCR product (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -prange
                    z-prangeZprangezAcceptable range of length for the PCR product.

                    Option added in EMBOSS 6.1.0, replacing -productsizerange
                    z-productotmZ
productotmzOptimum melting temperature for the PCR product (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -ptmopt
                    z-ptmoptZptmoptzOptimum melting temperature for the PCR product.

                    Option added in EMBOSS 6.1.0, replacing -productotm
                    z-productmintmZproductmintmzMinimum allowed melting temperature for the amplicon (OBSOLETE)

                    Option replaced in EMBOSS 6.1.0 by -ptmmin
                    z-ptmminZptmminzMinimum allowed melting temperature for the amplicon."),

                    Option added in EMBOSS 6.1.0, replacing -productmintm
                    z-productmaxtmZproductmaxtmzMaximum allowed melting temperature for the amplicon (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -ptmmax
                    z-ptmmaxZptmmaxzMaximum allowed melting temperature for the amplicon."),

                    Option added in EMBOSS 6.1.0, replacing -productmaxtm
                    z-oexcludedregionZoexcludedregionzDo not pick internal oligos in this region."),

                    Option added in EMBOSS 6.1.0, replacing -oligoexcludedregion.
                    z-oligoexcludedregionZoligoexcludedregionzDo not pick internal oligos in this region (OBSOLETE)."),

                    Option replaced in EMBOSS 6.1.0 by -oexcluderegion.
                    z-oligoinputZ
oligoinputzSequence of the internal oligo.z
-oligosizeZ	oligosizezOptimum length of internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -osizeopt.
                    z	-osizeoptZosizeoptz}Optimum length of internal oligo.

                    Option added in EMBOSS 6.1.0, replaces -oligosize
                    z-oligominsizeZoligominsizezMinimum length of internal oligo (OBSOLETE)."),

                    Option replaced in EMBOSS 6.1.0 by -ominsize.
                    z	-ominsizeZominsizezMinimum length of internal oligo."

                    Option added in EMBOSS 6.1.0, replaces -oligominsize
                    z-oligomaxsizeZoligomaxsizezMaximum length of internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -omaxsize.
                    z	-omaxsizeZomaxsizezMaximum length of internal oligo.

                    Option added in EMBOSS 6.1.0, replaces -oligomaxsize
                    z-oligotmZoligotmzOptimum melting temperature of internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -otmopt.
                    z-otmoptZotmoptzvOptimum melting temperature of internal oligo.

                    Option added in EMBOSS 6.1.0.
                    z-oligomintmZ
oligomintmzMinimum melting temperature of internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -otmmin.
                    z-otmminZotmminzMinimum melting temperature of internal oligo.

                    Option added in EMBOSS 6.1.0, replacing -oligomintm
                    z-oligomaxtmZ
oligomaxtmzMaximum melting temperature of internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -otmmax.
                    z-otmmaxZotmmaxzMaximum melting temperature of internal oligo.

                    Option added in EMBOSS 6.1.0, replacing -oligomaxtm
                    z-oligoogcpercentZoligoogcpercentzOptimum GC% for internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -ogcopt.
                    z-ogcoptZogcoptzOptimum GC% for internal oligo."

                    Option added in EMBOSS 6.1.0, replacing -oligoogcpercent
                    z-oligomingcZ
oligomingczMinimum GC% for internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -ogcmin.
                    z-ogcminZogcminz}Minimum GC% for internal oligo.

                    Option added in EMBOSS 6.1.0, replacing -oligomingc
                    z-oligomaxgcZ
oligomaxgcztMaximum GC% for internal oligo.

                    Option replaced in EMBOSS 6.1.0 by -ogcmax
                    z-ogcmaxZogcmaxzMaximum GC% for internal oligo."),

                    Option added in EMBOSS 6.1.0, replacing -oligomaxgc
                    z-oligosaltconcZoligosaltconczMillimolar concentration of salt in the hybridisation."),

                    Option replaced in EMBOSS 6.1.0 by -osaltconc
                    z
-osaltconcZ	osaltconczMillimolar concentration of salt in the hybridisation."),

                    Option added in EMBOSS 6.1.0, replacing -oligosaltconc
                    z-oligodnaconcZoligodnaconczNanomolar concentration of internal oligo in the hybridisation.

                    Option replaced in EMBOSS 6.1.0 by -odnaconc
                    z	-odnaconcZodnaconczNanomolar concentration of internal oligo in the hybridisation.

                    Option added in EMBOSS 6.1.0, replacing -oligodnaconc
                    z-oligoselfanyZoligoselfanyzMaximum allowable alignment score for self-complementarity (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -oanyself
                    z	-oanyselfZoanyselfzMaximum allowable alignment score for self-complementarity."),

                    Option added in EMBOSS 6.1.0, replacing -oligoselfany
                    z-oligoselfendZoligoselfendzMaximum allowable 3'-anchored global alignment score "
                    for self-complementarity (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -oendself
                    z	-oendselfZoendselfzMax 3'-anchored self-complementarity global alignment score.

                    Option added in EMBOSS 6.1.0, replacing -oligoselfend
                    z-oligomaxpolyxZoligomaxpolyxzMaximum length of mononucleotide repeat in internal oligo (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -opolyxmax
                    z
-opolyxmaxZ	opolyxmaxzMaximum length of mononucleotide repeat in internal oligo."),

                    Option added in EMBOSS 6.1.0, replacing -oligomaxpolyx
                    z-mispriminglibraryfileZmispriminglibraryfilez8File containing library of sequences to avoid amplifyingz-maxmisprimingZmaxmisprimingz]Maximum allowed similarity of primers to sequences in library specified by -mispriminglibraryz-oligomaxmishybZoligomaxmishybzMaximum alignment score for hybridisation of internal oligo to
                    library specified by -oligomishyblibraryfile (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -omishybmax
                    z-omishybmaxZ
omishybmaxzMaximum alignment score for hybridisation of internal oligo to
                    library specified by -mishyblibraryfile.

                    Option added in EMBOSS 6.1.0, replacing -oligomaxmishyb
                    z-oligomishyblibraryfileZoligomishyblibraryfilezLibrary file of seqs to avoid internal oligo hybridisation (OBSOLETE).

                    Option replaced in EMBOSS 6.1.0 by -mishyblibraryfile
                    z-mishyblibraryfileZmishyblibraryfilezLibrary file of seqs to avoid internal oligo hybridisation.

                    Option added in EMBOSS 6.1.0, replacing -oligomishyblibraryfile
                    z-explainflagZexplainflagz,Produce output tags with eprimer3 statisticsN)r   r   r   r   )r   r   r   r   r   r   r      s$   zPrimer3Commandline.__init__N)r   r   r   r   r   r   r   r   r   r"      s   r"   c               @   s%   e  Z d  Z d Z d d d  Z d S)PrimerSearchCommandlinez<Commandline object for the primersearch program from EMBOSS.Zprimersearchc             K   s   t  d d d d g d d d t  d d	 d
 d g d d d d d t  d d g d d d t  d d g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z-seqallz
-sequences	sequencesZseqallz)Sequence to look for the primer pairs in.r$   Tz-infilez-primersZprimersinfilez/File containing the primer pairs to search for.r   z-mismatchpercentZmismatchpercentz;Allowed percentage mismatch (any integer value, default 0).z-snucleotidesnucleotidez"Sequences are nucleotide (boolean)z	-sproteinsproteinzSequences are protein (boolean)N)r   r   r   r   )r   r   r   r   r   r   r     s    z PrimerSearchCommandline.__init__N)r   r   r   r   r   r   r   r   r   r'     s   r'   c               @   s%   e  Z d  Z d Z d d d  Z d S)FDNADistCommandlinezCommandline object for the fdnadist program from EMBOSS.

    fdnadist is an EMBOSS wrapper for the PHYLIP program dnadist for
    calulating distance matrices from DNA sequence files.
    Zfdnadistc             K   s  t  d d g d d d d d t  d d g d	 d d t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  t  d" d# g d$  t  d% d& g d'  t  d( d) g d*  g |  _ t j |  | |  d+ S),zInitialize the class.z	-sequencer#   zseq file to use (phylip)r   Tr$   z-methodmethodzsub. model [f,k,j,l,s]z-gammagammazgamma [g, i,n]z-ncategoriesncategoriesz number of rate catergories (1-9)z-rateratezrate for each categoryz-categories
categoriesz$File of substitution rate categoriesz-weightsweightszweights filez-gammacoefficientgammacoefficientzvalue for gamma (> 0.001)z
-invarfracZ	invarfraczproportoin of invariant sitesz-ttratiottratiozts/tv ratioz
-freqsfromZ	freqsfromzuse emprical base freqsz	-basefreqbasefreqzspecify basefreqsz-lowerlowerzlower triangle matrix (y/N)N)r   r   r   r   )r   r   r   r   r   r   r     s<    zFDNADistCommandline.__init__N)r   r   r   r   r   r   r   r   r   r,     s   r,   c               @   s%   e  Z d  Z d Z d d d  Z d S)FTreeDistCommandlinezCommandline object for the ftreedist program from EMBOSS.

    ftreedist is an EMBOSS wrapper for the PHYLIP program treedist used for
    calulating distance measures between phylogentic trees.
    Z	ftreedistc             K   s   t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z-intreefile
intreefileztree file to score (phylip)r   Tr$   z-dtypeZdtypez*distance type ([S]ymetric, [b]ranch score)z-pairingZpairingz<tree pairing method ([A]djacent pairs, all [p]ossible pairs)z-stylestylez*output style - [V]erbose, [f]ill, [s]parsez-norootZnorootztreat trees as rooted [N/y]z-outgrnooutgrnoz2which taxon to root the trees with (starts from 0)N)r   r   r   r   )r   r   r   r   r   r   r     s    zFTreeDistCommandline.__init__N)r   r   r   r   r   r   r   r   r   r7     s   r7   c               @   s%   e  Z d  Z d Z d d d  Z d S)FNeighborCommandlinezCommandline object for the fneighbor program from EMBOSS.

    fneighbor is an EMBOSS wrapper for the PHYLIP program neighbor used for
    calulating neighbor-joining or UPGMA trees from distance matrices.
    Z	fneighborc             K   s   t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  g
 |  _ t j |  | |  d" S)#zInitialize the class.z	-datafiledatafilezdist file to use (phylip)r   Tr$   z-matrixtypeZ
matrixtypez)is martrix [S]quare pr [u]pper or [l]owerz	-treetypeZtreetypeznj or UPGMA tree (n/u)z-outgrnor:   ztaxon to use as OGz-jumbleZjumblezrandommise input order (Y/n)z-seedseedzprovide a random seedz-trouttroutzwrite tree (Y/n)z-outtreefileouttreefilezfilename for output treez	-progressprogresszprint progress (Y/n)z
-treeprintZ	treeprintzprint tree (Y/n)N)r   r   r   r   )r   r   r   r   r   r   r   ;  s.    zFNeighborCommandline.__init__N)r   r   r   r   r   r   r   r   r   r;   4  s   r;   c               @   s%   e  Z d  Z d Z d d d  Z d S)FSeqBootCommandlinezCommandline object for the fseqboot program from EMBOSS.

    fseqboot is an EMBOSS wrapper for the PHYLIP program seqboot used to
    pseudo-sample alignment files.
    Zfseqbootc             K   s  t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  t  d" d# g d$  t  d% d& g d'  t  d( d) g d*  g |  _ t j |  | |  d+ S),zInitialize the class.z	-sequencer#   zseq file to sample (phylip)r   Tr$   z-categoriescatergorieszfile of input categoriesz-weightsr2   z weights filez-testtestz'specify operation, default is bootstrapz-regularZregularzabsolute number to resamplez-fracsampleZ
fracsamplezfraction to resamplez-rewriteformatZrewriteformatz'output format ([P]hyilp, [n]exus, [x]mlz-seqtypeZseqtypez&output format ([D]na, [p]rotein, [r]naz
-blocksize	blocksizezprint progress (Y/n)z-repsZrepsz%how many replicates, defaults to 100)z-justweightsZ
jusweightsz.what to write out [D]atasets of just [w]eightsz-seedr=   zspecify random seedz-dotdiffdotdiffzUse dot-differencing? [Y/n]N)r   r   r   r   )r   r   r   r   r   r   r   _  s:    zFSeqBootCommandline.__init__N)r   r   r   r   r   r   r   r   r   rA   X  s   rA   c               @   s%   e  Z d  Z d Z d d d  Z d S)FDNAParsCommandlinea  Commandline object for the fdnapars program from EMBOSS.

    fdnapars is an EMBOSS version of the PHYLIP program dnapars, for
    estimating trees from DNA sequences using parsiomny. Calling this command
    without providing a value for the option "-intreefile" will invoke
    "interactive mode" (and as a result fail if called with subprocess) if
    "-auto" is not set to true.
    Zfdnaparsc             K   s:  t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  t  d" d# g d$  t  d% d& g d'  t  d( d) g d*  t  d+ d, g d-  t  d. d/ g d0  g |  _ t j |  | |  d1 S)2zInitialize the class.z	-sequencer#   zseq file to use (phylip)r   Tr$   z-intreefiler8   zPhylip tree filez-weightsr2   zweights filez	-maxtreesZmaxtreeszmax trees to save during runz	-thoroughZthoroughzmore thorough search (Y/n)z
-rearrangeZ	rearrangez#Rearrange on just 1 best tree (Y/n)z-transversionZtransversionzUse tranversion parsimony (y/N)z-njumblenjumblez7number of times to randomise input order (default is 0)z-seedr=   zprovide random seedz-outgrnor:   zSpecify outgroupz-threshthreshzUse threshold parsimony (y/N)z
-threshold	thresholdzThreshold valuez-troutr>   zWrite trees to file (Y/n)z-outtreefiler?   zfilename for output treez-dotdiffrE   zUse dot-differencing? [Y/n]N)r   r   r   r   )r   r   r   r   r   r   r     sB    zFDNAParsCommandline.__init__N)r   r   r   r   r   r   r   r   r   rF     s   rF   c               @   s%   e  Z d  Z d Z d d d  Z d S)FProtParsCommandlinea  Commandline object for the fdnapars program from EMBOSS.

    fprotpars is an EMBOSS version of the PHYLIP program protpars, for
    estimating trees from protein  sequences using parsiomny. Calling this
    command without providing a value for the option "-intreefile" will invoke
    "interactive mode" (and as a result fail if called with subprocess) if
    "-auto" is not set to true.
    Z	fprotparsc             K   s  t  d d g d d d d d t  d d g d	  t  d
 d g d d d d d t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  t  d" d# g d$  t  d% d& g d'  g |  _ t j |  | |  d( S))zInitialize the class.z	-sequencer#   zseq file to use (phylip)r   Tr$   z-intreefiler8   zPhylip tree file to scorez-outtreefiler?   zphylip tree output filez-weightsr2   zweights filez
-whichcode	whichcodez which genetic code, [U,M,V,F,Y]]z-njumblerG   z7number of times to randomise input order (default is 0)z-seedr=   zprovide random seedz-outgrnor:   zSpecify outgroupz-threshrH   zUse threshold parsimony (y/N)z
-thresholdrI   zThreshold valuez-troutr>   zWrite trees to file (Y/n)z-dotdiffrE   zUse dot-differencing? [Y/n]N)r   r   r   r   )r   r   r   r   r   r   r     s:    zFProtParsCommandline.__init__N)r   r   r   r   r   r   r   r   r   rJ     s   rJ   c               @   s%   e  Z d  Z d Z d d d  Z d S)FProtDistCommandlinezCommandline object for the fprotdist program from EMBOSS.

    fprotdist is an EMBOSS wrapper for the PHYLIP program protdist used to
    estimate trees from protein sequences using parsimony
    Z	fprotdistc             K   s(  t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  t  d" d# g d$  t  d% d& g d'  t  d( d) g d*  t  d+ d, g d-  g |  _ t j |  | |  d. S)/zInitialize the class.z	-sequencer#   zseq file to use (phylip)r   Tr$   z-ncategoriesr/   z number of rate catergories (1-9)z-rater0   zrate for each categoryz-catergoriesrB   zfile of ratesz-weightsr2   zweights filez-methodr-   zsub. model [j,h,d,k,s,c]z-gammar.   zgamma [g, i,c]z-gammacoefficientr3   zvalue for gamma (> 0.001)z-invarcoefficientZinvarcoefficientz4float for variation of substitution rate among sitesz-aacategZaacategz"Choose the category to use [G,C,H]z
-whichcoderK   zgenetic code [c,m,v,f,y]z-easeZeasez-Pob change catergory (float between -0 and 1)z-ttratior4   z#Transition/transversion ratio (0-1)z	-basefreqr5   z+DNA base frequencies (space separated list)N)r   r   r   r   )r   r   r   r   r   r   r     s>    zFProtDistCommandline.__init__N)r   r   r   r   r   r   r   r   r   rL     s   rL   c               @   s%   e  Z d  Z d Z d d d  Z d S)FConsenseCommandlinezCommandline object for the fconsense program from EMBOSS.

    fconsense is an EMBOSS wrapper for the PHYLIP program consense used to
    calculate consensus trees.
    Z	fconsensec          	   K   s   t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z-intreefiler8   z-file with phylip trees to make consensus fromr   Tr$   z-methodr-   z!consensus method [s, mr, MRE, ml]z-mlfracZmlfracz8cut-off freq for branch to appear in consensus (0.5-1.0)z-rootrootztreat trees as rooted (YES, no)z-outgrnor:   z&OTU to use as outgroup (starts from 0)z-troutr>   z-outtreefiler?   z"Phylip tree output file (optional)N)r   r   r   r   )r   r   r   r   r   r   r     s"    zFConsenseCommandline.__init__N)r   r   r   r   r   r   r   r   r   rM     s   rM   c               @   s%   e  Z d  Z d Z d d d  Z d S)WaterCommandlinez5Commandline object for the water program from EMBOSS.Zwaterc             K   s  t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d t  d d g d d d t  d d g d d d t d d g d  t d d g d  t  d d g d  t  d d g d  t  d d  g d!  t  d" d# g d$  g |  _ t j |  | |  d% S)&zInitialize the class.z
-asequence	asequencezFirst sequence to alignr   Tr$   z
-bsequence	bsequencezSecond sequence to alignz-gapopengapopenzGap open penaltyz
-gapextend	gapextendzGap extension penaltyz	-datafiler<   zMatrix filez-nobriefnobriefz(Display extended identity and similarityz-briefbriefz%Display brief identity and similarityz-similarity
similarityz'Display percent identity and similarityz-snucleotider*   z"Sequences are nucleotide (boolean)z	-sproteinr+   zSequences are protein (boolean)z-aformataformatz5Display output in a different specified output formatN)r   r   r   r   r   )r   r   r   r   r   r   r   -  s<    zWaterCommandline.__init__N)r   r   r   r   r   r   r   r   r   rO   *  s   rO   c               @   s%   e  Z d  Z d Z d d d  Z d S)NeedleCommandlinez6Commandline object for the needle program from EMBOSS.Zneedlec             K   sF  t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d t  d d g d d d t  d d g d d d t  d d g d  t  d d g d  t  d d g d  t d d g d  t d d  g d!  t  d" d# g d$  t  d% d& g d'  t  d( d) g d*  t  d+ d, g d-  g |  _ t j |  | |  d. S)/zInitialize the class.z
-asequencerP   zFirst sequence to alignr   Tr$   z
-bsequencerQ   zSecond sequence to alignz-gapopenrR   zGap open penaltyz
-gapextendrS   zGap extension penaltyz	-datafiler<   zMatrix filez
-endweight	endweightzApply And gap penaltiesz-endopenendopenz0The score taken away when an end gap is created.z
-endextend	endextendzPThe score added to the end gap penality for each base or residue in the end gap.z-nobriefrT   z(Display extended identity and similarityz-briefrU   z%Display brief identity and similarityz-similarityrV   z'Display percent identity and similarityz-snucleotider*   z"Sequences are nucleotide (boolean)z	-sproteinr+   zSequences are protein (boolean)z-aformatrW   z5Display output in a different specified output formatN)r   r   r   r   r   )r   r   r   r   r   r   r   T  sH    zNeedleCommandline.__init__N)r   r   r   r   r   r   r   r   r   rX   Q  s   rX   c               @   s%   e  Z d  Z d Z d d d  Z d S)NeedleallCommandlinez9Commandline object for the needleall program from EMBOSS.Z	needleallc             K   sj  t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d t  d d g d d d t  d d g d d d t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d  g d!  t d" d# g d$  t d% d& g d'  t  d( d) g d*  t  d+ d, g d-  t  d. d/ g d0  t  d1 d2 g d3  g |  _ t j |  | |  d4 S)5zInitialize the class.z
-asequencerP   zFirst sequence to alignr   Tr$   z
-bsequencerQ   zSecond sequence to alignz-gapopenrR   zGap open penaltyz
-gapextendrS   zGap extension penaltyz	-datafiler<   zMatrix filez	-minscoreminscorez:Exclude alignments with scores below this threshold score.z
-errorfileZ	errorfilezError file to be written to.z
-endweightrY   zApply And gap penaltiesz-endopenrZ   z0The score taken away when an end gap is created.z
-endextendr[   zPThe score added to the end gap penality for each base or residue in the end gap.z-nobriefrT   z(Display extended identity and similarityz-briefrU   z%Display brief identity and similarityz-similarityrV   z'Display percent identity and similarityz-snucleotider*   z"Sequences are nucleotide (boolean)z	-sproteinr+   zSequences are protein (boolean)z-aformatrW   z5Display output in a different specified output formatN)r   r   r   r   r   )r   r   r   r   r   r   r     sP    zNeedleallCommandline.__init__N)r   r   r   r   r   r   r   r   r   r\     s   r\   c               @   s%   e  Z d  Z d Z d d d  Z d S)StretcherCommandlinez9Commandline object for the stretcher program from EMBOSS.Z	stretcherc             K   s   t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d d d d   t  d d g d d d d d d   t  d d g d d d t  d d g d  t  d d g d  t  d d g d  g |  _ t j |  | |  d  S)!zInitialize the class.z
-asequencerP   zFirst sequence to alignr   Tr$   z
-bsequencerQ   zSecond sequence to alignz-gapopenrR   zGap open penaltyZchecker_functionc             S   s   t  |  t  S)N)
isinstanceint)valuer   r   r   <lambda>  s    z/StretcherCommandline.__init__.<locals>.<lambda>z
-gapextendrS   zGap extension penaltyc             S   s   t  |  t  S)N)r_   r`   )ra   r   r   r   rb     s    z	-datafiler<   zMatrix filez-snucleotider*   z"Sequences are nucleotide (boolean)z	-sproteinr+   zSequences are protein (boolean)z-aformatrW   z5Display output in a different specified output formatN)r   r   r   r   )r   r   r   r   r   r   r     s4    zStretcherCommandline.__init__N)r   r   r   r   r   r   r   r   r   r^     s   r^   c               @   s%   e  Z d  Z d Z d d d  Z d S)FuzznucCommandlinez7Commandline object for the fuzznuc program from EMBOSS.Zfuzznucc             K   s   t  d d g d d d t  d d g d d d t  d	 d
 g d  t  d d g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   zSequence database USAr$   Tz-patternpatternz5Search pattern, using standard IUPAC one-letter codesz
-pmismatch	pmismatchzNumber of mismatchesz-complementZ
complementzSearch complementary strandz-rformatrformatz'Specify the report format to output in.N)r   r   r   r   )r   r   r   r   r   r   r     s    zFuzznucCommandline.__init__N)r   r   r   r   r   r   r   r   r   rc     s   rc   c               @   s%   e  Z d  Z d Z d d d  Z d S)FuzzproCommandlinez7Commandline object for the fuzzpro program from EMBOSS.Zfuzzproc             K   st   t  d d g d d d t  d d g d d d t  d	 d
 g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   zSequence database USAr$   Tz-patternrd   z5Search pattern, using standard IUPAC one-letter codesz
-pmismatchre   zNumber of mismatchesz-rformatrf   z'Specify the report format to output in.N)r   r   r   r   )r   r   r   r   r   r   r     s    zFuzzproCommandline.__init__N)r   r   r   r   r   r   r   r   r   rg     s   rg   c               @   s%   e  Z d  Z d Z d d d  Z d S)Est2GenomeCommandlinez:Commandline object for the est2genome program from EMBOSS.Z
est2genomec             K   s^  t  d d g d d d t  d d g d d d t  d	 d
 g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d  t  d d g d   t  d! d" g d#  t  d$ d% g d&  t  d' d( g d)  t  d* d+ g d,  t  d- d. g d/  t  d0 d1 g d2  t  d3 d4 g d5  g |  _ t j |  | |  d6 S)7zInitialize the class.z-estZestzEST sequence(s)r$   Tz-genomeZgenomezGenomic sequencez-matchmatchzScore for matching two basesz	-mismatchmismatchzCost for mismatching two basesz-gappenaltyZ
gappenaltyzECost for deleting a single base in either sequence, excluding intronsz-intronpenaltyZintronpenaltyz*Cost for an intron, independent of length.z-splicepenaltyZsplicepenaltyzUCost for an intron, independent of length and starting/ending on donor-acceptor sitesz	-minscorer]   z:Exclude alignments with scores below this threshold score.z-reversereversez+Reverse the orientation of the EST sequencez-spliceZsplicez$Use donor and acceptor splice sites.z-modemodez?This determines the comparion mode. 'both', 'forward' 'reverse'z-bestbestz:You can print out all comparisons instead of just the bestz-spacespacezfor linear-space recursion.z-shuffleshuffleZShufflez-seedr=   zRandom number seedz-alignZalignzShow the alignment.z-widthwidthzAlignment widthN)r   r   r   r   )r   r   r   r   r   r   r     sJ    zEst2GenomeCommandline.__init__N)r   r   r   r   r   r   r   r   r   rh     s   rh   c               @   s%   e  Z d  Z d Z d d d  Z d S)ETandemCommandlinez7Commandline object for the etandem program from EMBOSS.Zetandemc          	   K   s   t  d d g d d d d d t  d d g d	 d d t  d
 d g d d d t  d d g d  t  d d g d  t  d d g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   Sequencer   Tr$   z
-minrepeatZ	minrepeatzMinimum repeat sizez
-maxrepeat	maxrepeatzMaximum repeat sizez
-thresholdrI   zThreshold scorez	-mismatchrj   zAllow N as a mismatchz-uniformuniformzAllow uniform consensusz-rformatrf   zOutput report formatN)r   r   r   r   )r   r   r   r   r   r   r   2  s&    zETandemCommandline.__init__N)r   r   r   r   r   r   r   r   r   rq   /  s   rq   c               @   s%   e  Z d  Z d Z d d d  Z d S)EInvertedCommandlinez9Commandline object for the einverted program from EMBOSS.Z	einvertedc          	   K   s   t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d t  d d g d d d t  d d g d d d t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   rr   r   Tr$   z-gapZgapzGap penaltyz
-thresholdrI   zMinimum score thresholdz-matchri   zMatch scorez	-mismatchrj   zMismatch scorez
-maxrepeatrs   z6Maximum separation between the start and end of repeatN)r   r   r   r   )r   r   r   r   r   r   r   N  s(    zEInvertedCommandline.__init__N)r   r   r   r   r   r   r   r   r   ru   K  s   ru   c               @   s%   e  Z d  Z d Z d d d  Z d S)PalindromeCommandlinez:Commandline object for the palindrome program from EMBOSS.Z
palindromec          
   K   s   t  d d g d d d d d t  d d g d	 d d t  d
 d g d d d t  d d g d d d t  d d g d d d t  d d g d d d g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   rr   r   Tr$   z
-minpallenZ	minpallenzMinimum palindrome lengthz
-maxpallenZ	maxpallenzMaximum palindrome lengthz	-gaplimitZgaplimitzMaximum gap between repeatsz-nummismatchesZnummismatcheszNumber of mismatches allowedz-overlapoverlapzReport overlapping matchesN)r   r   r   r   )r   r   r   r   r   r   r   k  s(    zPalindromeCommandline.__init__N)r   r   r   r   r   r   r   r   r   rv   h  s   rv   c               @   s%   e  Z d  Z d Z d d d  Z d S)TranalignCommandlinez9Commandline object for the tranalign program from EMBOSS.Z	tranalignc          	   K   s   t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d d d t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z
-asequencerP   z#Nucleotide sequences to be aligned.r   Tr$   z
-bsequencerQ   zProtein sequence alignmentz-outseqoutseqzOutput sequence file.z-tabletablezCode to useN)r   r   r   r   )r   r   r   r   r   r   r     s    zTranalignCommandline.__init__N)r   r   r   r   r   r   r   r   r   rx     s   rx   c               @   s%   e  Z d  Z d Z d d d  Z d S)DiffseqCommandlinez7Commandline object for the diffseq program from EMBOSS.Zdiffseqc             K   s   t  d d g d d d d d t  d d g d	 d d d d t  d
 d g d d d t  d d g d d d d d t  d d g d d d d d t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z
-asequencerP   zFirst sequence to comparer   Tr$   z
-bsequencerQ   zSecond sequence to comparez	-wordsizewordsizez-Word size to use for comparisons (10 default)z	-aoutfeatZaoutfeatz,File for output of first sequence's featuresz	-boutfeatZboutfeatz-File for output of second sequence's featuresz-rformatrf   zOutput report file formatN)r   r   r   r   )r   r   r   r   r   r   r     s,    zDiffseqCommandline.__init__N)r   r   r   r   r   r   r   r   r   r{     s   r{   c               @   s%   e  Z d  Z d Z d d d  Z d S)IepCommandlinea  Commandline for EMBOSS iep: calculated isoelectric point and charge.

    Examples
    --------
    >>> from Bio.Emboss.Applications import IepCommandline
    >>> iep_cline = IepCommandline(sequence="proteins.faa",
    ...                            outfile="proteins.txt")
    >>> print(iep_cline)
    iep -outfile=proteins.txt -sequence=proteins.faa

    You would typically run the command line with iep_cline() or via the
    Python subprocess module, as described in the Biopython tutorial.

    Ziepc             K   s   t  d d g d d d d d t  d d g d	  t  d
 d g d  t  d d g d  t  d d g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   zProtein sequence(s) filenamer   Tr$   z-aminoZaminozZNumber of N-termini

                    Integer 0 (default) or more.
                    z	-carboxylZcarboxylzZNumber of C-termini

                    Integer 0 (default) or more.
                    z-lysinemodifiedZlysinemodifiedzaNumber of modified lysines

                    Integer 0 (default) or more.
                    z-disulphidesZdisulphideszcNumber of disulphide bridges

                    Integer 0 (default) or more.
                    z
-noterminiZ	noterminiz=Exclude (True) or include (False) charge at N and C terminus.N)r   r   r   r   )r   r   r   r   r   r   r     s    zIepCommandline.__init__N)r   r   r   r   r   r   r   r   r   r}     s   r}   c               @   s1   e  Z d  Z d Z d d d  Z d d   Z d S)SeqretCommandlinea  Commandline object for the seqret program from EMBOSS.

    This tool allows you to interconvert between different sequence file
    formats (e.g. GenBank to FASTA). Combining Biopython's Bio.SeqIO module
    with seqret using a suitable intermediate file format can allow you to
    read/write to an even wider range of file formats.

    This wrapper currently only supports the core functionality, things like
    feature tables (in EMBOSS 6.1.0 onwards) are not yet included.
    Zseqretc             K   st   t  d d g d d d t  d d g d d d t  d	 d
 g d  t  d d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   zInput sequence(s) filenamer   Tz-outseqry   zOutput sequence file.z-sformatZsformatz.Input sequence(s) format (e.g. fasta, genbank)z	-osformatZosformatz/Output sequence(s) format (e.g. fasta, genbank)N)r   r   r   r   )r   r   r   r   r   r   r     s    zSeqretCommandline.__init__c             C   s[   |  j  p |  j p |  j s' t d   |  j p? |  j p? |  j sN t d   t j |   S)Nz]You must either set outfile (output filename), or enable filter or stdout (output to stdout).z\You must either set sequence (input filename), or enable filter or stdin (input from stdin).)ry   r   r   r    r#   Zstdintr   r!   )r   r   r   r   r!     s
    zSeqretCommandline._validateN)r   r   r   r   r   r!   r   r   r   r   r~     s   
r~   c               @   s%   e  Z d  Z d Z d d d  Z d S)SeqmatchallCommandlineak  Commandline object for the seqmatchall program from EMBOSS.

    e.g.
    >>> cline = SeqmatchallCommandline(sequence="opuntia.fasta", outfile="opuntia.txt")
    >>> cline.auto = True
    >>> cline.wordsize = 18
    >>> cline.aformat = "pair"
    >>> print(cline)
    seqmatchall -auto -outfile=opuntia.txt -sequence=opuntia.fasta -wordsize=18 -aformat=pair

    Zseqmatchallc             K   sb   t  d d g d d d d d t  d d g d	  t  d
 d g d  g |  _ t j |  | |  d S)zInitialize the class.z	-sequencer#   zReadable set of sequencesr   Tr$   z	-wordsizer|   z(Word size (Integer 2 or more, default 4)z-aformatrW   z5Display output in a different specified output formatN)r   r   r   r   )r   r   r   r   r   r   r   %  s    zSeqmatchallCommandline.__init__N)r   r   r   r   r   r   r   r   r   r     s   r   __main__)run_doctestN)%r   
__future__r   ZBio.Applicationr   r   r   r   r   r"   r'   r,   r7   r;   rA   rF   rJ   rL   rM   rO   rX   r\   r^   rc   rg   rh   rq   ru   rv   rx   r{   r}   r~   r   r   Z
Bio._utilsr   r   r   r   r   <module>   sB   F$ Q+$*1-,'.2#13)