70 std::string
const& newick_filename
81 std::string
const& phyloxml_filename
84 tree, std::vector<utils::Color>{}, phyloxml_filename
90 std::vector<utils::Color>
const& color_per_branch,
91 std::string
const& phyloxml_filename
98 if( ! color_per_branch.empty() ) {
99 color_plugin.register_with( writer );
100 color_plugin.edge_colors( color_per_branch );
108 std::vector<double>
const& value_per_branch,
111 std::string
const& phyloxml_filename
114 tree, color_map( color_norm, value_per_branch ), phyloxml_filename
124 std::string
const& nexus_filename
127 tree, std::vector<utils::Color>{}, nexus_filename
133 std::vector<utils::Color>
const& color_per_branch,
134 std::string
const& nexus_filename
138 newick_writer.trailing_new_line(
false );
142 if( ! color_per_branch.empty() ) {
143 color_plugin.register_with( newick_writer );
144 color_plugin.edge_colors( color_per_branch );
151 auto taxa = utils::make_unique<utils::NexusTaxa>();
153 nexus_doc.set_block( std::move( taxa ));
156 auto trees = utils::make_unique<utils::NexusTrees>();
157 trees->add_tree(
"tree1", newick_writer.to_string(tree) );
158 nexus_doc.set_block( std::move(trees) );
167 std::vector<double>
const& value_per_branch,
170 std::string
const& nexus_filename
173 tree, color_map( color_norm, value_per_branch ), nexus_filename
184 std::vector<utils::Color>
const& color_per_branch,
185 std::vector<utils::SvgGroup>
const& node_shapes,
186 std::vector<utils::SvgGroup>
const& edge_shapes
190 std::unique_ptr<LayoutBase> layout = [&]() -> std::unique_ptr<LayoutBase> {
192 return utils::make_unique<CircularLayout>( tree, params.
type, params.
ladderize );
195 return utils::make_unique<RectangularLayout>( tree, params.
type, params.
ladderize );
197 throw std::runtime_error(
"Unknown Tree shape parameter." );
201 if( ! color_per_branch.empty() ) {
202 std::vector<utils::SvgStroke> strokes;
203 for(
auto const& color : color_per_branch ) {
204 auto stroke = params.
stroke;
205 stroke.
color = color;
207 strokes.push_back( std::move( stroke ));
213 if( ! node_shapes.empty() ) {
216 if( ! edge_shapes.empty() ) {
222 svg_doc.
margin.
left = svg_doc.margin.top = svg_doc.margin.bottom = svg_doc.margin.right = 200;
241 std::vector<utils::Color>
const& color_per_branch
254 std::vector<double>
const& value_per_branch,
259 tree, params, color_map( color_norm, value_per_branch ), color_map, color_norm
266 std::vector<utils::Color>
const& color_per_branch,
271 tree, params, color_per_branch, color_map, color_norm,
272 std::vector<utils::SvgGroup>{}, std::vector<utils::SvgGroup>{}
279 std::vector<utils::Color>
const& color_per_branch,
282 std::vector<utils::SvgGroup>
const& node_shapes,
283 std::vector<utils::SvgGroup>
const& edge_shapes
287 tree, params, color_per_branch, node_shapes, edge_shapes
291 if( ! color_map.
empty() ) {
295 svg_pal_settings.height = svg_doc.bounding_box().height() / 2.0;
296 svg_pal_settings.width = svg_pal_settings.height / 10.0;
297 svg_pal_settings.line_width = svg_pal_settings.height / 300.0;
298 svg_pal_settings.text_size = svg_pal_settings.height / 30.0;
304 1.2 * svg_doc.bounding_box().width() / 2.0, 0.0
306 svg_doc.margin.right = 0.2 * svg_doc.bounding_box().width() / 2.0 + 2 * svg_pal_settings.width + 200;
310 1.2 * svg_doc.bounding_box().width(), svg_pal_settings.height
312 svg_doc.margin.right = 0.2 * svg_doc.bounding_box().width() + 2 * svg_pal_settings.width + 200;
316 if( ! svg_scale.first.empty() ) {
317 svg_doc.defs.push_back( svg_scale.first );
319 svg_doc.add( svg_scale.second );
328 std::vector<utils::Color>
const& color_per_branch,
329 std::vector<utils::Color>
const& color_list,
330 std::vector<std::string>
const& color_labels
334 tree, params, color_per_branch,
335 std::vector<utils::SvgGroup>{}, std::vector<utils::SvgGroup>{}
346 1.2 * svg_doc.bounding_box().width() / 2.0, 0.0
352 1.2 * svg_doc.bounding_box().width(), svg_doc.bounding_box().height() / 2.0
359 auto const sf = ( svg_doc.bounding_box().height() / 2.0 ) / (
static_cast<double>( color_list.size() ) * 15.0 );
363 svg_doc.add( svg_color_list );
374 std::string
const& svg_filename
380 tree, params, std::vector<utils::Color>{},
389 std::vector<utils::Color>
const& color_per_branch,
390 std::string
const& svg_filename
396 tree, params, color_per_branch,
405 std::vector<double>
const& value_per_branch,
408 std::string
const& svg_filename
411 tree, params, color_map( color_norm, value_per_branch ), color_map, color_norm, svg_filename
418 std::vector<utils::Color>
const& color_per_branch,
421 std::string
const& svg_filename
425 tree, params, color_per_branch, color_map, color_norm
429 svg_doc.write( ofs );
435 std::vector<utils::Color>
const& color_per_branch,
438 std::vector<utils::SvgGroup>
const& node_shapes,
439 std::vector<utils::SvgGroup>
const& edge_shapes,
440 std::string
const& svg_filename
444 tree, params, color_per_branch, color_map, color_norm, node_shapes, edge_shapes
448 svg_doc.write( ofs );
454 std::vector<utils::Color>
const& color_per_branch,
455 std::vector<utils::Color>
const& color_list,
456 std::vector<std::string>
const& color_labels,
457 std::string
const& svg_filename
461 tree, params, color_per_branch, color_list, color_labels
465 svg_doc.write( ofs );