biomcmc-lib  0.1
low level library for phylogenetic analysis
topology_space.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 
21 #ifndef _biomcmc_topology_space_h_
22 #define _biomcmc_topology_space_h_
23 
24 #include "newick_space.h"
25 
27 
31 {
32  int ntrees, ndistinct;
33  topology *tree, *distinct;
34  double *freq;
37  bool is_rooted;
38  char *filename;
39 };
40 
42 void add_string_with_size_to_topology_space (topology_space *tsp_address, char *long_string, size_t string_size, bool use_root_location);
44 void add_topology_to_topology_space_if_distinct (topology topol, topology_space tsp, double tree_weight, bool use_root_location);
45 
47 topology_space read_topology_space_from_file (char *seqfilename, hashtable external_taxhash, bool use_root_location);
49 topology_space read_topology_space_from_file_with_burnin_thin (char *seqfilename, hashtable external_taxhash, int burnin, int thin, bool use_root_location);
51 void merge_topology_spaces (topology_space ts1, topology_space ts2, double weight_ts1, bool use_root_location);
52 void sort_topology_space_by_frequency(topology_space tsp, double *external_freqs) ; // INCOMPLETE
53 
55 void save_topology_space_to_trprobs_file (topology_space tsp, char *filename, double credible);
57 int estimate_treesize_from_file (char *seqfilename);
58 
60 topology_space new_topology_space (void);
62 void del_topology_space (topology_space tsp);
63 
64 #endif
char * filename
If trees are unrooted, then branch lengths must be accounted for in some comparisons.
Definition: topology_space.h:38
topology_space read_topology_space_from_file_with_burnin_thin(char *seqfilename, hashtable external_taxhash, int burnin, int thin, bool use_root_location)
lower level function where we can specify burnin and thinning factor, in iterations ...
Definition: topology_space.c:139
Hash table (vector indexed by strings).
Definition: hashtable.h:42
Reads a list of trees in newick format and creates vector of topologies.
double * freq
Vector of trees originally in nexus file and compacted.
Definition: topology_space.h:34
topology_space new_topology_space(void)
Allocates memory for topology_space_struct (set of trees present in nexus file).
Definition: topology_space.c:357
vector of strings (char vectors) of variable length
Definition: char_vector.h:27
bool is_rooted
Lookup table with taxon names.
Definition: topology_space.h:37
void merge_topology_spaces(topology_space ts1, topology_space ts2, double weight_ts1, bool use_root_location)
merge trees from two topology_space objects, assuming names hashtable is the same ...
Definition: topology_space.c:232
void add_topology_to_topology_space_if_distinct(topology topol, topology_space tsp, double tree_weight, bool use_root_location)
Add topology to topology_space only if unrooted version is distinct, updating freqs, trees[] etc. Aux for python module.
Definition: topology_space.c:518
void add_string_with_size_to_topology_space(topology_space *tsp_address, char *long_string, size_t string_size, bool use_root_location)
Read tree in newick format until char string_size, returning updated topolgy_space. Auxiliary for python module.
Definition: topology_space.c:80
topology * tree
Number of trees originally in nexus file and compacted (only distinct topologies).
Definition: topology_space.h:33
int estimate_treesize_from_file(char *seqfilename)
Quickly counts the number of leaves in a tree file, without storing any info. Assumes file and trees ...
Definition: topology_space.c:332
Collection of topologies from tree file. When topologies have no branch lengths we store only unique ...
Definition: topology_space.h:30
void del_topology_space(topology_space tsp)
Free memory from topology_space_struct.
Definition: topology_space.c:379
void save_topology_space_to_trprobs_file(topology_space tsp, char *filename, double credible)
Save topology_space to a file, in format nexus w/ trprobs, up to "credible" cummul frequency...
Definition: topology_space.c:292
topology_space read_topology_space_from_file(char *seqfilename, hashtable external_taxhash, bool use_root_location)
Read tree file and store info in topology_space_struct with possible external hashtable to impose the...
Definition: topology_space.c:133
hashtable taxlabel_hash
Taxon names.
Definition: topology_space.h:36
char_vector taxlabel
frequency of each distinct topology (add up to one)
Definition: topology_space.h:35
Binary unrooted topology (rooted at leaf with ID zero)
Definition: topology_common.h:47