bpp-popgen3  3.0.0
BiAlleleMonolocusGenotype.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 // Secured inclusion of header's file
6 #ifndef _BIALLELEMONOLOCUSGENOTYPE_H_
7 #define _BIALLELEMONOLOCUSGENOTYPE_H_
8 
9 // From STL
10 #include <vector>
11 
12 #include <Bpp/Exceptions.h>
13 
14 // From local
15 #include "MonolocusGenotype.h"
16 
17 namespace bpp
18 {
25  public virtual MonolocusGenotypeInterface
26 {
27 private:
28  std::vector<size_t> alleleIndex_;
29 
30 public:
31  // Constructors and destructor
35  BiAlleleMonolocusGenotype(size_t firstAlleleIndex,
36  size_t secondAlleleIndex);
37 
41  BiAlleleMonolocusGenotype(std::vector<size_t> alleleIndex);
42 
47 
52 
53 public:
58 
62  bool operator==(const BiAlleleMonolocusGenotype& bmg) const;
63 
67  size_t getFirstAlleleIndex() const
68  {
69  return alleleIndex_[0];
70  }
71 
75  size_t getSecondAlleleIndex() const
76  {
77  return alleleIndex_[1];
78  }
79 
83  bool isHomozygous() const
84  {
85  return alleleIndex_[0] == alleleIndex_[1];
86  }
87 
93  std::vector<size_t> getAlleleIndex() const override
94  {
95  return alleleIndex_;
96  }
97 
106  {
107  return new BiAlleleMonolocusGenotype(*this);
108  }
110 };
111 } // end of namespace bpp;
112 
113 #endif // _BIALLELEMONOLOCUSGENOTYPE_H_
The BiAlleleMonolocusGenotype class.
size_t getFirstAlleleIndex() const
Get the first allele index.
bool operator==(const BiAlleleMonolocusGenotype &bmg) const
The == operator.
BiAlleleMonolocusGenotype * clone() const override
size_t getSecondAlleleIndex() const
Get the second allele index.
std::vector< size_t > getAlleleIndex() const override
Get the alleles' index.
BiAlleleMonolocusGenotype & operator=(const BiAlleleMonolocusGenotype &bmg)
The affectation operator.
BiAlleleMonolocusGenotype(size_t firstAlleleIndex, size_t secondAlleleIndex)
Build a monolocus genotype containing two alleles.
bool isHomozygous() const
Test the homozygozity of the locus.
virtual ~BiAlleleMonolocusGenotype()
Destroy the BiAlleleMonolocusGenotype.
The MonolocusGenotype virtual class.