PyPop.Arlequin#

Provides Arlequin functionality in Python.

Deprecated since version 1.0.0: Only works for an obsolete version of Arlequin.

Attributes#

usage_message

Classes#

ArlequinWrapper

Wraps the functionality of the Arlequin program.

ArlequinExactHWTest

Wraps the Arlequin Hardy-Weinberg exact functionality.

ArlequinBatch

A wrapper for running Arlequin from the command-line.

Module Contents#

class ArlequinWrapper(matrix=None, arlequinPrefix='arl_run', arlequinExec='arlecore.exe', untypedAllele='****', arpFilename='output.arp', arsFilename='arl_run.ars', debug=None)#

Wraps the functionality of the Arlequin program.

Parameters:
  • matrix (StringMatrix) – matrix

  • arlequinPrefix (str, optional) – directory prefix (default arl_run)

  • arlequinExec (str, optional) – executable program (default arlecore.exe)

  • untypedAllele (str, optional) – untyped allele designator (default ****)

  • arpFilename (str, optional) – default output file name (default output.arp)

  • arsFilename (str, optional) – default run file name (default arl_run.ars)

  • debug (bool) – enable debug (default off, i.e. None)

outputArpFile(group)#

Output the .arp file.

Parameters:

group (list) – list of loci to pass to Arlequin

outputArsFile(arsFilename, arsContents)#

Outputs the run-time Arlequin program file.

Parameters:
  • arsFilename (str) – name of file

  • arsContents (str) – contents of file

outputRunFiles()#

Generates the expected ‘.txt’ set-up files for Arlequin.

runArlequin()#

Run the Arlequin haplotyping program.

Forks a copy of arlecore.exe, which must be on PATH to actually generate the desired statistics estimates from the generated .arp file.

cleanup()#

Remove the working Arlequin subdirectory.

class ArlequinExactHWTest(matrix=None, lociList=None, markovChainStepsHW=100000, markovChainDememorisationStepsHW=1000, **kw)#

Bases: ArlequinWrapper

Inheritance diagram of PyPop.Arlequin.ArlequinExactHWTest

Wraps the Arlequin Hardy-Weinberg exact functionality.

Run Hardy-Weinberg exact test on list specified in lociList.

hwExactTest#

standard config options for Arlequin

Type:

str

Parameters:
  • matrix (StringMatrix) – StringMatrix for testing

  • lociList (list) – list of loci

  • markovChainStepsHW (int, optional) – Number of steps to use in Markov chain (default: 100000)

  • markovChainDememorisationStepsHW (int, optional) – “Burn-in” time for Markov chain (default: 1000).

getHWExactTest()#

Returns a dictionary of loci.

Returns:

Each dictionary element contains a tuple of the results from the Arlequin implementation of the Hardy-Weinberg exact test, namely:

  • number of genotypes,

  • observed heterozygosity,

  • expected heterozygosity,

  • the p-value,

  • the standard deviation,

  • number of steps,

If locus is monomorphic, the HW exact test can’t be run, and the contents of the dictionary element simply contains the string monomorphic, rather than the tuple of values.

Return type:

dict

class ArlequinBatch(arpFilename, arsFilename, idCol, prefixCols, suffixCols, windowSize, mapOrder=None, untypedAllele='0', arlequinPrefix='arl_run', debug=0)#

A wrapper for running Arlequin from the command-line.

Given a delimited text file of multi-locus genotype data: provides methods to output Arlequin format data files and runtime info and execution of Arlequin itself. Used to provide a “batch” (i.e. command line) mode for generating appropriate Arlequin input files and for forking Arlequin itself.

Parameters:
  • arpFilename (str) – Arlequin filename (must have .arp file extension)

  • arsFilename (str) – Arlequin settings filename (must have .ars file extension)

  • idCol (str) – column in input file that contains the individual id.

  • prefixCols (int) – number of columns to ignore before allele data starts

  • suffixCols (int) – number of columns to ignore after allele data stops

  • windowSize (int) – size of sliding window

  • mapOrder (list, optional) – list order of columns if different to column order in file (defaults to order in file)

  • untypedAllele (str, optional) – (defaults to 0)

  • arlequinPrefix (str, optional) – prefix for all Arlequin run-time files (defaults to arl_run).

  • debug (int, optional) – (defaults to 0)

outputArlequin(data)#

Outputs the specified .arp sample file.

Parameters:

data (list) – list of lines of data.

outputRunFiles()#

Generates the expected set-up files for Arlequin.

Includes .txt and .ars file names.

runArlequin()#

Run the Arlequin haplotyping program.

Forks a copy of arlecore.exe, which must be on PATH to actually generate the desired statistics estimates from the generated .arp file.

usage_message = Multiline-String#
Show Value
"""Usage: Arlequin.py [OPTION] INPUTFILE ARPFILE ARSFILE
Process a tab-delimited INPUTFILE of alleles to produce an data files
(including ARPFILE), using parameters from ARSFILE for the Arlequin population
genetics program.

 -i, --idcol=NUM       column number of identifier (first column is zero)
 -l, --ignorelines=NUM number of header lines to ignore in in file
 -c, --cols=POS1,POS2  number of leading columns (POS1) before start and
                        number of trailing columns before the end (POS2) of
                        allele data (including IDCOL)
 -k, --sort=POS1,..    specify order of loci if different from column order
                        in file (must not repeat a locus)
 -w, --windowsize=NUM  number of loci involved in window size
                        (note that this is half the number of allele columns)
 -u, --untyped=STR     the string that represents `untyped' alleles
                        (defaults to '****')
 -x, --execute         execute the Arlequin program
 -h, --help            this message
 -d, --debug           switch on debugging

  INPUTFILE   input text file
  ARPFILE     output Arlequin '.arp' project file
  ARSFILE     input Arlequin '.ars' settings file"""