52 vector<size_t> groups;
53 for (
size_t i = 0; i < permuted_pmgc.
size(); i++)
59 std::random_shuffle(groups.begin(), groups.end());
60 for (
size_t i = 0; i < permuted_pmgc.
size(); i++)
73 vector<vector<const MonolocusGenotype*> > mono_gens;
74 mono_gens.resize(loc_num);
76 for (
size_t i = 0; i < pmgc.
size(); i++)
78 if (groups.find(pmgc.
getGroupId(i)) != groups.end())
80 for (
size_t j = 0; j < loc_num; j++)
87 for (
size_t i = 0; i < loc_num; i++)
90 std::random_shuffle(mono_gens[i].begin(), mono_gens[i].end());
94 for (
size_t i = 0; i < pmgc.
size(); i++)
96 if (groups.find(pmgc.
getGroupId(i)) != groups.end())
99 for (
size_t j = 0; j < loc_num; j++)
101 if (mono_gens[j][k] != NULL)
115 for (set<size_t>::iterator it = grp_ids.begin(); it != grp_ids.end(); it++)
122 return permuted_pmgc;
131 vector<vector<const MonolocusGenotype*> > mono_gens;
132 mono_gens.resize(loc_num);
134 for (set<size_t>::const_iterator g = groups.begin(); g != groups.end(); g++)
136 size_t nb_ind_in_group = 0;
138 for (
size_t i = 0; i < pmgc.
size(); i++)
141 if (groups.find(indiv_grp) != groups.end())
147 for (
size_t j = 0; j < loc_num; j++)
160 if (nb_ind_in_group > 0)
162 for (
size_t j = 0; j < loc_num; j++)
165 std::random_shuffle(mono_gens[j].begin(), mono_gens[j].end());
170 for (
size_t k = 0; k < nb_ind_in_group; k++)
172 for (
size_t j = 0; j < loc_num; j++)
174 if (mono_gens[j][k] != NULL)
185 for (set<size_t>::iterator it = grp_ids.begin(); it != grp_ids.end(); it++)
192 return permuted_pmgc;
201 vector<vector<size_t> > alleles;
202 alleles.resize(loc_num);
204 for (
size_t i = 0; i < pmgc.
size(); i++)
206 if (groups.find(pmgc.
getGroupId(i)) != groups.end())
208 for (
size_t j = 0; j < loc_num; j++)
211 for (
size_t k = 0; k < pmgc.
getMultilocusGenotype(i)->getMonolocusGenotype(j).getAlleleIndex().size(); k++)
219 for (
size_t i = 0; i < loc_num; i++)
222 std::random_shuffle(alleles[i].begin(), alleles[i].end());
225 vector<size_t> k(loc_num, 0);
226 for (
size_t i = 0; i < pmgc.
size(); i++)
228 if (groups.find(pmgc.
getGroupId(i)) != groups.end())
231 for (
size_t j = 0; j < loc_num; j++)
251 for (set<size_t>::iterator it = grp_ids.begin(); it != grp_ids.end(); it++)
258 return permuted_pmgc;
267 vector<vector<size_t> > alleles;
268 alleles.resize(loc_num);
270 for (set<size_t>::const_iterator g = groups.begin(); g != groups.end(); g++)
272 size_t nb_ind_in_group = 0;
274 vector< vector<size_t> > nb_alleles_for_inds;
275 nb_alleles_for_inds.resize(loc_num);
277 for (
size_t i = 0; i < pmgc.
size(); i++)
280 if (groups.find(indiv_grp) != groups.end() )
285 for (
size_t j = 0; j < loc_num; j++)
290 nb_alleles_for_inds[j].push_back(nb_alls);
291 for (
size_t k = 0; k < nb_alls; k++)
306 if (nb_ind_in_group > 0)
308 for (
size_t i = 0; i < loc_num; i++)
311 std::random_shuffle(alleles[i].begin(), alleles[i].end());
315 vector<size_t> k(loc_num, 0);
317 for (
size_t ind = 0; ind < nb_ind_in_group; ind++)
320 for (
size_t j = 0; j < loc_num; j++)
322 if (nb_alleles_for_inds[j][ind] == 1)
324 if (nb_alleles_for_inds[j][ind] == 2)
336 for (set<size_t>::iterator it = grp_ids.begin(); it != grp_ids.end(); it++)
343 return permuted_pmgc;
351 for (set<size_t>::const_iterator g = groups.begin(); g != groups.end(); g++)
354 for (
size_t i = 0; i < pmgc.
size(); i++)
357 if (groups.find(indiv_grp) != groups.end() )
369 for (set<size_t>::iterator it = grp_ids.begin(); it != grp_ids.end(); it++)
The BiAlleleMonolocusGenotype class.
The MonoAlleleMonolocusGenotype class.
virtual std::vector< size_t > getAlleleIndex() const =0
Get the alleles' index.
The MultilocusGenotype class.
void setMonolocusGenotype(size_t locus_position, const MonolocusGenotype &monogen)
Set a MonolocusGenotype.
const MonolocusGenotype & getMonolocusGenotype(size_t locus_position) const
Get a MonolocusGenotype.
bool isMonolocusGenotypeMissing(size_t locus_position) const
Tell if a MonolocusGenotype is a missing data.
The PolymorphismMultiGContainer class.
size_t getGroupId(size_t position) const
Get the Group id of a MultilocusGenotype.
const MultilocusGenotype * getMultilocusGenotype(size_t position) const
Get a MultilocusGenotype at a position.
void setGroupId(size_t position, size_t group_id)
Set the Group id of a MultilocusGenotype.
size_t getNumberOfLoci() const
Get the number of loci if the MultilocusGenotypes are aligned.
std::string getGroupName(size_t group_id) const
Get the group name for a given group id or just the id if not available juste return it's id.
void addMultilocusGenotype(const MultilocusGenotype &mg, size_t group)
Add a MultilocusGenotype to the container.
std::set< size_t > getAllGroupsIds() const
Get the groups' ids.
size_t size() const
Get the number of MultilocusGenotype.
void setGroupName(size_t group_id, std::string name)
Set the name for the given group id.