The pyp_newclasses Module

pyp_newclasses contains the new class structure that will be a part of PyPedal 2.0.0Final. It includes a master class to which most of the computational routines will be bound as methods, a NewAnimal() class, and a PedigreeMetadata() class.

Module Contents

NewAMatrix(kw) (class) [#]

NewAMatrix provides an instance of a numerator relationship matrix as a Numarray array of floats with some convenience methods.

For more information about this class, see The NewAMatrix Class.

NewAnimal(locations, data, mykw) (class) [#]

The NewAnimal() class is holds animals records read from a pedigree file.

For more information about this class, see The NewAnimal Class.

NewPedigree(kw) (class) [#]

The NewPedigree class is the main data structure for PyP 2.0.0Final.

For more information about this class, see The NewPedigree Class.

PedigreeMetadata(myped, kw) (class) [#]

The PedigreeMetadata() class stores metadata about pedigrees.

For more information about this class, see The PedigreeMetadata Class.

The NewAMatrix Class

NewAMatrix(kw) (class) [#]

NewAMatrix provides an instance of a numerator relationship matrix as a Numarray array of floats with some convenience methods. The idea here is to provide a wrapper around a NRM so that it is easier to work with. For large pedigrees it can take a long time to compute the elements of A, so there is real value in providing an easy way to save and retrieve a NRM once it has been formed.

form_a_matrix(pedigree) ⇒ integer [#]

form_a_matrix() calls pyp_nrm/fast_a_matrix() or pyp_nrm/fast_a_matrix_r() to form a NRM from a pedigree.

pedigree
The pedigree used to form the NRM.
Returns:
A NRM on success, 0 on failure.

info() ⇒ None [#]

info() uses the info() method of Numarray arrays to dump some information about the NRM. This is of use predominantly for debugging.

None
Returns:
None

load(nrm_filename) ⇒ integer [#]

load() uses the Numarray Array Function "fromfile()" to load an array from a binary file. If the load is successful, self.nrm contains the matrix.

nrm_filename
The file from which the matrix should be read.
Returns:
A load status indicator (0: failed, 1: success).

save(nrm_filename) ⇒ integer [#]

save() uses the Numarray method "tofile()" to save an array to a binary file.

nrm_filename
The file to which the matrix should be written.
Returns:
A save status indicator (0: failed, 1: success).

The NewAnimal Class

NewAnimal(locations, data, mykw) (class) [#]

The NewAnimal() class is holds animals records read from a pedigree file.

__init__(locations, data, mykw) ⇒ object [#]

__init__() initializes a NewAnimal() object.

locations
A dictionary containing the locations of variables in the input line.
data
The line of input read from the pedigree file.
Returns:
An instance of a NewAnimal() object populated with data

pad_id() ⇒ integer [#]

pad_id() takes an Animal ID, pads it to fifteen digits, and prepends the birthyear (or 1950 if the birth year is unknown). The order of elements is: birthyear, animalID, count of zeros, zeros.

self
Reference to the current Animal() object
Returns:
A padded ID number that is supposed to be unique across animals

printme() [#]

printme() prints a summary of the data stored in the Animal() object.

self
Reference to the current Animal() object

string_to_int(idstring) [#]

string_to_int() takes an Animal/Sire/Dam ID as a string and returns a string that can be represented as an integer by replacing each character in the string with its corresponding ASCII table value.

stringme() [#]

stringme() returns a summary of the data stored in the Animal() object as a string.

self
Reference to the current Animal() object

trap() [#]

trap() checks for common errors in Animal() objects

self
Reference to the current Animal() object

The NewPedigree Class

NewPedigree(kw) (class) [#]

The NewPedigree class is the main data structure for PyP 2.0.0Final.

load() ⇒ None [#]

load() wraps several processes useful for loading and preparing a pedigree for use in an analysis, including reading the animals into a list of animal objects, forming lists of sires and dams, checking for common errors, setting ancestor flags, and renumbering the pedigree.

renum
Flag to indicate whether or not the pedigree is to be renumbered.
alleles
Flag to indicate whether or not pyp_metrics/effective_founder_genomes() should be called for a single round to assign alleles.
Returns:
None

preprocess() ⇒ None [#]

preprocess() processes a pedigree file, which includes reading the animals into a list of animal objects, forming lists of sires and dams, and checking for common errors.

None
Returns:
None

renumber() ⇒ None [#]

renumber() updates the ID map after a pedigree has been renumbered so that all references are to renumbered rather than original IDs.

None
Returns:
None

save(filename='', outformat='o', idformat='o') ⇒ integer [#]

save() writes a PyPedal pedigree to a user-specified file. The saved pedigree includes all fields recognized by PyPedal, not just the original fields read from the input pedigree file.

filename
The file to which the pedigree should be written.
outformat
The format in which the pedigree should be written: 'o' for original (as read) and 'l' for long version (all available variables).
idformat
Write 'o' (original) or 'r' (renumbered) animal, sire, and dam IDs.
Returns:
A save status indicator (0: failed, 1: success)

updateidmap() ⇒ None [#]

updateidmap() updates the ID map after a pedigree has been renumbered so that all references are to renumbered rather than original IDs.

None
Returns:
None

The PedigreeMetadata Class

PedigreeMetadata(myped, kw) (class) [#]

The PedigreeMetadata() class stores metadata about pedigrees. Hopefully this will help improve performance in some procedures, as well as provide some useful summary data.

__init__(myped, kw) ⇒ object [#]

__init__() initializes a PedigreeMetadata object.

self
Reference to the current Pedigree() object
myped
A PyPedal pedigree.
kw
A dictionary of options.
Returns:
An instance of a Pedigree() object populated with data

fileme() [#]

fileme() writes the metada stored in the Pedigree() object to disc.

self
Reference to the current Pedigree() object

nud() ⇒ integer-and-list [#]

nud() returns the number of unique dams in the pedigree along with a list of the dams

self
Reference to the current Pedigree() object
Returns:
The number of unique dams in the pedigree and a list of those dams

nuf() ⇒ integer-and-list [#]

nuf() returns the number of unique founders in the pedigree along with a list of the founders

self
Reference to the current Pedigree() object
Returns:
The number of unique founders in the pedigree and a list of those founders

nug() ⇒ integer-and-list [#]

nug() returns the number of unique generations in the pedigree along with a list of the generations

self
Reference to the current Pedigree() object
Returns:
The number of unique generations in the pedigree and a list of those generations

nus() ⇒ integer-and-list [#]

nus() returns the number of unique sires in the pedigree along with a list of the sires

self
Reference to the current Pedigree() object
Returns:
The number of unique sires in the pedigree and a list of those sires

nuy() ⇒ integer-and-list [#]

nuy() returns the number of unique birthyears in the pedigree along with a list of the birthyears

self
Reference to the current Pedigree() object
Returns:
The number of unique birthyears in the pedigree and a list of those birthyears

printme() [#]

printme() prints a summary of the metadata stored in the Pedigree() object.

self
Reference to the current Pedigree() object

stringme() [#]

stringme() returns a summary of the metadata stored in the pedigree as a string.

self
Reference to the current Pedigree() object