|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
47 std::string
const& target_key
49 indexed_attributes_.push_back({ source, index, target, target_key,
"",
false });
57 std::string
const& target_key,
58 std::string
const& default_value
60 indexed_attributes_.push_back({ source, index, target, target_key, default_value,
true });
67 std::string
const& target_key_prefix
69 catch_all_attributes_.push_back({ source, 0, target, target_key_prefix,
"",
false });
84 indexed_attributes_.clear();
85 catch_all_attributes_.clear();
97 process_indexed_attributes_( element, attributes,
Target::kNode );
98 process_catch_all_attributes_( element, attributes,
Target::kNode );
106 process_indexed_attributes_( element, attributes,
Target::kEdge );
107 process_catch_all_attributes_( element, attributes,
Target::kEdge );
141 std::vector<std::string>
const& IndexedAttributeTreeNewickReaderPlugin::get_attribute_source_(
157 throw std::runtime_error(
"Invalid source type for indexed attribute." );
162 throw std::runtime_error(
"Invalid source type for indexed attribute." );
165 void IndexedAttributeTreeNewickReaderPlugin::process_indexed_attributes_(
166 NewickBrokerElement
const& element,
171 for(
auto const& attrs : indexed_attributes_ ) {
174 if( attrs.target != target ) {
179 auto const& src = get_attribute_source_( element, attrs.source );
182 if( attrs.index < src.size() ) {
183 attributes[ attrs.target_key ] = src[ attrs.index ];
184 }
else if( attrs.use_default ) {
185 attributes[ attrs.target_key ] = attrs.default_value;
190 void IndexedAttributeTreeNewickReaderPlugin::process_catch_all_attributes_(
191 NewickBrokerElement
const& element,
196 for(
auto const& attrs : catch_all_attributes_ ) {
199 if( attrs.target != target ) {
204 auto const& src = get_attribute_source_( element, attrs.source );
208 for(
auto const& elem : src ) {
create_node_data_function create_node_data_plugin
void element_to_edge(NewickBrokerElement const &element, TreeEdge &edge) const
std::map< std::string, std::string > AttributeTreeMap
Alias for the map type used by an AttributeTree.
std::vector< std::string > comments
Arbitrary strings that can be attached to a node, e.g. in Newick format via "[]".
create_edge_data_function create_edge_data_plugin
Source
Select which kind of Newick data to take, i.e., either comments, values, or tags.
Provide a set of plugin functions for NewickReader to read ordered attributes of the Nodes and Edges ...
std::vector< std::string > values
Numerical values associated with the node, i.e. branch lengths.
std::string to_string(GenomeLocus const &locus)
Data class for AttributeTreeEdges.
std::vector< element_to_edge_function > element_to_edge_plugins
Target
Select where to store the data, i.e., at Nodes or Edges of the Tree.
@ kValue
Take data from Newick values, i.e., :3.14.
std::vector< std::string > tags
Arbitrary strings that can be attached to a node, e.g. in Newick format via "{}".
@ kComment
Take data from Newick comments, i.e., [something].
static std::unique_ptr< AttributeTreeEdgeData > create()
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
@ kEdge
Store data at the attributes map of an AttributeTreeEdge.
void clear()
Reset all settings to the default, i.e., delete all attribute settings.
@ kTag
Take data from Newick tags, i.e., {42}.
std::vector< element_to_node_function > element_to_node_plugins
self_type & add_attribute(Source source, size_t index, Target target, std::string const &target_key)
Store the Newick data at a given index in an AttributeTreeMap.
Store the information for one element of a Newick tree.
Data class for AttributeTreeNodes.
void register_with(NewickReader &reader) const
@ kNode
Store data at the attributes map of an AttributeTreeNode.
static std::unique_ptr< AttributeTreeNodeData > create()
void element_to_node(NewickBrokerElement const &element, TreeNode &node) const
self_type & add_catch_all(Source source, Target target, std::string const &target_key_prefix)
Store all Newick data of a given source in an AttributeTreeMap.