bpp-popgen3  3.0.0
MonoAlleleMonolocusGenotype.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
6 
7 using namespace bpp;
8 using namespace std;
9 
10 // ** Class constructor: *******************************************************/
11 
13  alleleIndex_(allele_index) {}
14 
15 MonoAlleleMonolocusGenotype::MonoAlleleMonolocusGenotype(std::vector<size_t> allele_index) : alleleIndex_(0)
16 {
17  if (allele_index.size() != 1)
18  throw BadSizeException("MonoAlleleMonolocusGenotype::MonoAlleleMonolocusGenotype: allele_index must contain one value.", allele_index.size(), 1);
19  alleleIndex_ = allele_index[0];
20 }
21 
23  alleleIndex_(mmg.getAlleleIndex()[0]) {}
24 
25 // ** Other methods: **********************************************************/
26 
28 {
29  alleleIndex_ = mmg.getAlleleIndex()[0];
30  return *this;
31 }
32 
34 {
35  return alleleIndex_ == mmg.getAlleleIndex()[0];
36 }
37 
39 {
40  vector<size_t> index;
41  index.push_back(alleleIndex_);
42  return index;
43 }
The MonoAlleleMonolocusGenotype class.
MonoAlleleMonolocusGenotype & operator=(const MonoAlleleMonolocusGenotype &mmg)
The affectation operator.
virtual bool operator==(const MonoAlleleMonolocusGenotype &mmg) const
The == operator.
std::vector< size_t > getAlleleIndex() const override
Get the alleles' index.
MonoAlleleMonolocusGenotype(size_t alleleIndex)
Build a monolocus genotype containing one allele.