|
Legofit
infers population history from nucleotide site patterns.
|
A single segment of a population tree. More...
#include "popnode.h"#include "gene.h"#include "misc.h"#include "parstore.h"#include "ptrptrmap.h"#include "error.h"#include "ptrqueue.h"#include <stdbool.h>#include <string.h>#include <float.h>#include <math.h>#include <gsl/gsl_randist.h>#include "plot.c"Data Structures | |
| struct | PopNode |
Macros | |
| #define | NODETYPE PopNode |
Functions | |
| static void | PopNode_transferSample (PopNode *self, Gene *gene) |
| Transfer an existing sample to a PopNode. | |
| static void | PopNode_printShallow (PopNode *self, FILE *fp) |
| Print a PopNode but not its descendants. | |
| static void | PopNode_sanityCheck (PopNode *self, const char *file, int lineno) |
| Check sanity of PopNode. | |
| static void | PopNode_sanityFromLeaf (PopNode *self, const char *file, int line) |
| Check for errors in PopNode tree. Call this from each leaf node. | |
| static int | PopNode_nsamples (PopNode *self) |
| Return the number of samples in a PopNode. | |
| static void | PopNode_duplicate_nodes (PopNode *old, PtrPtrMap *ppm) |
| Traverse tree, making a duplicate of each node, and putting the duplicates into a hash map (called ppm) in which the old node is the key and the new duplicate is the value associated with that key. | |
| static void | unlink_child (PopNode *child, PopNode *parent) |
| Remove child from parent. | |
| static int | PopNode_equals_r (PopNode *a, PopNode *b) |
| static void | PopNode_print_r (PopNode *self, FILE *fp, int indent) |
| Print a PopNode and (recursively) its descendants. | |
| int | PopNode_equals (PopNode *a, PopNode *b) |
| void * | PopNode_root (void *vself) |
| Find root of population network, starting from given node. | |
| void | PopNode_clear (PopNode *self) |
| Remove all references to samples from tree of populations. | |
| int | PopNode_isClear (const PopNode *self) |
| Return 1 if PopNode tree is empty of samples. | |
| void | PopNode_print (void *vroot, FILE *fp, int indent) |
| Print a network of PopNodes. | |
| void | PopNode_unvisit (PopNode *self) |
| Set all "visited" flags to false. | |
| void * | PopNode_new (int twoN_i, int start_i, ParStore *ps, const char *label) |
| PopNode constructor. | |
| void | PopNode_update (PopNode *self, ParStore *ps) |
| int | PopNode_addChild (void *vparent, void *vchild) |
| Connect parent and child. | |
| void | PopNode_newSample (PopNode *self, unsigned ndx) |
| Allocates a new Gene and puts it into the array within PopNode. | |
| int | PopNode_mix (void *vchild, int mix_i, void *vintrogressor, void *vnative, ParStore *ps) |
| Connect a child PopNode to two parents. | |
| Gene * | PopNode_coalesce (PopNode *self, gsl_rng *rng, long unsigned *event_counter) |
| Coalesce gene tree within population tree. | |
| void | PopNode_free (PopNode *self) |
| Free node and descendants. | |
| int | PopNode_feasible (const PopNode *self, Bounds bnd, int verbose) |
| Return 1 if parameters satisfy inequality constraints, or 0 otherwise. | |
| PopNode * | PopNode_dup (PopNode *old_root, PtrPtrMap *ppm) |
| Duplicate a network of nodes, returning a pointer to the root of the duplicate network. | |
A single segment of a population tree.
PopNode objects can be linked together into a network, which models bifurcation of populations and gene flow among them. Each PopNode knows its size and duration. It has pointers to parents and children. If it has two parents, there is also a mixing parameter, which determines what fraction of the node derives from each parent.
| void PopNode_clear | ( | PopNode * | self | ) |
Remove all references to samples from tree of populations.
Doesn't free the Gene objects, because they aren't owned by PopNode. Sets "visited" to 0 in every node.
References PopNode_clear(), and PopNode_sanityCheck().
Referenced by GPTree_brlen(), GPTree_free(), PopNode_clear(), and PopNode_dup().
Duplicate a network of nodes, returning a pointer to the root of the duplicate network.
On entry, ppm should be an empty hashmap.
References PopNode_clear(), and PopNode_duplicate_nodes().
Referenced by GPTree_dup().
| int PopNode_mix | ( | void * | vchild, |
| int | mix_i, | ||
| void * | vintrogressor, | ||
| void * | vnative, | ||
| ParStore * | ps ) |
Connect a child PopNode to two parents.
| [in,out] | child | pointer to the child PopNode |
| [in] | mPtr | pointer to the gene flow variable |
| [in,out] | introgressor | pointer to the introgressing parent |
| [in,out] | native | pointer to the native parent |
References PopNode_sanityCheck().
Referenced by Network_init().
| void PopNode_newSample | ( | PopNode * | self, |
| unsigned | ndx ) |
Allocates a new Gene and puts it into the array within PopNode.
The gene isn't owned by PopNode, however. It will eventually be freed by a recursive call to Gene_free, which will free the root Gene and all descendants.
References Gene_new(), and PopNode_sanityCheck().
Referenced by GPTree_brlen().