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
pypopwill 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.CommandLineInterface→PyPop.command_line_interfaceLowercased for PEP8 compliance; underscores separate readable words.PyPop.DataTypes→PyPop.datatypesLowercased for PEP8 compliance and consistency with plural naming for data structures.PyPop.Filter→PyPop.filtersLowercased and clarified plural form since module defines multiple filter functions.PyPop.Haplo→PyPop.haploLowercased for PEP8 compliance.PyPop.HardyWeinberg→PyPop.hardyweinbergLowercased for PEP8 compliance.PyPop.Homozygosity→PyPop.homozygosityLowercased for PEP8 compliance.PyPop.Main→PyPop.popanalysisLowercased and renamed for clarity; represents per-population analysis rather than script entry point.PyPop.Meta→PyPop.popaggregateLowercased and renamed for clarity; aggregates results across populations, not ‘metadata’.PyPop.ParseFile→PyPop.parsersLowercased for and renamed for clarity: module parses multiple file types, not just one file.PyPop.RandomBinning→PyPop.randombinningLowercased for PEP8 compliance.PyPop.Utils→PyPop.utilsLowercased for PEP8 compliance.
Removed in version 1.4.0: The following modules were removed:
PyPop.GUIAppObsolete, never fully implemented a fullwxPythonUI. Replaced by built-in Tkinter file-picker
Deprecated since version 1.0.0: The following modules were marked deprecated:
PyPop.Arlequin→PyPop.arlequinScheduled 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:
Create the
ConfigParserinstance (see configuration file section in the PyPop User Guide for the description of the configuration options), supply this to theMainclass, along with an input.popfile, to perform the analysis.Next get the name of output XML file from the generated
Maininstance, and pass it to theMetato 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#
Package-wide logger used throughout a PyPop run. |
|
copyright information used in |
|
platform information used in |
Exceptions#
Deprecation warning for PyPop module renames. |
Functions#
|
Configure the 'pypop' logger with stdout/file handler, optional debug verbosity, and doctest mode. |
Package Contents#
- exception PyPopModuleRenameDeprecationWarning#
Bases:
DeprecationWarning
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
--helpscreens and elsewhere
- platform_info = '[Python Uninferable | Uninferable | Uninferable]'#
platform information used in
--helpscreens 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: