bpp-seq
2.2.0
|
The Phylip & co format. More...
#include <Bpp/Seq/Io/Phylip.h>
Public Member Functions | |
Phylip (bool extended=true, bool sequential=true, unsigned int charsByLine=100, bool checkSequenceNames=true, const std::string &split=" ") | |
Build a new Phylip file reader. More... | |
virtual | ~Phylip () |
unsigned int | getNumberOfSequences (const std::string &path) const throw (IOException) |
bool | checkNames () const |
void | checkNames (bool yn) |
Tell whether the sequence names should be checked when reading from files. More... | |
const std::string & | getSplit () const |
void | setSplit (const std::string &split) |
const std::string | getDataType () const |
The AbstractIAlignment interface. | |
void | appendAlignmentFromStream (std::istream &input, SiteContainer &sc) const throw (Exception) |
Append sequences to a container from a stream. More... | |
The ISequence interface. | |
As a SiteContainer is a subclass of SequenceContainer, we hereby implement the ISequence interface by downcasting the interface. | |
virtual SequenceContainer * | readSequences (std::istream &input, const Alphabet *alpha) const throw (Exception) |
Create a new container from a stream. More... | |
virtual SequenceContainer * | readSequences (const std::string &path, const Alphabet *alpha) const throw (Exception) |
Create a new container from a file. More... | |
The OSequence interface. | |
void | writeAlignment (std::ostream &output, const SiteContainer &sc) const throw (Exception) |
Write a container to a stream. More... | |
void | writeAlignment (const std::string &path, const SiteContainer &sc, bool overwrite) const throw (Exception) |
Write a container to a file. More... | |
The IOSequence interface. | |
const std::string | getFormatName () const |
const std::string | getFormatDescription () const |
IAlignment methods: | |
virtual void | readAlignment (std::istream &input, SiteContainer &sc) const throw (Exception) |
Add sequences to a container from a stream. More... | |
virtual void | readAlignment (const std::string &path, SiteContainer &sc) const throw (Exception) |
Add sequences to a container from a file. More... | |
virtual AlignedSequenceContainer * | readAlignment (const std::string &path, const Alphabet *alpha) const throw (Exception) |
Create a new container from a file. More... | |
virtual AlignedSequenceContainer * | readAlignment (std::istream &input, const Alphabet *alpha) const throw (Exception) |
Create a new container from a stream. More... | |
Protected Member Functions | |
const std::vector< std::string > | splitNameAndSequence (const std::string &s) const throw (Exception) |
void | readSequential (std::istream &in, SiteContainer &asc) const throw (Exception) |
void | readInterleaved (std::istream &in, SiteContainer &asc) const throw (Exception) |
std::vector< std::string > | getSizedNames (const std::vector< std::string > &names) const |
void | writeSequential (std::ostream &out, const SequenceContainer &sc) const |
void | writeInterleaved (std::ostream &out, const SequenceContainer &sc) const |
virtual void | appendAlignmentFromFile (const std::string &path, SiteContainer &sc) const throw (Exception) |
Append sequences to a container from a file. More... | |
virtual AlignedSequenceContainer * | readAlignmentFromStream (std::istream &input, const Alphabet *alpha) const throw (Exception) |
Read sequences from a stream. More... | |
virtual AlignedSequenceContainer * | readAlignmentFromFile (const std::string &path, const Alphabet *alpha) const throw (Exception) |
Read sequences from a file. More... | |
Private Attributes | |
bool | extended_ |
bool | sequential_ |
unsigned int | charsByLine_ |
The maximum number of chars to be written on a line. More... | |
bool | checkNames_ |
std::string | namesSplit_ |
The Phylip & co format.
An AlignedSequenceContainer is used instead of a VectorSequenceContainer.
This format is described on the Phylip package documentation website: http://evolution.genetics.washington.edu/phylip/doc/sequence.html
|
inline |
Build a new Phylip file reader.
extended | If true, sequences with names longer than 10 characters are allowed. |
sequential | If false, sequences are supposed to be interlaved. |
charsByLine | The number of base to display in a row. |
checkSequenceNames | Tell if the names in the file should be checked for unicity (slower, in o(n*n) where n is the number of sequences). |
split | The string to use to split sequence name from content (only for 'extended' format). This will typically be " " (two spaces) or "\t" (a tabulation). |
|
inlineprotectedvirtualinherited |
Append sequences to a container from a file.
path | The path to the file to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Definition at line 143 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment::readAlignment(), and bpp::AbstractIAlignment::readAlignmentFromFile().
|
virtual |
Append sequences to a container from a stream.
This is the unique method to implement!
input | The input stream to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Implements bpp::AbstractIAlignment.
Definition at line 174 of file Phylip.cpp.
|
inline |
Definition at line 163 of file Phylip.h.
References checkNames_.
|
inline |
Tell whether the sequence names should be checked when reading from files.
yn | whether the sequence names should be checked when reading from files. |
Definition at line 170 of file Phylip.h.
References checkNames_.
|
inlineinherited |
Definition at line 65 of file IoSequence.h.
const std::string Phylip::getFormatDescription | ( | ) | const |
Definition at line 298 of file Phylip.cpp.
const std::string Phylip::getFormatName | ( | ) | const |
Definition at line 294 of file Phylip.cpp.
unsigned int Phylip::getNumberOfSequences | ( | const std::string & | path | ) | const |
throw | ( | IOException | |||
) |
This methods parses the firt line of the phylip file.
path | The path of the file to parse. |
Definition at line 185 of file Phylip.cpp.
|
protected |
Definition at line 201 of file Phylip.cpp.
|
inline |
Definition at line 175 of file Phylip.h.
References namesSplit_.
|
inlinevirtualinherited |
Add sequences to a container from a stream.
input | The input stream to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Definition at line 81 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::DCSE::readSequences(), bpp::Clustal::readSequences(), bpp::NexusIOSequence::readSequences(), and readSequences().
|
inlinevirtualinherited |
Add sequences to a container from a file.
path | The path to the file to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Definition at line 93 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
|
inlinevirtualinherited |
Create a new container from a file.
path | The path to the file to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::IAlignment.
Definition at line 104 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignmentFromFile().
|
inlinevirtualinherited |
Create a new container from a stream.
input | The input stream to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::IAlignment.
Definition at line 115 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignmentFromStream().
|
inlineprotectedvirtualinherited |
Read sequences from a file.
path | The path to the file to read. |
alpha | The alphabet to use. |
Exception | If the file is not in the specified format. |
Definition at line 173 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
Referenced by bpp::AbstractIAlignment::readAlignment().
|
inlineprotectedvirtualinherited |
Read sequences from a stream.
input | The input stream to read. |
alpha | The alphabet to use. |
Exception | If the file is not in the specified format. |
Definition at line 158 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment::readAlignment().
|
protected |
Definition at line 132 of file Phylip.cpp.
|
inlinevirtual |
Create a new container from a stream.
input | The input stream to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Definition at line 122 of file Phylip.h.
References bpp::AbstractIAlignment::readAlignment().
|
inlinevirtual |
Create a new container from a file.
path | The path to the file to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Definition at line 125 of file Phylip.h.
References bpp::AbstractIAlignment::readAlignment().
|
protected |
Definition at line 75 of file Phylip.cpp.
|
inline |
split | The string to be used to split sequence name from content. |
Definition at line 180 of file Phylip.h.
References namesSplit_.
|
protected |
Definition at line 55 of file Phylip.cpp.
|
virtual |
Write a container to a stream.
output | The output stream where to write. |
sc | The container to write. |
Exception | If the file is not in the specified format. |
Implements bpp::AbstractOAlignment.
Definition at line 279 of file Phylip.cpp.
|
inlinevirtual |
Write a container to a file.
path | The path to the file to write. |
sc | The container to write. |
overwrite | If true the sequences are written at the beginning of the file instead of being appended. Any previous content will be lost. |
Exception | If the file is not in the specified format. |
Reimplemented from bpp::AbstractOAlignment.
Definition at line 144 of file Phylip.h.
References bpp::AbstractOAlignment::writeAlignment().
|
protected |
Definition at line 246 of file Phylip.cpp.
References bpp::SequenceContainer::getAlphabet(), bpp::SequenceContainer::getNumberOfSequences(), bpp::SequenceContainer::getSequence(), bpp::SequenceContainer::getSequencesNames(), bpp::Alphabet::getStateCodingSize(), and bpp::SequenceContainer::toString().
|
protected |
Definition at line 226 of file Phylip.cpp.
References bpp::SequenceContainer::getAlphabet(), bpp::SequenceContainer::getNumberOfSequences(), bpp::SequenceContainer::getSequence(), bpp::SequenceContainer::getSequencesNames(), bpp::Alphabet::getStateCodingSize(), and bpp::SequenceContainer::toString().
|
private |
|
private |
Definition at line 85 of file Phylip.h.
Referenced by checkNames().
|
private |
Definition at line 87 of file Phylip.h.
Referenced by getSplit(), and setSplit().