bpp-popgen
2.2.0
|
The native I/O format for popgenlib. More...
#include <Bpp/PopGen/PopgenlibIO.h>
Public Member Functions | |
PopgenlibIO () | |
PopgenlibIO (const std::string &missing_data_symbol, const std::string &data_separator) throw (Exception) | |
~PopgenlibIO () | |
std::string | getMissingDataSymbol () const |
Get the code for missing data. More... | |
std::string | getDataSeparator () const |
Get the code for data separator. More... | |
char | getMissingDataChar () const |
Get the character for missing data. More... | |
char | getDataSeparatorChar () const |
Get the data separator char. More... | |
void | setMissingDataSymbol (const std::string &missing_data_symbol) throw (Exception) |
Set the code for missing data. More... | |
void | setDataSeparator (const std::string &data_separator) throw (Exception) |
Set the code for data separator. More... | |
The IDataSet interface. | |
void | read (std::istream &is, DataSet &data_set) throw (Exception) |
Read a DataSet on istream. More... | |
void | read (const std::string &path, DataSet &data_set) throw (Exception) |
Read a DataSet from a text file. More... | |
DataSet * | read (std::istream &is) throw (Exception) |
Read istream and return a DataSet. More... | |
DataSet * | read (const std::string &path) throw (Exception) |
Read a text file and return a DataSet. More... | |
The ODataSet interface. | |
void | write (std::ostream &os, const DataSet &data_set) const throw (Exception) |
Write a DataSet on ostream. More... | |
void | write (const std::string &path, const DataSet &data_set, bool overwrite) const throw (Exception) |
Write a DataSet in a text file. More... | |
The IOFormat interface | |
const std::string | getFormatName () const |
const std::string | getFormatDescription () const |
Static Public Attributes | |
static const std::string | WHITESPACE = string("WHITESPACE") |
static const std::string | TAB = string("TAB") |
static const std::string | COMA = string("COMA") |
static const std::string | SEMICOLON = string("SEMICOLON") |
static const std::string | DIPLOID = string("DIPLOID") |
static const std::string | HAPLOID = string("HAPLOID") |
static const std::string | HAPLODIPLOID = string("HAPLODIPLOID") |
static const std::string | UNKNOWN = string("UNKNOWN") |
Private Member Functions | |
std::vector< std::string > | getValues_ (std::string ¶m_line, const std::string &delim) |
void | parseGeneral_ (const std::vector< std::string > &in, DataSet &data_set) |
void | parseLocality_ (const std::vector< std::string > &in, DataSet &data_set) |
void | parseSequence_ (const std::vector< std::string > &in, VectorSequenceContainer &vsc) |
void | parseLoci_ (const std::vector< std::string > &in, std::vector< LocusInfo > &locus_info) |
void | parseIndividual_ (const std::vector< std::string > &in, DataSet &data_set, const VectorSequenceContainer &vsc) |
Private Attributes | |
char | data_separator_ |
char | missing_data_symbol_ |
The native I/O format for popgenlib.
Definition at line 63 of file PopgenlibIO.h.
PopgenlibIO::PopgenlibIO | ( | ) |
Definition at line 55 of file PopgenlibIO.cpp.
PopgenlibIO::PopgenlibIO | ( | const std::string & | missing_data_symbol, |
const std::string & | data_separator | ||
) | |||
throw | ( | Exception | |
) |
Definition at line 58 of file PopgenlibIO.cpp.
PopgenlibIO::~PopgenlibIO | ( | ) |
Definition at line 74 of file PopgenlibIO.cpp.
std::string PopgenlibIO::getDataSeparator | ( | ) | const |
Get the code for data separator.
Definition at line 112 of file PopgenlibIO.cpp.
References COMA, data_separator_, SEMICOLON, TAB, and WHITESPACE.
char PopgenlibIO::getDataSeparatorChar | ( | ) | const |
Get the data separator char.
Definition at line 129 of file PopgenlibIO.cpp.
References data_separator_.
Referenced by getValues_().
|
inline |
Definition at line 180 of file PopgenlibIO.h.
|
inline |
Definition at line 176 of file PopgenlibIO.h.
char PopgenlibIO::getMissingDataChar | ( | ) | const |
Get the character for missing data.
Definition at line 124 of file PopgenlibIO.cpp.
References missing_data_symbol_.
std::string PopgenlibIO::getMissingDataSymbol | ( | ) | const |
Get the code for missing data.
Definition at line 107 of file PopgenlibIO.cpp.
References missing_data_symbol_.
Referenced by parseIndividual_().
|
private |
Definition at line 694 of file PopgenlibIO.cpp.
References getDataSeparatorChar().
Referenced by parseGeneral_(), parseIndividual_(), parseLocality_(), and parseLoci_().
|
private |
Definition at line 295 of file PopgenlibIO.cpp.
References getValues_(), bpp::DataSet::setAlphabet(), setDataSeparator(), and setMissingDataSymbol().
|
private |
Definition at line 395 of file PopgenlibIO.cpp.
References bpp::DataSet::addAlleleInfoByLocusPosition(), bpp::DataSet::addEmptyGroup(), bpp::DataSet::addIndividualToGroup(), bpp::Individual::addSequence(), bpp::DataSet::getGroupPosition(), bpp::Individual::getId(), bpp::DataSet::getLocalityByName(), bpp::DataSet::getLocusInfoAtPosition(), getMissingDataSymbol(), bpp::DataSet::getNumberOfLoci(), getValues_(), bpp::Individual::initGenotype(), bpp::Individual::setCoord(), bpp::Individual::setDate(), bpp::Individual::setId(), bpp::Individual::setLocality(), and bpp::Individual::setMonolocusGenotypeByAlleleId().
|
private |
Definition at line 315 of file PopgenlibIO.cpp.
References bpp::DataSet::addLocality(), bpp::Locality< T >::getName(), getValues_(), and bpp::Locality< T >::setName().
|
private |
Definition at line 354 of file PopgenlibIO.cpp.
References bpp::LocusInfo::DIPLOID, DIPLOID, getValues_(), bpp::LocusInfo::HAPLODIPLOID, HAPLODIPLOID, bpp::LocusInfo::HAPLOID, HAPLOID, bpp::LocusInfo::UNKNOWN, and UNKNOWN.
|
private |
Definition at line 343 of file PopgenlibIO.cpp.
|
virtual |
Read a DataSet on istream.
Implements bpp::AbstractIDataSet.
Definition at line 134 of file PopgenlibIO.cpp.
References bpp::AnalyzedLoci::setLocusInfo().
|
virtual |
Read a DataSet from a text file.
Reimplemented from bpp::AbstractIDataSet.
Definition at line 530 of file PopgenlibIO.cpp.
References bpp::AbstractIDataSet::read().
|
virtual |
Read istream and return a DataSet.
Reimplemented from bpp::AbstractIDataSet.
Definition at line 535 of file PopgenlibIO.cpp.
References bpp::AbstractIDataSet::read().
|
virtual |
Read a text file and return a DataSet.
Reimplemented from bpp::AbstractIDataSet.
Definition at line 540 of file PopgenlibIO.cpp.
References bpp::AbstractIDataSet::read().
void PopgenlibIO::setDataSeparator | ( | const std::string & | data_separator | ) | |
throw | ( | Exception | |||
) |
Set the code for data separator.
The character used to separate data can be every single non numerical character and can't be the same used for coding missing data. Most common characters used are:
The default value is "WHITESPACE".
Exception | if data_separator is a not allowed character. |
Exception | if data_separator containes more than one character other than the two codes defined upper. |
Definition at line 87 of file PopgenlibIO.cpp.
Referenced by parseGeneral_().
void PopgenlibIO::setMissingDataSymbol | ( | const std::string & | missing_data_symbol | ) | |
throw | ( | Exception | |||
) |
Set the code for missing data.
The character used to code missing data can be every single non numerical character and can't be the same used as data separator or a white space or a tabulation. The default value is '$'.
Excpetion | if missing_data_symbol is a not allowed character. |
Exception | if missing_data_symbol contains more than one character. |
Definition at line 76 of file PopgenlibIO.cpp.
Referenced by parseGeneral_().
|
virtual |
Write a DataSet on ostream.
Implements bpp::AbstractODataSet.
Definition at line 545 of file PopgenlibIO.cpp.
References bpp::LocusInfo::DIPLOID, bpp::MonolocusGenotype::getAlleleIndex(), bpp::Individual::getDate(), bpp::Date::getDateStr(), bpp::Individual::getGenotype(), bpp::Individual::getId(), bpp::Individual::getLocality(), bpp::MultilocusGenotype::getMonolocusGenotype(), bpp::LocusInfo::getName(), bpp::Locality< T >::getName(), bpp::LocusInfo::getNumberOfAlleles(), bpp::Individual::getNumberOfSequences(), bpp::LocusInfo::getPloidy(), bpp::Individual::getSequenceAtPosition(), bpp::Individual::getX(), bpp::Individual::getY(), bpp::LocusInfo::HAPLODIPLOID, bpp::LocusInfo::HAPLOID, bpp::Individual::hasCoord(), bpp::Individual::hasDate(), bpp::Individual::hasGenotype(), bpp::Individual::hasLocality(), bpp::Individual::hasSequences(), bpp::MultilocusGenotype::isMonolocusGenotypeMissing(), bpp::MultilocusGenotype::size(), and bpp::LocusInfo::UNKNOWN.
|
virtual |
Write a DataSet in a text file.
Reimplemented from bpp::AbstractODataSet.
Definition at line 689 of file PopgenlibIO.cpp.
References bpp::AbstractODataSet::write().
|
static |
Definition at line 71 of file PopgenlibIO.h.
Referenced by getDataSeparator().
|
private |
Definition at line 80 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and getDataSeparatorChar().
|
static |
Definition at line 74 of file PopgenlibIO.h.
Referenced by parseLoci_().
|
static |
Definition at line 76 of file PopgenlibIO.h.
Referenced by parseLoci_().
|
static |
Definition at line 75 of file PopgenlibIO.h.
Referenced by parseLoci_().
|
private |
Definition at line 81 of file PopgenlibIO.h.
Referenced by getMissingDataChar(), and getMissingDataSymbol().
|
static |
Definition at line 72 of file PopgenlibIO.h.
Referenced by getDataSeparator().
|
static |
Definition at line 70 of file PopgenlibIO.h.
Referenced by getDataSeparator().
|
static |
Definition at line 77 of file PopgenlibIO.h.
Referenced by parseLoci_().
|
static |
Definition at line 69 of file PopgenlibIO.h.
Referenced by getDataSeparator().