17 throw IOException(
"Genepop::read: fail to open stream.");
20 ios::pos_type entry_point = is.tellg();
22 bool loc_def_ok =
false;
23 bool loc_nbr_ok =
false;
25 vector<LocusInfo> tmp_loc;
26 vector<set<string>> al_ids;
27 map<string, size_t> ind_id_count;
28 map<string, size_t> ind_id_index;
34 if (is.peek() == EOF && !eof_ok)
37 is.seekg(entry_point);
46 if (cp_temp ==
string(
"POP"))
58 if (loc_def_ok && !loc_nbr_ok)
60 al_ids.resize(tmp_loc.size());
79 string tmp_id = string(ids.begin(), ids.begin() + (ids.size() / 2));
80 if (tmp_id !=
string(
"00") && tmp_id !=
string(
"000"))
81 al_ids[i].insert(tmp_id);
82 tmp_id = string(ids.begin() + (ids.size() / 2), ids.end());
83 if (tmp_id !=
string(
"00") && tmp_id !=
string(
"000"))
84 al_ids[i].insert(tmp_id);
94 for (
size_t i = 0; i < tmp_loc.size(); i++)
97 for (set<string>::iterator it = al_ids[i].begin(); it != al_ids[i].end(); it++)
112 if (cp_temp ==
string(
"POP"))
128 if (ind_id_count[ind_id] > 1)
142 vector<string> tmp_ids;
143 tmp_ids.push_back(
string(ids.begin(), ids.begin() + (ids.size() / 2)));
144 tmp_ids.push_back(
string(ids.begin() + (ids.size() / 2), ids.end()));
145 if (tmp_ids[0] !=
string(
"00") && tmp_ids[0] !=
string(
"000")
146 && tmp_ids[1] !=
string(
"00") && tmp_ids[1] !=
string(
"000"))
virtual void read(std::istream &is, DataSet &data_set)=0
Read a DataSet on istream.
The BasicAlleleInfo class.
void addAlleleInfoByLocusPosition(size_t locus_position, const AlleleInfo &allele)
Add an AlleleInfo to a LocusInfo.
void initAnalyzedLoci(size_t numberOfLoci)
Initialize the AnalyzedLoci for number of loci.
size_t getIndividualPositionInGroup(size_t groupPosition, const std::string &individual_id) const
Get the position of an Individual in a Group.
size_t getGroupPosition(size_t group_id) const
Get the position of a Group.
void setLocusInfo(size_t locus_position, const LocusInfo &locus)
Set a LocusInfo.
void setIndividualMonolocusGenotypeByAlleleIdInGroup(size_t groupPosition, size_t individualPosition, size_t locusPosition, const std::vector< std::string > alleleId)
Set a MonolocusGenotype of an Individual from a group.
void addEmptyIndividualToGroup(size_t groupPosition, const std::string &individual_id)
Add an empty Individual to a Group.
void initIndividualGenotypeInGroup(size_t groupPosition, size_t individualPosition)
Initialize the genotype of an Individual in a Group.
void addEmptyGroup(size_t group_id)
Add an empty Group to the DataSet.
void read(std::istream &is, DataSet &data_set)
Read a DataSet on istream.
size_t numberOfRemainingTokens() const
const std::string & nextToken()
bool hasMoreToken() const
std::string removeSurroundingWhiteSpaces(const std::string &s)
std::string toUpper(const std::string &s)
std::string toString(T t)