bpp-popgen  3.0.0
bpp::PopgenlibIO Class Reference

The native I/O format for popgenlib. More...

#include <Bpp/PopGen/DataSet/Io/PopgenlibIO.h>

+ Inheritance diagram for bpp::PopgenlibIO:
+ Collaboration diagram for bpp::PopgenlibIO:

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...
 
DataSetread (std::istream &is)
 Read istream and return a DataSet. More...
 
DataSetread (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 &param_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_
 

Detailed Description

The native I/O format for popgenlib.

Author
Sylvain Gaillard

Definition at line 63 of file PopgenlibIO.h.

Constructor & Destructor Documentation

◆ PopgenlibIO() [1/2]

PopgenlibIO::PopgenlibIO ( )

Definition at line 55 of file PopgenlibIO.cpp.

◆ PopgenlibIO() [2/2]

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::~PopgenlibIO ( )

Definition at line 74 of file PopgenlibIO.cpp.

Member Function Documentation

◆ getDataSeparator()

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().

◆ getDataSeparatorChar()

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().

◆ getDataType()

const std::string bpp::IODataSet::getDataType ( ) const
inlineprivatevirtualinherited

Implements bpp::IOFormat.

Definition at line 67 of file IODataSet.h.

◆ getFormatDescription()

const std::string bpp::PopgenlibIO::getFormatDescription ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 178 of file PopgenlibIO.h.

◆ getFormatName()

const std::string bpp::PopgenlibIO::getFormatName ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 174 of file PopgenlibIO.h.

◆ getMissingDataChar()

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().

◆ getMissingDataSymbol()

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().

◆ getValues_()

std::vector< std::string > PopgenlibIO::getValues_ ( std::string &  param_line,
const std::string &  delim 
)
private

◆ parseGeneral_()

void PopgenlibIO::parseGeneral_ ( const std::vector< std::string > &  in,
DataSet data_set 
)
private

◆ parseIndividual_()

◆ parseLocality_()

◆ parseLoci_()

void PopgenlibIO::parseLoci_ ( const std::vector< std::string > &  in,
std::vector< LocusInfo > &  locus_info 
)
private

◆ parseSequence_()

void PopgenlibIO::parseSequence_ ( const std::vector< std::string > &  in,
VectorSequenceContainer vsc 
)
private

Definition at line 343 of file PopgenlibIO.cpp.

References bpp::Fasta::readSequences().

Referenced by read().

◆ read() [1/4]

DataSet * PopgenlibIO::read ( const std::string &  path)
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().

◆ read() [2/4]

void PopgenlibIO::read ( const std::string &  path,
DataSet data_set 
)
virtual

Read a DataSet from a text file.

Reimplemented from bpp::AbstractIDataSet.

Definition at line 530 of file PopgenlibIO.cpp.

References bpp::AbstractIDataSet::read().

◆ read() [3/4]

DataSet * PopgenlibIO::read ( std::istream &  is)
virtual

Read istream and return a DataSet.

Reimplemented from bpp::AbstractIDataSet.

Definition at line 535 of file PopgenlibIO.cpp.

References bpp::AbstractIDataSet::read().

◆ read() [4/4]

◆ setDataSeparator()

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 white space: "WHITESPACE"
  • the tabulation: "TAB"
  • the coma: "COMA"
  • the semicolon: "SEMICOLON"

The default value is "WHITESPACE".

Exceptions
Exceptionif data_separator is a not allowed character.
Exceptionif 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().

◆ setMissingDataSymbol()

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 '$'.

Exceptions
Excpetionif missing_data_symbol is a not allowed character.
Exceptionif 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().

◆ write() [1/2]

void PopgenlibIO::write ( const std::string &  path,
const DataSet data_set,
bool  overwrite 
) const
virtual

Write a DataSet in a text file.

Reimplemented from bpp::AbstractODataSet.

Definition at line 689 of file PopgenlibIO.cpp.

References bpp::AbstractODataSet::write().

◆ write() [2/2]

void PopgenlibIO::write ( std::ostream &  os,
const DataSet data_set 
) const
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().

Member Data Documentation

◆ COMA

const string PopgenlibIO::COMA = string("COMA")
static

Definition at line 71 of file PopgenlibIO.h.

Referenced by getDataSeparator(), and setDataSeparator().

◆ data_separator_

char bpp::PopgenlibIO::data_separator_
private

◆ DIPLOID

const string PopgenlibIO::DIPLOID = string("DIPLOID")
static

Definition at line 74 of file PopgenlibIO.h.

Referenced by parseLoci_(), and write().

◆ HAPLODIPLOID

const string PopgenlibIO::HAPLODIPLOID = string("HAPLODIPLOID")
static

Definition at line 76 of file PopgenlibIO.h.

Referenced by parseLoci_(), and write().

◆ HAPLOID

const string PopgenlibIO::HAPLOID = string("HAPLOID")
static

Definition at line 75 of file PopgenlibIO.h.

Referenced by parseLoci_(), and write().

◆ missing_data_symbol_

char bpp::PopgenlibIO::missing_data_symbol_
private

Definition at line 81 of file PopgenlibIO.h.

Referenced by getMissingDataChar(), getMissingDataSymbol(), and setMissingDataSymbol().

◆ SEMICOLON

const string PopgenlibIO::SEMICOLON = string("SEMICOLON")
static

Definition at line 72 of file PopgenlibIO.h.

Referenced by getDataSeparator(), and setDataSeparator().

◆ TAB

const string PopgenlibIO::TAB = string("TAB")
static

Definition at line 70 of file PopgenlibIO.h.

Referenced by getDataSeparator(), and setDataSeparator().

◆ UNKNOWN

const string PopgenlibIO::UNKNOWN = string("UNKNOWN")
static

Definition at line 77 of file PopgenlibIO.h.

Referenced by parseLoci_(), and write().

◆ WHITESPACE

const string PopgenlibIO::WHITESPACE = string("WHITESPACE")
static

Definition at line 69 of file PopgenlibIO.h.

Referenced by getDataSeparator(), and setDataSeparator().


The documentation for this class was generated from the following files: