71 if (s.length() !=
length) {
72 throw std::runtime_error(
"Sequences do not have the same length." );
76 throw std::runtime_error(
"Sequences are empty." );
80 os << sset.size() <<
" " << length <<
"\n";
83 if( label_length_ == 0 ) {
84 os << s.label() <<
" ";
86 os << s.label().substr( 0, label_length_ );
87 if( label_length_ > s.label().length() ) {
88 os << std::string( label_length_ - s.label().length(),
' ' );
93 if( line_length_ > 0 ) {
94 for(
size_t i = 0; i < s.length(); i += line_length_ ) {
97 os << s.sites().substr( i, line_length_ ) <<
"\n";
100 os << s.sites() <<
"\n";
128 std::ostringstream oss;
154 label_length_ = value;
165 return label_length_;
177 line_length_ = value;
void file_output_stream(std::string const &filename, std::ofstream &out_stream, std::ios_base::openmode mode=std::ios_base::out)
Helper function to obtain an output stream to a file.
size_t line_length() const
Get the current line length.
std::string to_string(SequenceSet const &sset) const
Return Sequences of a SequenceSet in form of a Phylip formatted string.
Provides functions for accessing the file system.
Store a set of Sequences.
void to_stream(SequenceSet const &sset, std::ostream &os) const
Write Sequences of a SequenceSet to a stream in Phylip format.
void to_file(SequenceSet const &sset, std::string const &fn) const
Write Sequences of a SequenceSet to a file in Phylip format.
size_t label_length() const
Return the currently set label length.
double length(Tree const &tree)
Get the length of the tree, i.e., the sum of all branch lengths.