44 std::vector<PhyloFactor>
const& factors,
48 max_factor = std::min( max_factor, factors.size() );
49 std::vector<size_t> result;
50 for(
size_t i = 0; i < max_factor; ++i ) {
51 result.push_back( factors[i].edge_index );
62 std::vector<PhyloFactor>
const& factors,
66 if( factor_index >= factors.size() ) {
67 throw std::invalid_argument(
"Invalid index for a phylo factor." );
69 auto const& factor = factors[ factor_index ];
76 auto set_color_ = [&](
size_t index,
utils::Color color ){
77 if( index >= edge_cols.size() ) {
78 throw std::runtime_error(
"Invalid edge index in a phylo factor." );
81 edge_cols[ index ] = color;
83 throw std::runtime_error(
84 "Edge at index " +
std::to_string( index ) +
" is in multiple edge sets of the " 91 set_color_( factor.edge_index, colors.
factor_edge );
92 for(
auto const e : factor.edge_indices_primary ) {
95 for(
auto const e : factor.edge_indices_secondary ) {
101 for(
auto const e : prev_factors ) {
114 std::vector<PhyloFactor>
const& factors,
119 if( num_factors > factors.size() ) {
120 throw std::invalid_argument(
"Invalid number of factors requested." );
122 if( num_factors == 0 ) {
123 num_factors = factors.size();
126 throw std::invalid_argument(
127 "Not enough clade colors provided for the requested number of factors." 135 auto set_color_ = [&](
size_t index,
utils::Color color ){
136 if( index >= edge_cols.size() ) {
137 throw std::runtime_error(
"Invalid edge index in a phylo factor." );
139 edge_cols[ index ] = color;
143 for(
size_t i = 0; i < num_factors; ++i ) {
144 assert( i < factors.size() );
147 auto const& factor = factors[i];
151 for(
auto const e : factor.edge_indices_secondary ) {
152 set_color_( e, clade_col );
utils::Color secondary_edges
Color for the edges away from the root that have been used in this phylo factor.
size_t edge_count() const
Return the number of TreeEdges of the Tree.
utils::Color previous_factors
Color for the edges that have been factored out before (earlier factors in the greedy search)...
Store a set of colors for making visualizations of the clades of all phylo factors.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
utils::Color base_edges
Color for the edges towards the root of the first phylo factor.
utils::Color primary_edges
Color for the edges towards the root that have been used in this phylo factor.
utils::Color factor_edge
Color for the edge of that phylo factor.
Class for representing phylogenetic trees.
std::vector< utils::Color > phylo_factor_single_factor_colors(Tree const &tree, std::vector< PhyloFactor > const &factors, size_t factor_index, PhyloFactorSingleColors colors)
Return a color for each edge indicating its role in a single phylogenetic factor. ...
std::vector< utils::Color > phylo_factor_clade_colors(Tree const &tree, std::vector< PhyloFactor > const &factors, size_t num_factors, PhyloFactorCladeColors colors)
Return a color for each edge, indicating which factor (phylogenetic unit, clade) it belongs to...
utils::Color neutral_edges
Color for the edges that have not been used in this phylo factor.
std::shared_ptr< BaseOutputTarget > to_string(std::string &target_string)
Obtain an output target for writing to a string.
utils::Color factor_edges
Color for the "winning" edges of phylo factors.
Store a set of colors for making visualizations of individual phylo factors.
std::vector< utils::Color > clade_colors
Colors for the sets of edges away from the root that have been split by the phylo factors...
std::vector< size_t > phylo_factor_edge_indices(std::vector< PhyloFactor > const &factors, size_t max_factor)
Get a list of all edges that have factored out by phylogenetic_factorization().