PyPop.Main#

Primary access to PyPop’s population genetics statistics modules.

This module handles processing configparser.ConfigParser instance. The Main class coordinates running the analysis packages specified in this configparser.ConfigParser instance which can be:

  • created from a filename passed from command-line argument oar;

  • from values populated by the GUI (for example, selected from an .ini file,

  • created programmatically as part of an external Python program

Here is an example of calling Main programmatically, explicitly specifying the untypedAllele and alleleDesignator in the .pop file:

>>> from PyPop.Main import Main
>>> from configparser import ConfigParser
>>>
>>> config = ConfigParser()
>>> config.read_dict({
...     "ParseGenotypeFile": {"untypedAllele": "****",
...                           "alleleDesignator": "*",
...                           "validSampleFields": "*a_1\n*a_2"}})
>>>
>>> pop_contents = '''a_1\ta_2
... ****\t****
... 01:01\t02:01
... 02:10\t03:01:02'''
>>> with open("my.pop", "w") as f:
...     _ = f.write(pop_contents)
...
>>> application = Main(
...     config=config,
...     fileName="my.pop",
...     version="fake",
... )
LOG: no XSL file, skipping text output
LOG: Data file has no header data block

Classes#

Main

Main interface to the PyPop modules.

Functions#

getConfigInstance([configFilename, altpath])

Create and return ConfigParser instance.

get_sequence_directory(directory_str[, debug])

Get the directory for the PyPop.Filter.AnthonyNolanFilter.

Module Contents#

class Main(config=None, xslFilename=None, xslFilenameDefault=None, debugFlag=0, fileName=None, datapath=None, thread=None, outputDir=None, version=None, testMode=False)#

Main interface to the PyPop modules.

Runs the analyses specified in the configuration object provided to the config parameter, and an input fileName, and generates an output XML file. The XML output file name, appends -out.xml on to the stem of the provided fileName. For example, if fileName="MyPopulation.pop" is provided as a parameter, the output XML file will be MyPopulation-out.xml.

Changed in version 1.4.0: If an xslFilename or xslFilenameDefault is provided, also generate a plain text output. Otherwise no text output is generated. Previous to this version, if neither were provided, the program would exit with an error.

Parameters:
  • config (configparser.ConfigParser) – configure object

  • xslFilename (str, optional) – XSLT file to use

  • xslFilenameDefault (str, optional) – fallback file name

  • debugFlag (int, optional) – enable debugging (1)

  • fileName (str) – input .pop file

  • datapath (str, optional) – root of data path

  • thread (str, optional) – specified thread

  • outputDir (str, optional) – use a different output directory than default

  • version (str, optional) – current Python version for output

  • testMode (bool, optional) – enable testing mode

getXmlOutPath()#

Get name of XML file.

Returns:

return XML file name

Return type:

XMLOutputStream

getTxtOutPath()#

Get name of .txt output file.

Returns:

return txt file name

Return type:

TextOutputStream

getConfigInstance(configFilename=None, altpath=None)#

Create and return ConfigParser instance.

Parameters:
  • configFilename (str) – a specified .ini filename

  • altpath (str) – an alternative path to search if no .ini filename provided in configFilename

Returns:

configuration object

Return type:

configparser.ConfigParser

get_sequence_directory(directory_str, debug=False)#

Get the directory for the PyPop.Filter.AnthonyNolanFilter.

Parameters:
  • directory_str (str) – directory to search

  • debug (bool) – enable debugging

Returns:

path to sequence files

Return type:

str