bpp-popgen3  3.0.0
PopgenlibIO.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef _POPULIBIO_H_
6 #define _POPULIBIO_H_
7 
8 #include <Bpp/Exceptions.h>
9 #include <Bpp/Text/TextTools.h>
10 #include <Bpp/Io/FileTools.h>
11 
12 // From Seq
13 #include <Bpp/Seq/Io/Fasta.h>
15 
16 // From local Pop
17 #include "AbstractIDataSet.h"
18 #include "AbstractODataSet.h"
19 #include "../../BasicAlleleInfo.h"
20 
21 namespace bpp
22 {
28 class PopgenlibIO :
29  public AbstractIDataSet,
30  public AbstractODataSet
31 {
32 public:
33  // Constantes
34  static const std::string WHITESPACE;
35  static const std::string TAB;
36  static const std::string COMA;
37  static const std::string SEMICOLON;
38 
39  static const std::string DIPLOID;
40  static const std::string HAPLOID;
41  static const std::string HAPLODIPLOID;
42  static const std::string UNKNOWN;
43 
44 private:
47 
48  std::vector<std::string> getValues_(std::string& param_line, const std::string& delim);
49  void parseGeneral_(const std::vector<std::string>& in, DataSet& data_set);
50  void parseLocality_(const std::vector<std::string>& in, DataSet& data_set);
51  void parseSequence_(const std::vector<std::string>& in, VectorSequenceContainer& vsc);
52  void parseLoci_(const std::vector<std::string>& in, std::vector<LocusInfo>& locus_info);
53  void parseIndividual_(const std::vector<std::string>& in, DataSet& data_set, const VectorSequenceContainer& vsc);
54 
55 public:
56  // Constructor and destructor
57  PopgenlibIO();
58  PopgenlibIO(const std::string& missing_data_symbol, const std::string& data_separator);
59  ~PopgenlibIO();
60 
61 public:
65  std::string getMissingDataSymbol() const;
66 
70  std::string getDataSeparator() const;
71 
75  char getMissingDataChar() const;
76 
80  char getDataSeparatorChar() const;
81 
93  void setMissingDataSymbol(const std::string& missing_data_symbol);
94 
110  void setDataSeparator(const std::string& data_separator);
111 
116  void read(std::istream& is, DataSet& data_set);
117  void read(const std::string& path, DataSet& data_set);
118  DataSet* read(std::istream& is);
119  DataSet* read(const std::string& path);
128  void write(std::ostream& os, const DataSet& data_set) const;
129 
130  void write(const std::string& path, const DataSet& data_set, bool overwrite) const;
139  const std::string getFormatName() const
140  {
141  return "PopgenlibIO ver 0.1";
142  }
143  const std::string getFormatDescription() const
144  {
145  return "IO format used to store DataSets inspired from Arlequin and Fasta";
146  }
150 };
151 } // end of namespace bpp;
152 
153 #endif // _POPULIBIO_H_
Partial implementation of the DataSet Input interface.
Partial implementation of the DataSet Output interface.
The DataSet class.
Definition: DataSet.h:37
The native I/O format for popgenlib.
Definition: PopgenlibIO.h:31
static const std::string UNKNOWN
Definition: PopgenlibIO.h:42
void parseIndividual_(const std::vector< std::string > &in, DataSet &data_set, const VectorSequenceContainer &vsc)
static const std::string HAPLODIPLOID
Definition: PopgenlibIO.h:41
void parseLocality_(const std::vector< std::string > &in, DataSet &data_set)
static const std::string COMA
Definition: PopgenlibIO.h:36
void write(std::ostream &os, const DataSet &data_set) const
Write a DataSet on ostream.
char missing_data_symbol_
Definition: PopgenlibIO.h:46
static const std::string TAB
Definition: PopgenlibIO.h:35
const std::string getFormatDescription() const
Definition: PopgenlibIO.h:143
static const std::string SEMICOLON
Definition: PopgenlibIO.h:37
void read(std::istream &is, DataSet &data_set)
Read a DataSet on istream.
Definition: PopgenlibIO.cpp:99
std::string getDataSeparator() const
Get the code for data separator.
Definition: PopgenlibIO.cpp:77
static const std::string DIPLOID
Definition: PopgenlibIO.h:39
std::string getMissingDataSymbol() const
Get the code for missing data.
Definition: PopgenlibIO.cpp:72
static const std::string WHITESPACE
Definition: PopgenlibIO.h:34
std::vector< std::string > getValues_(std::string &param_line, const std::string &delim)
char getMissingDataChar() const
Get the character for missing data.
Definition: PopgenlibIO.cpp:89
const std::string getFormatName() const
Definition: PopgenlibIO.h:139
void parseLoci_(const std::vector< std::string > &in, std::vector< LocusInfo > &locus_info)
void setDataSeparator(const std::string &data_separator)
Set the code for data separator.
Definition: PopgenlibIO.cpp:52
static const std::string HAPLOID
Definition: PopgenlibIO.h:40
void parseGeneral_(const std::vector< std::string > &in, DataSet &data_set)
void setMissingDataSymbol(const std::string &missing_data_symbol)
Set the code for missing data.
Definition: PopgenlibIO.cpp:41
void parseSequence_(const std::vector< std::string > &in, VectorSequenceContainer &vsc)
char getDataSeparatorChar() const
Get the data separator char.
Definition: PopgenlibIO.cpp:94