A library for working with phylogenetic and population genetic data.
v0.27.0
taxonomy_writer.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2020 Lucas Czech and HITS gGmbH
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
38 
39 #include <iostream>
40 
41 namespace genesis {
42 namespace taxonomy {
43 
44 // =================================================================================================
45 // Writing
46 // =================================================================================================
47 
48 void TaxonomyWriter::write( Taxonomy const& tax, std::shared_ptr<utils::BaseOutputTarget> target ) const
49 {
50  auto& os = target->ostream();
51  for( auto const& tit : preorder( tax )) {
52  os << tax_gen_.to_string( tit.taxon() );
53 
54  if( write_ids_ ) {
55  os << "\t" << tit.taxon().id();
56  }
57  if( write_ranks_ ) {
58  os << "\t" << tit.taxon().rank();
59  }
60 
61  os << "\n";
62  }
63 }
64 
65 } // namespace taxonomy
66 } // namespace genesis
taxopath.hpp
genesis::taxonomy::TaxonomyWriter::write
void write(Taxonomy const &tax, std::shared_ptr< utils::BaseOutputTarget > target) const
Definition: taxonomy_writer.cpp:48
genesis::taxonomy::preorder
utils::Range< IteratorPreorder< Taxonomy const, Taxon const > > preorder(TaxonomyType const &taxonomy)
Definition: taxonomy/iterator/preorder.hpp:206
taxonomy.hpp
taxonomy_writer.hpp
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::taxonomy::Taxonomy
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Definition: taxonomy/taxonomy.hpp:96
taxon.hpp
genesis::taxonomy::TaxopathGenerator::to_string
std::string to_string(Taxopath const &taxopath) const
Return a string representation of a Taxopath.
Definition: taxopath_generator.cpp:49
preorder.hpp