bpp-popgen3  3.0.0
MonolocusGenotypeTools.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 // From Pop
9 
10 #include "MonolocusGenotypeTools.h"
11 
12 using namespace bpp;
13 using namespace std;
14 
15 std::unique_ptr<MonolocusGenotypeInterface> MonolocusGenotypeTools::buildMonolocusGenotypeByAlleleKey(const std::vector<size_t> alleleKeys)
16 {
17  if (alleleKeys.size() < 1)
18  throw Exception("MonolocusGenotypeTools::buildMonolocusGenotypeByAlleleKey: no key in allele_keys.");
19 
20  if (alleleKeys.size() == 1)
21  return unique_ptr<MonolocusGenotypeInterface>(new MonoAlleleMonolocusGenotype(alleleKeys));
22  if (alleleKeys.size() == 2)
23  return unique_ptr<MonolocusGenotypeInterface>(new BiAlleleMonolocusGenotype(alleleKeys));
24  // for all other cases (allele_keys.size() > 2)
25  return unique_ptr<MonolocusGenotypeInterface>(new MultiAlleleMonolocusGenotype(alleleKeys));
26 }
The BiAlleleMonolocusGenotype class.
The MonoAlleleMonolocusGenotype class.
static std::unique_ptr< MonolocusGenotypeInterface > buildMonolocusGenotypeByAlleleKey(const std::vector< size_t > alleleKeys)
Build a proper MonolocusGenotype accordig to the number of alleles.
The MultiAlleleMonolocusGenotype class.