biomcmc-lib  0.1
low level library for phylogenetic analysis
genetree.h
Go to the documentation of this file.
1 /*
2  * This file is part of biomcmc-lib, a low-level library for phylogenomic analysis.
3  * Copyright (C) 2019-today Leonardo de Oliveira Martins [ leomrtns at gmail.com; http://www.leomartins.org ]
4  *
5  * biomcmc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11  * details (file "COPYING" or http://www.gnu.org/copyleft/gpl.html).
12  */
13 
19 #ifndef _biomcmc_genetree_h_
20 #define _biomcmc_genetree_h_
21 
22 #include "upgma.h"
23 
24 typedef struct genetree_struct* genetree;
25 typedef struct speciestree_struct* speciestree;
27 typedef struct splitset_struct* splitset;
28 
30 {
31  topology t;
32  reconciliation rec;
33  speciestree sptre;
34  splitset split;
35  int *distance, *minmax;
36  int ref_counter;
37 };
38 
40 {
41  topology t;
42  topol_node *mrca;
45 };
46 
49 {
50  topol_node *map_d;
52  int *sp_id,
53  *sp_count,
54  sp_size,
55  size_diff,
56  *dup,
57  *ndup_d,
58  *ndup_u,
59  *nlos_d,
60  *nlos_u,
61  ndups,
62  nloss,
63  ndcos;
64 };
65 
67 {
68  int size, spsize, spr, spr_extra, rf, hdist, hdist_reduced;
69  int n_g, n_s, n_agree, n_disagree;
70  bipartition *g_split, *s_split, *agree, *disagree, *sp0; /* sp0 points to vec[0], s_split points to vec[x] */
71  bipartition prune;
72  hungarian h; /* hungarian method for solving the assignment between edges */
73  bool match;
74 };
75 
76 // convenience function
77 genetree new_genetree_speciestree_pair (topology gene, topology species);
79 genetree new_genetree (topology gene, speciestree sptre);
80 void del_genetree (genetree gtre);
82 speciestree new_speciestree (topology species, int *order_of_species_names);
83 void del_speciestree (speciestree sptre);
85 void genetree_speciestree_distances (genetree gtre, speciestree sptre);
87 int count_species_in_index_species_gene (int *sp_id, int max_sp, int n_sp_id);
88 
90 void genetree_reconcile_speciestree (genetree gtre, speciestree sptre);
92 void genetree_dSPR_speciestree (genetree gtre, speciestree sptre, int level);
93 
94 #endif
speciestree new_speciestree(topology species, int *order_of_species_names)
Allocate space for new speciestree_struct, given a species topology and optionally the order of speci...
Definition: genetree.c:76
int ref_counter
Length+lexico order of sptree leaf names (not used unless added by user, when arbitrary leaf ordering...
Definition: genetree.h:44
Definition: genetree.h:66
void genetree_reconcile_speciestree(genetree gtre, speciestree sptre)
<debug function>=""> dups.loss, ils calculation; accepts unseen speciestree_struct (i...
Definition: genetree.c:123
int count_species_in_index_species_gene(int *sp_id, int max_sp, int n_sp_id)
from gene-species map index, count number of distinct species represented
Definition: reconciliation.c:96
mapping between gene tree nodes (this) and (external) species tree nodes
Definition: genetree.h:48
topol_node * map_u
Mapping of all nodes from gene to species (the first gene::nnodes are fixed)
Definition: genetree.h:51
Definition: lowlevel.h:71
void genetree_dSPR_speciestree(genetree gtre, speciestree sptre, int level)
<debug function>=""> dSPR (level > 1), hdist (level > 0), and RF distances; doesn&#39;t need to update sp...
Definition: genetree.c:130
genetree new_genetree(topology gene, speciestree sptre)
Allocate space for new genetree_struct, given a gene topology and a specestree_struct.
Definition: genetree.c:38
Definition: genetree.h:29
Information of a node (binary tree).
Definition: topology_common.h:35
int * spnames_order
triangular matrix of topol_nodes (LCA between topol_node::id (i-1) and j) in one dimension ...
Definition: genetree.h:43
int sp_size
how many copies of each species are present in this gene (used by deepcoal)
Definition: genetree.h:52
UPGMA and bioNJ from (onedimensional representation of) distance matrices.
int n_g
spr, extra prunes for spr, rf distances and hdist=assignment cost
Definition: genetree.h:69
Definition: genetree.h:39
void genetree_speciestree_distances(genetree gtre, speciestree sptre)
calculates all (discrete) distances and update min and max
Definition: genetree.c:107
Bit-string representation of splits.
Definition: bipartition.h:30
Binary unrooted topology (rooted at leaf with ID zero)
Definition: topology_common.h:47