bpp-popgen3
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 28 of file PopgenlibIO.h.
PopgenlibIO::PopgenlibIO | ( | ) |
Definition at line 20 of file PopgenlibIO.cpp.
PopgenlibIO::PopgenlibIO | ( | const std::string & | missing_data_symbol, |
const std::string & | data_separator | ||
) |
Definition at line 23 of file PopgenlibIO.cpp.
References setDataSeparator(), and setMissingDataSymbol().
PopgenlibIO::~PopgenlibIO | ( | ) |
Definition at line 39 of file PopgenlibIO.cpp.
std::string PopgenlibIO::getDataSeparator | ( | ) | const |
Get the code for data separator.
Definition at line 77 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 94 of file PopgenlibIO.cpp.
References data_separator_.
Referenced by getValues_(), and write().
|
inlineprivatevirtualinherited |
Implements bpp::IOFormat.
Definition at line 33 of file IODataSet.h.
|
inlinevirtual |
Implements bpp::IOFormat.
Definition at line 143 of file PopgenlibIO.h.
|
inlinevirtual |
Implements bpp::IOFormat.
Definition at line 139 of file PopgenlibIO.h.
char PopgenlibIO::getMissingDataChar | ( | ) | const |
Get the character for missing data.
Definition at line 89 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 72 of file PopgenlibIO.cpp.
References missing_data_symbol_, and bpp::TextTools::toString().
Referenced by parseIndividual_(), setDataSeparator(), and write().
|
private |
Definition at line 662 of file PopgenlibIO.cpp.
References getDataSeparatorChar(), and bpp::TextTools::removeSurroundingWhiteSpaces().
Referenced by parseGeneral_(), parseIndividual_(), parseLocality_(), and parseLoci_().
|
private |
Definition at line 260 of file PopgenlibIO.cpp.
References bpp::FileTools::getNextLine(), getValues_(), bpp::DataSet::setAlphabet(), setDataSeparator(), and setMissingDataSymbol().
Referenced by read().
|
private |
Definition at line 360 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::TextTools::removeSurroundingWhiteSpaces(), bpp::TemplateVectorSequenceContainer< class >::sequence(), 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 280 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 319 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 308 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 508 of file PopgenlibIO.cpp.
References bpp::AbstractIDataSet::read().
|
virtual |
Read a DataSet from a text file.
Reimplemented from bpp::AbstractIDataSet.
Definition at line 498 of file PopgenlibIO.cpp.
References bpp::AbstractIDataSet::read().
|
virtual |
Read istream and return a DataSet.
Reimplemented from bpp::AbstractIDataSet.
Definition at line 503 of file PopgenlibIO.cpp.
References bpp::AbstractIDataSet::read().
|
virtual |
Read a DataSet on istream.
Implements bpp::AbstractIDataSet.
Definition at line 99 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 contains more than one character other than the two codes defined upper. |
Definition at line 52 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 '$'.
Exception | if missing_data_symbol is a not allowed character. |
Exception | if missing_data_symbol contains more than one character. |
Definition at line 41 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 657 of file PopgenlibIO.cpp.
References bpp::AbstractODataSet::write().
|
virtual |
Write a DataSet on ostream.
Implements bpp::AbstractODataSet.
Definition at line 513 of file PopgenlibIO.cpp.
References DIPLOID, bpp::LocusInfo::DIPLOID, bpp::MonolocusGenotypeInterface::getAlleleIndex(), bpp::LocusInfo::getAlleleInfoByKey(), bpp::DataSet::getAlphabetType(), getDataSeparator(), getDataSeparatorChar(), bpp::DataSet::getGroupAtPosition(), bpp::Individual::getId(), bpp::AlleleInfo::getId(), bpp::DataSet::getIndividualAtPositionFromGroup(), bpp::DataSet::getLocusInfoAtPosition(), getMissingDataChar(), getMissingDataSymbol(), bpp::LocusInfo::getName(), bpp::LocusInfo::getNumberOfAlleles(), bpp::DataSet::getNumberOfGroups(), bpp::DataSet::getNumberOfIndividualsInGroup(), bpp::DataSet::getNumberOfLocalities(), bpp::DataSet::getNumberOfLoci(), bpp::LocusInfo::getPloidy(), HAPLODIPLOID, bpp::LocusInfo::HAPLODIPLOID, HAPLOID, bpp::LocusInfo::HAPLOID, bpp::DataSet::hasAlleleicData(), bpp::DataSet::hasLocality(), bpp::DataSet::hasSequenceData(), bpp::MultilocusGenotype::isMonolocusGenotypeMissing(), bpp::DataSet::localityAtPosition(), bpp::MultilocusGenotype::monolocusGenotype(), bpp::Individual::sequences(), bpp::MultilocusGenotype::size(), bpp::TextTools::toString(), UNKNOWN, bpp::LocusInfo::UNKNOWN, and bpp::Fasta::writeSequences().
|
static |
Definition at line 36 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().
|
private |
Definition at line 45 of file PopgenlibIO.h.
Referenced by getDataSeparator(), getDataSeparatorChar(), setDataSeparator(), and setMissingDataSymbol().
|
static |
Definition at line 39 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
static |
Definition at line 41 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
static |
Definition at line 40 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
private |
Definition at line 46 of file PopgenlibIO.h.
Referenced by getMissingDataChar(), getMissingDataSymbol(), and setMissingDataSymbol().
|
static |
Definition at line 37 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().
|
static |
Definition at line 35 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().
|
static |
Definition at line 42 of file PopgenlibIO.h.
Referenced by parseLoci_(), and write().
|
static |
Definition at line 34 of file PopgenlibIO.h.
Referenced by getDataSeparator(), and setDataSeparator().