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.
The LightAnimal() class holds animals records read from a pedigree file.
For more information about this class, see The LightAnimal Class.
loadPedigree() wraps pedigree creation and loading into a one-step process. If the user passes both a dictionary and a filename, the dictionary will be used instead of the filename unless the dictionary is empty.
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.
The NewAnimal() class is holds animals records read from a pedigree file.
For more information about this class, see The NewAnimal Class.
The NewPedigree class is the main data structure for PyP 2.0.0Final.
For more information about this class, see The NewPedigree Class.
The PedigreeMetadata() class stores metadata about pedigrees.
For more information about this class, see The PedigreeMetadata Class.
PyPedalError is the base class for exceptions in PyPedal.
For more information about this class, see The PyPedalError Class.
PyPedalPedigreeInputFileNameError is raised when a simulated pedigree is not requested and a pedigree file name is not provided.
For more information about this class, see The PyPedalPedigreeInputFileNameError Class.
The SimAnimal() class is a placeholder used for simulating animals.
For more information about this class, see The SimAnimal Class.
tail_recursive is a tail recursion decorator that eliminates tail calls for recursive functions.
For more information about this class, see The tail_recursive Class.
The LightAnimal() class holds animals records read from a pedigree file. It is a much simpler object than the NewAnimal() object and is intended for use with the graph theoretic routines in pyp_network. The only attributes of these objects are: animal ID, sire ID, dam ID, original ID, birth year, and sex.
__init__() initializes a LightAnimal() object.
dictme() returns a summary of the data stored in the NewAnimal() object as a dictionary.
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.
printme() prints a summary of the data stored in the LightAnimal() object.
string_to_int() takes an Animal/Sire/Dam ID as a string and returns a hash.
stringme() returns a summary of the data stored in the LightAnimal() object as a string.
trap() checks for common errors in LightAnimal() objects
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.
__init__() initializes a NewAMatrix object.
form_a_matrix() calls pyp_nrm/fast_a_matrix() or pyp_nrm/fast_a_matrix_r() to form a NRM from a pedigree.
info() uses the info() method of Numarray arrays to dump some information about the NRM. This is of use predominantly for debugging.
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.
printme() prints the NRM to the screen.
save() uses the Numarray method "tofile()" to save an array to a binary file.
The NewAnimal() class is holds animals records read from a pedigree file.
__init__() initializes a NewAnimal() object.
dictme() returns a summary of the data stored in the NewAnimal() object as a dictionary.
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.
printme() prints a summary of the data stored in the NewAnimal() object.
string_to_int() takes an Animal/Sire/Dam ID as a string and returns a hash.
stringme() returns a summary of the data stored in the NewAnimal() object as a string.
trap() checks for common errors in NewAnimal() objects
The NewPedigree class is the main data structure for PyP 2.0.0Final.
__init__() initializes a NewPedigree object.
addanimal() adds a new animal of class NewAnimal to the pedigree.
delanimal() deletes an animal from the pedigree. Note that this method DOES not update the metadata attached to the pedigree and should only be used if that is not important. As of 04/10/2006 delanimal() is intended for use by pyp_metrics/mating_coi() rather than directly by users.
fromgraph() loads the animals to populate the pedigree from an XDiGraph object.
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.
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.
printoptions() prints the contents of the options dictionary.
renumber() updates the ID map after a pedigree has been renumbered so that all references are to renumbered rather than original IDs.
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.
simulate() simulates an arbitrary pedigree of size n with g generations starting from n_s base sires and n_d base dams. This method is based on the concepts and algorithms in the Pedigree::sample method from Matvec 1.1a. The arguments are read from the pedigree object's options dictionary.
updateidmap() updates the ID map after a pedigree has been renumbered so that all references are to renumbered rather than original IDs.
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__() initializes a PedigreeMetadata object.
fileme() writes the metada stored in the Pedigree() object to disc.
nud() returns the number of unique dams in the pedigree along with a list of the dams
nuf() returns the number of unique founders in the pedigree along with a list of the founders
nug() returns the number of unique generations in the pedigree along with a list of the generations
nuherds() returns the number of unique herds in the pedigree along with a list of the herds.
nus() returns the number of unique sires in the pedigree along with a list of the sires
nuy() returns the number of unique birthyears in the pedigree along with a list of the birthyears
printme() prints a summary of the metadata stored in the Pedigree() object.
stringme() returns a summary of the metadata stored in the pedigree as a string.
PyPedalError is the base class for exceptions in PyPedal. The exceptions are based on the examples from "An Introduction to Python" by Guido van Rossum and Fred L. Drake,Jr. (http://www.network-theory.co.uk/docs/pytut/tut_64.html).
PyPedalPedigreeInputFileNameError is raised when a simulated pedigree is not requested and a pedigree file name is not provided.
The SimAnimal() class is a placeholder used for simulating animals.
__init__() initializes a SimAnimal() object.
printme() prints a summary of the data stored in a SimAnimal() object.
stringme() returns the data stored in a SimAnimal() object as a string.
tail_recursive is a tail recursion decorator that eliminates tail calls for recursive functions. It was taken from the Python Cookbook entry "New Tail Recursion Decorator" submitted by Kay Schlueh. This version was provided by Michele Simionato on 2006/05/15. The URL is: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691.