bpp-popgen
3.0.0
|
The native I/O format for popgenlib. More...
#include <Bpp/PopGen/DataSet/Io/PopgenlibIO.h>
Public Member Functions | |
PopgenlibIO () | |
PopgenlibIO (const std::string &missing_data_symbol, const std::string &data_separator) | |
~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) |
Set the code for missing data. More... | |
void | setDataSeparator (const std::string &data_separator) |
Set the code for data separator. More... | |
The IDataSet interface. | |
void | read (std::istream &is, DataSet &data_set) |
Read a DataSet on istream. More... | |
void | read (const std::string &path, DataSet &data_set) |
Read a DataSet from a text file. More... | |
DataSet * | read (std::istream &is) |
Read istream and return a DataSet. More... | |
DataSet * | read (const std::string &path) |
Read a text file and return a DataSet. More... | |
The ODataSet interface. | |
void | write (std::ostream &os, const DataSet &data_set) const |
Write a DataSet on ostream. More... | |
void | write (const std::string &path, const DataSet &data_set, bool overwrite) const |
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) |
The IOFormat interface. | |
const std::string | getDataType () const |
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 | ||
) |
Definition at line 58 of file PopgenlibIO.cpp.
References setDataSeparator(), and setMissingDataSymbol().
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, bpp::TextTools::toString(), and WHITESPACE.
Referenced by write().
char PopgenlibIO::getDataSeparatorChar | ( | ) | const |
Get the data separator char.
Definition at line 129 of file PopgenlibIO.cpp.
References data_separator_.
Referenced by getValues_(), and write().
|
inlineprivatevirtualinherited |
Implements bpp::IOFormat.
Definition at line 67 of file IODataSet.h.
|
inlinevirtual |
Implements bpp::IOFormat.
Definition at line 178 of file PopgenlibIO.h.
|
inlinevirtual |
Implements bpp::IOFormat.
Definition at line 174 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_.
Referenced by write().
std::string PopgenlibIO::getMissingDataSymbol | ( | ) | const |
Get the code for missing data.
Definition at line 107 of file PopgenlibIO.cpp.
References missing_data_symbol_, and bpp::TextTools::toString().
Referenced by parseIndividual_(), setDataSeparator(), and write().
|
private |
Definition at line 694 of file PopgenlibIO.cpp.
References getDataSeparatorChar(), and bpp::TextTools::removeSurroundingWhiteSpaces().
Referenced by parseGeneral_(), parseIndividual_(), parseLocality_(), and parseLoci_().
|
private |
Definition at line 295 of file PopgenlibIO.cpp.
References bpp::FileTools::getNextLine(), getValues_(), bpp::DataSet::setAlphabet(), setDataSeparator(), and setMissingDataSymbol().
Referenced by read().
|
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(), bpp::VectorSequenceContainer::getSequence(), getValues_(), bpp::Individual::initGenotype(), bpp::TextTools::removeSurroundingWhiteSpaces(), bpp::Individual::setCoord(), bpp::Individual::setDate(), bpp::Individual::setId(), bpp::Individual::setLocality(), bpp::Individual::setMonolocusGenotypeByAlleleId(), bpp::TextTools::toDouble(), and bpp::TextTools::toInt().
Referenced by read().
|
private |
Definition at line 315 of file PopgenlibIO.cpp.
References bpp::DataSet::addLocality(), bpp::Locality< T >::getName(), bpp::FileTools::getNextLine(), getValues_(), bpp::TextTools::removeSurroundingWhiteSpaces(), bpp::Locality< T >::setName(), bpp::Point2D< class >::setX(), bpp::Point2D< class >::setY(), and bpp::TextTools::toDouble().
Referenced by read().
|
private |
Definition at line 354 of file PopgenlibIO.cpp.
References DIPLOID, bpp::LocusInfo::DIPLOID, bpp::FileTools::getNextLine(), getValues_(), HAPLODIPLOID, bpp::LocusInfo::HAPLODIPLOID, HAPLOID, bpp::LocusInfo::HAPLOID, bpp::TextTools::removeSurroundingWhiteSpaces(), bpp::TextTools::toUpper(), UNKNOWN, and bpp::LocusInfo::UNKNOWN.
Referenced by read().
|
private |
Definition at line 343 of file PopgenlibIO.cpp.
References bpp::Fasta::readSequences().
Referenced by 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().
|
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 DataSet on istream.
Implements bpp::AbstractIDataSet.
Definition at line 134 of file PopgenlibIO.cpp.
References bpp::DataSet::getAlphabet(), bpp::FileTools::getNextLine(), bpp::DataSet::hasSequenceData(), parseGeneral_(), parseIndividual_(), parseLocality_(), parseLoci_(), parseSequence_(), bpp::DataSet::setAnalyzedLoci(), and bpp::AnalyzedLoci::setLocusInfo().
void PopgenlibIO::setDataSeparator | ( | const std::string & | data_separator | ) |
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.
References COMA, data_separator_, getMissingDataSymbol(), SEMICOLON, TAB, and WHITESPACE.
Referenced by parseGeneral_(), and PopgenlibIO().
void PopgenlibIO::setMissingDataSymbol | ( | const std::string & | missing_data_symbol | ) |
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.
References data_separator_, bpp::TextTools::isWhiteSpaceCharacter(), and missing_data_symbol_.
Referenced by parseGeneral_(), and PopgenlibIO().
|
virtual |
Write a DataSet in a text file.
Reimplemented from bpp::AbstractODataSet.
Definition at line 689 of file PopgenlibIO.cpp.
References bpp::AbstractODataSet::write().
|
virtual |
Write a DataSet on ostream.
Implements bpp::AbstractODataSet.
Definition at line 545 of file PopgenlibIO.cpp.
References DIPLOID, bpp::LocusInfo::DIPLOID, bpp::MonolocusGenotype::getAlleleIndex(), bpp::LocusInfo::getAlleleInfoByKey(), bpp::DataSet::getAlphabetType(), getDataSeparator(), getDataSeparatorChar(), bpp::Individual::getDate(), bpp::Date::getDateStr(), bpp::Individual::getGenotype(), bpp::DataSet::getGroupAtPosition(), bpp::Individual::getId(), bpp::AlleleInfo::getId(), bpp::DataSet::getIndividualAtPositionFromGroup(), bpp::Individual::getLocality(), bpp::DataSet::getLocalityAtPosition(), bpp::DataSet::getLocusInfoAtPosition(), getMissingDataChar(), getMissingDataSymbol(), bpp::MultilocusGenotype::getMonolocusGenotype(), bpp::Locality< T >::getName(), bpp::LocusInfo::getName(), bpp::LocusInfo::getNumberOfAlleles(), bpp::DataSet::getNumberOfGroups(), bpp::DataSet::getNumberOfIndividualsInGroup(), bpp::DataSet::getNumberOfLocalities(), bpp::DataSet::getNumberOfLoci(), bpp::Individual::getNumberOfSequences(), bpp::LocusInfo::getPloidy(), bpp::Individual::getSequenceAtPosition(), bpp::Individual::getSequences(), bpp::Individual::getX(), bpp::Individual::getY(), HAPLODIPLOID, bpp::LocusInfo::HAPLODIPLOID, HAPLOID, bpp::LocusInfo::HAPLOID, bpp::DataSet::hasAlleleicData(), bpp::Individual::hasCoord(), bpp::Individual::hasDate(), bpp::Individual::hasGenotype(), bpp::DataSet::hasLocality(), bpp::Individual::hasLocality(), bpp::DataSet::hasSequenceData(), bpp::Individual::hasSequences(), bpp::MultilocusGenotype::isMonolocusGenotypeMissing(), bpp::MultilocusGenotype::size(), bpp::TextTools::toString(), UNKNOWN, bpp::LocusInfo::UNKNOWN, and bpp::Fasta::writeSequences().
|
static |
Definition at line 71 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().
|
private |
Definition at line 80 of file PopgenlibIO.h.
Referenced by getDataSeparator(), getDataSeparatorChar(), setDataSeparator(), and setMissingDataSymbol().
|
static |
Definition at line 74 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
static |
Definition at line 76 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
static |
Definition at line 75 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
private |
Definition at line 81 of file PopgenlibIO.h.
Referenced by getMissingDataChar(), getMissingDataSymbol(), and setMissingDataSymbol().
|
static |
Definition at line 72 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().
|
static |
Definition at line 70 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().
|
static |
Definition at line 77 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
static |
Definition at line 69 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().