bpp-seq3  3.0.0
bpp::PhylipDistanceMatrixFormat Class Reference

Distance matrix I/O in Phylip format. More...

#include <Bpp/Seq/Io/PhylipDistanceMatrixFormat.h>

+ Inheritance diagram for bpp::PhylipDistanceMatrixFormat:
+ Collaboration diagram for bpp::PhylipDistanceMatrixFormat:

Public Member Functions

 PhylipDistanceMatrixFormat (bool extended=false)
 
virtual ~PhylipDistanceMatrixFormat ()
 
const std::string getFormatName () const
 
const std::string getFormatDescription () const
 
std::unique_ptr< DistanceMatrixreadDistanceMatrix (const std::string &path) const
 Read a distance matrix from a file. More...
 
std::unique_ptr< DistanceMatrixreadDistanceMatrix (std::istream &in) const
 Read a distance matrix from a stream. More...
 
void writeDistanceMatrix (const DistanceMatrix &dist, const std::string &path, bool overwrite=true) const
 Write a distance matrix to a file. More...
 
void writeDistanceMatrix (const DistanceMatrix &dist, std::ostream &out) const
 Write a distance matrix to a stream. More...
 
virtual const std::string getDataType () const
 

Private Attributes

bool extended_
 

Detailed Description

Distance matrix I/O in Phylip format.

Entry names must be 10 characters long. If 'extended' is set to true, then entry names can be of any size, and should be separated from the data by at least two spaces. Names should therefore not contain more than one consecutive space.

Definition at line 20 of file PhylipDistanceMatrixFormat.h.

Constructor & Destructor Documentation

◆ PhylipDistanceMatrixFormat()

bpp::PhylipDistanceMatrixFormat::PhylipDistanceMatrixFormat ( bool  extended = false)
inline

Definition at line 28 of file PhylipDistanceMatrixFormat.h.

◆ ~PhylipDistanceMatrixFormat()

virtual bpp::PhylipDistanceMatrixFormat::~PhylipDistanceMatrixFormat ( )
inlinevirtual

Definition at line 29 of file PhylipDistanceMatrixFormat.h.

Member Function Documentation

◆ getDataType()

virtual const std::string bpp::IODistanceMatrix::getDataType ( ) const
inlinevirtualinherited

Implements bpp::IOFormat.

Definition at line 28 of file IoDistanceMatrix.h.

◆ getFormatDescription()

const std::string bpp::PhylipDistanceMatrixFormat::getFormatDescription ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 34 of file PhylipDistanceMatrixFormat.h.

◆ getFormatName()

const std::string bpp::PhylipDistanceMatrixFormat::getFormatName ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 32 of file PhylipDistanceMatrixFormat.h.

◆ readDistanceMatrix() [1/2]

std::unique_ptr<DistanceMatrix> bpp::PhylipDistanceMatrixFormat::readDistanceMatrix ( const std::string &  path) const
inlinevirtual

Read a distance matrix from a file.

Parameters
pathThe file path.
Returns
A new distance matrix object.
Exceptions
ExceptionIf an error occurred.

Reimplemented from bpp::AbstractIDistanceMatrix.

Definition at line 36 of file PhylipDistanceMatrixFormat.h.

References bpp::AbstractIDistanceMatrix::readDistanceMatrix().

◆ readDistanceMatrix() [2/2]

unique_ptr< DistanceMatrix > PhylipDistanceMatrixFormat::readDistanceMatrix ( std::istream &  in) const
virtual

Read a distance matrix from a stream.

Parameters
inThe input stream.
Returns
A new distance matrix object.
Exceptions
ExceptionIf an error occurred.

Implements bpp::AbstractIDistanceMatrix.

Definition at line 21 of file PhylipDistanceMatrixFormat.cpp.

References bpp::FileTools::getNextLine(), bpp::StringTokenizer::hasMoreToken(), and bpp::StringTokenizer::nextToken().

◆ writeDistanceMatrix() [1/2]

void bpp::PhylipDistanceMatrixFormat::writeDistanceMatrix ( const DistanceMatrix dist,
const std::string &  path,
bool  overwrite = true 
) const
inlinevirtual

Write a distance matrix to a file.

Parameters
distA distance matrix object.
pathThe file path.
overwriteTell if existing file must be overwritten. Otherwise append to the file.
Exceptions
ExceptionIf an error occurred.

Reimplemented from bpp::AbstractODistanceMatrix.

Definition at line 43 of file PhylipDistanceMatrixFormat.h.

References bpp::AbstractODistanceMatrix::writeDistanceMatrix().

◆ writeDistanceMatrix() [2/2]

void PhylipDistanceMatrixFormat::writeDistanceMatrix ( const DistanceMatrix dist,
std::ostream &  out 
) const
virtual

Write a distance matrix to a stream.

Parameters
distA distance matrix object.
outThe output stream.
Exceptions
ExceptionIf an error occurred.

Implements bpp::AbstractODistanceMatrix.

Definition at line 64 of file PhylipDistanceMatrixFormat.cpp.

References bpp::DistanceMatrix::getName(), bpp::TextTools::resizeRight(), and bpp::DistanceMatrix::size().

Member Data Documentation

◆ extended_

bool bpp::PhylipDistanceMatrixFormat::extended_
private

Definition at line 25 of file PhylipDistanceMatrixFormat.h.


The documentation for this class was generated from the following files: