Functions | |
def | set_ancestor_flag |
def | set_generation |
def | set_age |
def | set_species |
def | assign_sexes |
def | assign_offspring |
def | reorder |
def | fast_reorder |
def | renumber |
def | load_id_map |
def | delete_id_map |
def | trim_pedigree_to_year |
def | pedigree_range |
def | sort_dict_by_keys |
def | sort_dict_by_values |
def | simple_histogram_dictionary |
def | reverse_string |
def | pyp_nice_time |
def | string_to_table_name |
def | pyp_datestamp |
def | subpedigree |
def | founders_from_list |
def PyPedal::pyp_utils::assign_offspring | ( | pedobj | ) |
assign_offspring() assigns offspring to their parent(s)'s unknown sex offspring list (well, dictionary).
myped | An instance of a NewPedigree object. |
assign_offspring() assigns offspring to their parent(s)'s unknown sex offspring list (well, dictionary).
Definition at line 267 of file pyp_utils.py.
def PyPedal::pyp_utils::assign_sexes | ( | pedobj | ) |
assign_sexes() assigns a sex to every animal in the pedigree using sire and daughter lists for improved accuracy.
pedobj | A renumbered and reordered PyPedal pedigree object. |
assign_sexes() assigns a sex to every animal in the pedigree using sire and daughter lists for improved accuracy.
Definition at line 226 of file pyp_utils.py.
def PyPedal::pyp_utils::delete_id_map | ( | filetag = '_renumbered_' |
) |
delete_id_map() checks to see if an ID map for the given filetag exists. If the file exists, it is deleted.
filetag | A descriptor prepended to output file names that is used to determine name of the file to delete. |
delete_id_map() checks to see if an ID map for the given filetag exists. If the file exists, it is deleted.
Definition at line 778 of file pyp_utils.py.
def PyPedal::pyp_utils::fast_reorder | ( | myped, | ||
filetag = '_new_reordered_' , |
||||
io = 'no' , |
||||
debug = 0 | ||||
) |
fast_reorder() renumbers a pedigree such that parents precede their offspring in the pedigree. In order to minimize overhead as much as is reasonably possible, a list of animal IDs that have already been seen is kept. Whenever a parent that is not in the seen list is encountered, the offspring of that parent is moved to the end of the pedigree. This should ensure that the pedigree is properly sorted such that all parents precede their offspring. myped is reordered in place. fast_reorder() uses dictionaries to renumber the pedigree based on paddedIDs.
myped | A PyPedal pedigree object. | |
filetag | A descriptor prepended to output file names. | |
io | Indicates whether or not to write the reordered pedigree to a file (yes|no). | |
debug | Flag to indicate whether or not debugging messages are written to STDOUT. |
Renumber a pedigree such that parents precede their offspring in the pedigree. In order to minimize overhead as much as is reasonably possible, a list of animal IDs that have already been seen is kept. Whenever a parent that is not in the seen list is encountered, the offspring of that parent is moved to the end of the pedigree. This should ensure that the pedigree is properly sorted such that all parents precede their offspring. myped is reordered in place. reorder() is VERY slow, but I am pretty sure that it works correctly. fast_reorder() appears to be VERY fast, but I am not sure if it works correctly all of the time or not. Use this procedure at your own risk!
Definition at line 540 of file pyp_utils.py.
def PyPedal::pyp_utils::founders_from_list | ( | anlist, | ||
unkID | ||||
) |
founders_from_list() takes a list of NewAnimal objects and returns a list of animalIDs that represent founders in that pedigree (animals with an unknown sire and dam.
anlist | A list of NewAnimal objects. | |
unkID | The animalID assigned to unknown parents. |
founders_from_list() takes a list of NewAnimal objects and returns a list of animalIDs that represent founders in that pedigree (animals with an unknown sire and dam.
Definition at line 1052 of file pyp_utils.py.
def PyPedal::pyp_utils::load_id_map | ( | filetag = '_renumbered_' |
) |
load_id_map() reads an ID map from the file generated by pyp_utils/renumber() into a dictionary. There is a VERY similar function, pyp_io/id_map_from_file(), that is deprecated because it is much more fragile that this procedure.
filetag | A descriptor prepended to output file names that is used to determine the input file name. |
load_id_map() reads an ID map from the file generated by pyp_utils/renumber() into a dictionary. There is a VERY similar function, pyp_io/id_map_from_file(), that is deprecated because it is much more fragile that this procedure.
Definition at line 740 of file pyp_utils.py.
def PyPedal::pyp_utils::pedigree_range | ( | pedobj, | ||
n | ||||
) |
pedigree_range() takes a renumbered pedigree and removes all individuals with a renumbered ID > n. The reduced pedigree is returned. Assumes that the input pedigree is sorted on animal key in ascending order.
myped | A PyPedal pedigree object. | |
n | A renumbered animalID. |
pedigree_range() takes a renumbered pedigree and removes all individuals with a renumbered ID > n. The reduced pedigree is returned. Assumes that the input pedigree is sorted on animal key in ascending order.
Definition at line 829 of file pyp_utils.py.
def PyPedal::pyp_utils::pyp_datestamp | ( | ) |
pyp_datestamp() returns a datestamp, as a string, of the format YYYYMMDDHHMMSS.
None |
pyp_datestamp() returns a datestamp, as a string, of the format YYYYMMDDHHMMSS.
Definition at line 988 of file pyp_utils.py.
def PyPedal::pyp_utils::pyp_nice_time | ( | ) |
pyp_nice_time() returns the current date and time formatted as, e.g., Wed Mar 30 10:26:31 2005.
None |
pyp_nice_time() returns the current date and time formatted as, e.g., Wed Mar 30 10:26:31 2005.
Definition at line 952 of file pyp_utils.py.
def PyPedal::pyp_utils::renumber | ( | myped, | ||
filetag = '_renumbered_' , |
||||
io = 'no' , |
||||
outformat = '0' , |
||||
debug = 0 , |
||||
returnmap = 0 , |
||||
missingparent = 0 , |
||||
animaltype = 'new' | ||||
) |
renumber() takes a pedigree as input and renumbers it such that the oldest animal in the pedigree has an ID of '1' and the n-th animal has an ID of 'n'. If the pedigree is not ordered from oldest to youngest such that all offspring precede their offspring, the pedigree will be reordered. The renumbered pedigree is written to disc in 'asd' format and a map file that associates sequential IDs with original IDs is also written.
myped | A PyPedal pedigree object. | |
filetag | A descriptor prepended to output file names. | |
io | Indicates whether or not to write the renumbered pedigree to a file (yes|no). | |
outformat | Flag to indicate whether or not to write an asd pedigree (0) or a full pedigree (1). | |
returnmap | Indicates whether or not an ID map, as well as the renumbered pedigree, should be returned. If nonzero, suppresses writing of ID maps to disc. | |
debug | Flag to indicate whether or not progress messages are written to stdout. | |
missingparent | Indicates the value used to indicate a missing parent. | |
animaltype | Type of animal object used to populate pedigree |
renumber() takes a pedigree as input and renumbers it such that the oldest animal in the pedigree has an ID of '1' and the n-th animal has an ID of 'n'. If the pedigree is not ordered from oldest to youngest such that all offspring precede their offspring, the pedigree will be reordered. The renumbered pedigree is written to disc in 'asd' format and a map file that associates sequential IDs with original IDs is also written.
Definition at line 611 of file pyp_utils.py.
def PyPedal::pyp_utils::reorder | ( | myped, | ||
filetag = '_reordered_' , |
||||
io = 'no' , |
||||
missingparent = 0 , |
||||
debug = 0 , |
||||
max_rounds = 100 | ||||
) |
reorder() renumbers a pedigree such that parents precede their offspring in the pedigree. In order to minimize overhead as much as is reasonably possible, a list of animal IDs that have already been seen is kept. Whenever a parent that is not in the seen list is encountered, the offspring of that parent is moved to the end of the pedigree. This should ensure that the pedigree is properly sorted such that all parents precede their offspring. myped is reordered in place. reorder() is VERY slow, but I am pretty sure that it works correctly.
myped | A PyPedal pedigree object. | |
filetag | A descriptor prepended to output file names. | |
io | Indicates whether or not to write the reordered pedigree to a file (yes|no). | |
missingparent | Indicates the value used to indicate a missing parent. | |
debug | Toggles debugging messages on and off. | |
max_rounds | Maximum times to iterate through a pedigree trying to reorder it. |
Renumber a pedigree such that parents precede their offspring in the pedigree. In order to minimize overhead as much as is reasonably possible, a list of animal IDs that have already been seen is kept. Whenever a parent that is not in the seen list is encountered, the offspring of that parent is moved to the end of the pedigree. This should ensure that the pedigree is properly sorted such that all parents precede their offspring. myped is reordered in place. reorder() is VERY slow, but I am pretty sure that it works correctly.
Definition at line 338 of file pyp_utils.py.
def PyPedal::pyp_utils::reverse_string | ( | mystring | ) |
reverse_string() reverses the input string and returns the reversed version.
mystring | A non-empty Python string. |
reverse_string() reverses the input string and returns the reversed version.
Definition at line 930 of file pyp_utils.py.
def PyPedal::pyp_utils::set_age | ( | pedobj | ) |
set_age() Computes ages for all animals in a pedigree based on the global BASE_DEMOGRAPHIC_YEAR defined in pyp_demog.py. If the by is unknown, the inferred generation is used. If the inferred generation is unknown, the age is set to -999.
pedobj | A PyPedal pedigree object. |
set_age() Computes ages for all animals in a pedigree based on the global BASE_DEMOGRAPHIC_YEAR defined in pyp_demog.py. If the by is unknown, the inferred generation is used. If the inferred generation is unknown, the age is set to -999.
Definition at line 172 of file pyp_utils.py.
def PyPedal::pyp_utils::set_ancestor_flag | ( | pedobj | ) |
set_ancestor_flag() loops through a pedigree to build a dictionary of all of the parents in the pedigree. It then sets the ancestor flags for the parents. set_ancestor_flag() expects a reordered and renumbered pedigree as input!
pedobj | A PyPedal NewPedigree object. |
set_ancestor_flag() loops through a pedigree to build a dictionary of all of the parents in the pedigree. It then sets the ancestor flags for the parents. set_ancestor_flag() expects a reordered and renumbered pedigree as input!
Definition at line 56 of file pyp_utils.py.
def PyPedal::pyp_utils::set_generation | ( | pedobj | ) |
set_generation() Works through a pedigree to infer the generation to which an animal belongs based on founders belonging to generation 1. The igen assigned to an animal as the larger of sire.igen+1 and dam.igen+1. This routine assumes that myped is reordered and renumbered.
pedobj | A PyPedal NewPedigree object. |
set_generation() Works through a pedigree to infer the generation to which an animal belongs based on founders belonging to generation 1. The igen assigned to an animal as the larger of sire.igen+1 and dam.igen+1. This routine assumes that myped is reordered and renumbered.
Definition at line 120 of file pyp_utils.py.
def PyPedal::pyp_utils::set_species | ( | pedobj, | ||
species = 'u' | ||||
) |
set_species() assigns a specie to every animal in the pedigree.
set_species() assigns a specie to every animal in the pedigree.
Definition at line 202 of file pyp_utils.py.
def PyPedal::pyp_utils::simple_histogram_dictionary | ( | mydict, | ||
histchar = '*' , |
||||
histstep = 5 | ||||
) |
simple_histogram_dictionary() returns a dictionary containing a simple, text histogram. The input dictionary is assumed to contain keys which are distinct levels and values that are counts.
mydict | A non-empty Python dictionary. | |
histchar | The character used to draw the histogram (default is '*'). | |
histstep | Used to determine the number of bins (stars) in the diagram. |
simple_histogram_dictionary() returns a dictionary containing a simple, text histogram. The input dictionary is assumed to contain keys which are distinct levels and values that are counts.
Definition at line 899 of file pyp_utils.py.
def PyPedal::pyp_utils::sort_dict_by_keys | ( | mydict | ) |
sort_dict_by_keys() returns a dictionary where the values in the dictionary in the order obtained by sorting the keys. Taken from the routine sortedDictValues3 in the "Python Cookbook", p. 39.
mydict | A non-empty Python dictionary. |
sort_dict_by_keys() returns a dictionary where the values in the dictionary in the order obtained by sorting the keys. Taken from the routine sortedDictValues3 in the "Python Cookbook", p. 39.
Definition at line 853 of file pyp_utils.py.
def PyPedal::pyp_utils::sort_dict_by_values | ( | first, | ||
second | ||||
) |
sort_dict_by_values() returns a dictionary where the keys in the dictionary are sorted ascending value, first on value and then on key within value. The implementation was taken from John Hunter's contribution to a newsgroup thread: http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/bbc259f8454e4d3f/cc686f4cd795feb4?q=python+%22sorted+dictionary%22&rnum=1&hl=en#cc686f4cd795feb4
mydict | A non-empty Python dictionary. |
sort_dict_by_values() returns a dictionary where the keys in the dictionary are sorted ascending value, first on value and then on key within value. The implementation was taken from John Hunter's contribution to a newsgroup thread: http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread /bbc259f8454e4d3f/cc686f4cd795feb4?q=python+%22sorted+dictionary%22& rnum=1&hl=en#cc686f4cd795feb4
Definition at line 877 of file pyp_utils.py.
def PyPedal::pyp_utils::string_to_table_name | ( | instring | ) |
string_to_table_name() takes an arbitrary string and returns a string that is safe to use as an SQLite table name.
instring | A string that will be converted to an SQLite-safe table name. |
string_to_table_name() takes an arbitrary string and returns a string that is safe to use as an SQLite table name.
Definition at line 968 of file pyp_utils.py.
def PyPedal::pyp_utils::subpedigree | ( | pedobj, | ||
anlist | ||||
) |
subpedigree() takes a NewPedigree object and list of animal IDs and returns a NewPedigree object containing only the animals in the animals list.
pedobj | PyPedal pedigree object. | |
animals | A list of animal IDs. |
subpedigree() takes a NewPedigree object and list of animal IDs and returns a NewPedigree object containing only the animals in the animals list.
Definition at line 1007 of file pyp_utils.py.
def PyPedal::pyp_utils::trim_pedigree_to_year | ( | pedobj, | ||
year | ||||
) |
trim_pedigree_to_year() takes pedigrees and removes all individuals who were not born in birthyear 'year'.
myped | A PyPedal pedigree object. | |
year | A birthyear. |
trim_pedigree_to_year() takes pedigrees and removes all individuals who were not born in birthyear 'year'.
Definition at line 798 of file pyp_utils.py.