3.3 Program Structure

PyPedal programs load pedigrees from files and operate on those pedigrees. A program consists of four basic parts: a header, an options section, pedigree creation, and pedigree operations. The program header is used to import modules used in that program, and may include any Python module available on your system. You must import a module before you can use it:
# Program header -- load modules used by a program
from PyPedal import pyp_newclasses
from PyPedal import  pyp_metrics
You should only import modules that you are going to use in your program; you do not need to import every PyPedal module in every program you write.

PyPedal recognizes a number of diffferent options that are used to control its behavior (Section 3.4). Before you can load your pedigree into a PyPedal object you must provide a pedigree file name ("pedname") and a pedigree format string ("pedformat"). This is done by either creating a Python dictionary and passing it as a parameter when pyp_newclasses.loadPedigree() is called or by specifying a configuration file name. For example, here is how you would create and populate an options dictionary:

options = {}
options['messages'] = 'verbose'
options['renumber'] = 0
options['pedfile'] = 'new_lacy.ped'
options['pedformat'] = 'asd'
options['pedname'] = 'Lacy (1989) Pedigree'
The syntax used in a configuration file is similar. Consider the file options.ini, which contains the same options as set in the options dictionary in the previous example:
# options.ini
# This is an example of a PyPedal configuration file
messages = verbose
renumber = 0
pedfile = new_lacy.ped
pedformat = asd
pedname = Lacy (1989) Pedigree
More details on configuration files are provided in Section 3.4.1.

You may name your dictionary or configuration file whatever you like; the examples in this manual, as well as those distributed with PyPedal, use the name "options". Once you have defined your options to is time to load your pedigree. This is as simple as calling pyp_newclasses.NewPedigree():

example = pyp_newclasses.loadPedigree(options)
If you would like to use a configuration file to set your pedigree options, supply the configuration file name using the optionsfile keyword:
example = pyp_newclasses.loadPedigree(optionsfile='options.ini')
Once you have loaded your pedigree file into a NewPedigree object you can unleash the awesome power of a fully-functional PyPedal installation on it. For example, calculating the effective number of founders in your pedigree using Lacy's ref640 exact method is as simple as:
pyp_metrics.effective_founders_lacy(example)
Example programs that demonstrate how to use many of the features of PyPedal are included in the "examples" directory of the distribution.
See About this document... for information on suggesting changes.