bpp-seq3
3.0.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, const std::string &split=" ") | |
Build a new Phylip file reader. More... | |
virtual | ~Phylip () |
unsigned int | getNumberOfSequences (const std::string &path) const |
const std::string & | getSplit () const |
void | setSplit (const std::string &split) |
const std::string | getDataType () const |
The AbstractIAlignment2 interface. | |
void | appendAlignmentFromStream (std::istream &input, SequenceContainerInterface &sc) const override |
Append sequences to a container from a stream. More... | |
The AbstractISequence interface. | |
As a SiteContainer is a subclass of SequenceContainer, we hereby implement the ISequence interface by downcasting the interface. | |
virtual std::unique_ptr< SequenceContainerInterface > | readSequences (std::istream &input, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a stream. More... | |
virtual std::unique_ptr< SequenceContainerInterface > | readSequences (const std::string &path, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a file. More... | |
The AbstractOSequence interface. | |
void | writeAlignment (std::ostream &output, const SiteContainerInterface &sc) const override |
Write a container to a stream. More... | |
void | writeAlignment (const std::string &path, const SiteContainerInterface &sc, bool overwrite) const override |
Write a container to a file. More... | |
The IOSequence interface. | |
const std::string | getFormatName () const override |
const std::string | getFormatDescription () const override |
The ISequence interface. | |
As a SiteContainer is a subclass of SequenceContainer, we hereby implement the ISequence interface by downcasting the interface. | |
void | readSequences (std::istream &input, SequenceContainerInterface &sc) const override |
Create a new container from a stream. More... | |
void | readSequences (const std::string &path, SequenceContainerInterface &sc) const override |
Create a new container from a file. More... | |
IAlignment methods: | |
virtual void | readAlignment (std::istream &input, SequenceContainerInterface &sc) const override |
Add sequences to a container from a stream. More... | |
virtual void | readAlignment (const std::string &path, SequenceContainerInterface &sc) const override |
Add sequences to a container from a file. More... | |
std::unique_ptr< SiteContainerInterface > | readAlignment (const std::string &path, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a file. More... | |
std::unique_ptr< SiteContainerInterface > | readAlignment (std::istream &input, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a stream. More... | |
Protected Member Functions | |
const std::vector< std::string > | splitNameAndSequence (const std::string &s) const |
void | readSequential (std::istream &in, SequenceContainerInterface &asc) const |
void | readInterleaved (std::istream &in, SequenceContainerInterface &asc) const |
std::vector< std::string > | getSizedNames (const std::vector< std::string > &names) const |
void | writeSequential (std::ostream &out, const SiteContainerInterface &sc) const |
void | writeInterleaved (std::ostream &out, const SiteContainerInterface &sc) const |
virtual void | appendAlignmentFromFile (const std::string &path, SequenceContainerInterface &sc) const |
Append sequences to a container from a file. More... | |
virtual std::unique_ptr< SiteContainerInterface > | readAlignmentFromStream (std::istream &input, std::shared_ptr< const Alphabet > alpha) const |
Read sequences from a stream. More... | |
virtual std::unique_ptr< SiteContainerInterface > | readAlignmentFromFile (const std::string &path, std::shared_ptr< const Alphabet > alpha) const |
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... | |
std::string | namesSplit_ |
The Phylip & co format.
Sequences must be aligned. 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. |
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). |
Definition at line 58 of file Phylip.h.
References split().
|
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 93 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment::readAlignment(), bpp::AbstractIAlignment::readAlignmentFromFile(), and bpp::AbstractIAlignment2::readSequences().
|
overridevirtual |
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 145 of file Phylip.cpp.
|
inlinevirtualinherited |
|
overridevirtual |
Implements bpp::IOFormat.
Definition at line 290 of file Phylip.cpp.
|
overridevirtual |
Implements bpp::IOFormat.
Definition at line 286 of file Phylip.cpp.
unsigned int Phylip::getNumberOfSequences | ( | const std::string & | path | ) | const |
This methods parses the first line of the phylip file.
path | The path of the file to parse. |
Definition at line 161 of file Phylip.cpp.
References bpp::FileTools::getNextLine(), and bpp::StringTokenizer::nextToken().
|
protected |
Definition at line 180 of file Phylip.cpp.
References bpp::TextTools::resizeRight().
|
inline |
Definition at line 123 of file Phylip.h.
References namesSplit_.
|
inlineoverridevirtualinherited |
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. |
Implements bpp::IAlignment.
Definition at line 57 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
|
inlineoverridevirtualinherited |
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 62 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignmentFromFile().
|
inlineoverridevirtualinherited |
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. |
Implements bpp::IAlignment.
Definition at line 45 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment2::readSequences(), bpp::Clustal::readSequences(), bpp::DCSE::readSequences(), and readSequences().
|
inlineoverridevirtualinherited |
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 67 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 125 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 110 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment::readAlignment().
|
protected |
Definition at line 101 of file Phylip.cpp.
References bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::addSequence(), bpp::TemplateSequenceDataInterface< HashType >::getAlphabet(), bpp::FileTools::getNextLine(), bpp::TextTools::isEmpty(), bpp::StringTokenizer::nextToken(), and bpp::TextTools::removeWhiteSpaces().
|
inlineoverridevirtualinherited |
Create a new container from a file.
path | The path to the file to read. |
container | The container where to add data. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Definition at line 162 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
|
inlineoverridevirtual |
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. |
Reimplemented from bpp::AbstractIAlignment2.
Definition at line 84 of file Phylip.h.
References bpp::AbstractIAlignment::readAlignment().
|
inlineoverridevirtualinherited |
Create a new container from a stream.
input | The input stream to read. |
container | The container where to add data. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Definition at line 157 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
|
inlineoverridevirtual |
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. |
Reimplemented from bpp::AbstractIAlignment2.
Definition at line 80 of file Phylip.h.
References bpp::AbstractIAlignment::readAlignment().
|
protected |
Definition at line 42 of file Phylip.cpp.
References bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::addSequence(), bpp::TemplateSequenceDataInterface< HashType >::getAlphabet(), bpp::FileTools::getNextLine(), bpp::TextTools::isEmpty(), bpp::TextTools::removeSurroundingWhiteSpaces(), and bpp::TextTools::removeWhiteSpaces().
|
inline |
split | The string to be used to split sequence name from content. |
Definition at line 128 of file Phylip.h.
References namesSplit_, and split().
|
protected |
Definition at line 21 of file Phylip.cpp.
References bpp::TextTools::removeFirstWhiteSpaces(), and bpp::TextTools::removeSurroundingWhiteSpaces().
|
inlineoverridevirtual |
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 104 of file Phylip.h.
References bpp::AbstractOAlignment::writeAlignment().
|
overridevirtual |
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 266 of file Phylip.cpp.
References bpp::TemplateSequenceDataInterface< HashType >::getNumberOfSequences().
|
protected |
Definition at line 233 of file Phylip.cpp.
References bpp::TemplateSequenceDataInterface< HashType >::getAlphabet(), bpp::TemplateSequenceDataInterface< HashType >::getNumberOfSequences(), bpp::TemplateSequenceDataInterface< HashType >::getSequenceNames(), bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::sequence(), and bpp::TextTools::split().
|
protected |
Definition at line 213 of file Phylip.cpp.
References bpp::TemplateSequenceDataInterface< HashType >::getAlphabet(), bpp::TemplateSequenceDataInterface< HashType >::getNumberOfSequences(), bpp::TemplateSequenceDataInterface< HashType >::getSequenceNames(), bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::sequence(), and bpp::TextTools::split().
|
private |
|
private |
Definition at line 47 of file Phylip.h.
Referenced by getSplit(), and setSplit().