API Reference (1.3.1.post52+g60fe84e8d)#

Developer documentation

Documenting API for release 1.3.1.post52+g60fe84e8d of PyPop.

Document revision: 1.3.1.post52+g60fe84e8d

This API reference guide for PyPop is automatically generated from the 1.3.1.post52+g60fe84e8d source code via sphinx-autoapi.

Copyright © 2025 PyPop contributors

License terms Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the License chapter. (GNU Free Documentation License)

API changes#

In PyPop 1.4.0, modules have been renamed to follow the lower-case convention of PEP8. In addition to lowercasing, some have further renaming to clarify their purpose and follow standard conventions. Backwards-compatibile bindings have been created that allow end-user Python scripts using the PyPop API to continue to work with the old module names. However such use will raise a PyPopModuleRenameDeprecationWarning (a custom DeprecationWarning). In the following minor release, 1.5.0, the warnings will become more visible UserWarning. These bindings will be completely removed in the next major release.

Note:

Command-line users of pypop will not be affected by these changes, which are completely internal, scripts will continue to work with no changes needed in any configuration files.

Below are the list of all API changes, including removals and any other ongoing API deprecations, and notifications of upcoming removals.

Changed in version 1.4.0: The following modules were renamed or refactored:

  • PyPop.CommandLineInterfacePyPop.command_line_interface Lowercased for PEP8 compliance; underscores separate readable words.

  • PyPop.DataTypesPyPop.datatypes Lowercased for PEP8 compliance and consistency with plural naming for data structures.

  • PyPop.FilterPyPop.filters Lowercased and clarified plural form since module defines multiple filter functions.

  • PyPop.HaploPyPop.haplo Lowercased for PEP8 compliance.

  • PyPop.HardyWeinbergPyPop.hardyweinberg Lowercased for PEP8 compliance.

  • PyPop.HomozygosityPyPop.homozygosity Lowercased for PEP8 compliance.

  • PyPop.MainPyPop.popanalysis Lowercased and renamed for clarity; represents per-population analysis rather than script entry point.

  • PyPop.MetaPyPop.popaggregate Lowercased and renamed for clarity; aggregates results across populations, not ‘metadata’.

  • PyPop.ParseFilePyPop.parsers Lowercased for and renamed for clarity: module parses multiple file types, not just one file.

  • PyPop.RandomBinningPyPop.randombinning Lowercased for PEP8 compliance.

  • PyPop.UtilsPyPop.utils Lowercased for PEP8 compliance.

Removed in version 1.4.0: The following modules were removed:

  • PyPop.GUIApp Obsolete, never fully implemented a full wxPython UI. Replaced by built-in Tkinter file-picker

Deprecated since version 1.0.0: The following modules were marked deprecated:

  • PyPop.ArlequinPyPop.arlequin Scheduled for removal in 1.5.0. Lowercased for PEP8 compliance.

Package introduction#

PyPop is a framework for performing population genetics analyses.

PyPop was originally designed as an end-to-end pipeline that reads configuration files and datasets and produces standardized outputs. While the primary workflow is file-based, most internal functionality is exposed as Python modules and classes.

Important

Updates to PyPop’s API to better expose and streamline “library” access to PyPop’s functionality in end-user programs is still a work-in-progress. Although this API is intended to serve end-users and developers of PyPop, parts of it are not yet optimized for end-users.

Driving PyPop programmatically can be done via the popanalysis and popaggregate modules. In the example below, we run an simple analysis on a single input .pop file and generate output TSV files. There are two main steps:

  1. Create the ConfigParser instance (see configuration file section in the PyPop User Guide for the description of the configuration options), supply this to the Main class, along with an input .pop file, to perform the analysis.

  2. Next get the name of output XML file from the generated Main instance, and pass it to the Meta to generate TSV output files.

>>> from PyPop.popanalysis import Main
>>> from configparser import ConfigParser
>>>
>>> config = ConfigParser()
>>> config.read_dict({
...     "ParseGenotypeFile": {"validSampleFields": "*a_1\n*a_2"},
...     "HardyWeinberg": {"lumpBelow": "5"}})
>>>
>>> pop_contents = '''a_1\ta_2
... 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
>>> outXML = application.getXmlOutPath()
>>> from PyPop.popaggregate import Meta
>>> _ = Meta (TSV_output=True, xml_files=[outXML])
./1-locus-hardyweinberg.tsv
./1-locus-summary.tsv
./1-locus-allele.tsv
./1-locus-genotype.tsv

See also

The PyPop API examples in the PyPop User Guide for a more detailed breakdown of use of the API.

Submodules#

Deprecated Submodules#

Attributes#

logger

Package-wide logger used throughout a PyPop run.

copyright_message

copyright information used in --help screens and elsewhere

platform_info

platform information used in --help screens and elsewhere

Exceptions#

PyPopModuleRenameDeprecationWarning

Deprecation warning for PyPop module renames.

Functions#

setup_logger([level, filename, doctest_mode])

Configure the 'pypop' logger with stdout/file handler, optional debug verbosity, and doctest mode.

Package Contents#

exception PyPopModuleRenameDeprecationWarning#

Bases: DeprecationWarning

Inheritance diagram of PyPop.PyPopModuleRenameDeprecationWarning

Deprecation warning for PyPop module renames.

Added in version 1.4.0.

Initialize self. See help(type(self)) for accurate signature.

logger#

Package-wide logger used throughout a PyPop run.

Added in version 1.4.0.

copyright_message = Multiline-String#
Show Value
"""Copyright (C) 2003-2006 Regents of the University of California.
Copyright (C) 2007-2025 PyPop team.
This is free software.  There is NO warranty; not even for
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."""

copyright information used in --help screens and elsewhere

platform_info = '[Python Uninferable | Uninferable | Uninferable]'#

platform information used in --help screens and elsewhere

setup_logger(level=logging.INFO, filename=None, doctest_mode=True)#

Configure the ‘pypop’ logger with stdout/file handler, optional debug verbosity, and doctest mode.

Added in version 1.4.0.

Parameters:
  • level (str, optional) – INFO (default), DEBUG (more detailed), WARNING, CRITICAL

  • filename (str, optional) – Optional file to log to. If None, logs to stdout.

  • doctest_mode (bool, optional) – If True, forcibly rebinds the logger to sys.stdout and disables propagation so doctests see output.