bpp-popgen  3.0.0
LocusInfo.h
Go to the documentation of this file.
1 //
2 // File LocusInfo.h
3 // Author : Sylvain Gaillard
4 // Last modification : Thursday July 29 2004
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for population genetics analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38  */
39 
40 #ifndef _LOCUSINFO_H_
41 #define _LOCUSINFO_H_
42 
43 // From STL
44 #include <string>
45 #include <vector>
46 
47 // From local Popgenlib
48 #include "AlleleInfo.h"
49 #include "GeneralExceptions.h"
50 
51 #include <Bpp/Exceptions.h>
52 
53 namespace bpp
54 {
63 class LocusInfo
64 {
65 private:
66  std::string name_;
67  unsigned int ploidy_;
68  std::vector<AlleleInfo*> alleles_;
69 
70 public:
71  static unsigned int HAPLODIPLOID;
72  static unsigned int HAPLOID;
73  static unsigned int DIPLOID;
74  static unsigned int UNKNOWN;
75 
76 public:
77  // Constructors and destructor
84  LocusInfo(const std::string& name, const unsigned int ploidy = DIPLOID);
85 
89  LocusInfo(const LocusInfo& locus_info);
90 
94  virtual ~LocusInfo();
95 
96 public:
97  // Methodes
101  const std::string& getName() const { return name_; }
102 
108  unsigned int getPloidy() const { return ploidy_; }
109 
115  void addAlleleInfo(const AlleleInfo& allele);
116 
122  const AlleleInfo& getAlleleInfoById(const std::string& id) const;
123 
129  const AlleleInfo& getAlleleInfoByKey(size_t key) const;
130 
136  unsigned int getAlleleInfoKey(const std::string& id) const;
137 
141  size_t getNumberOfAlleles() const;
142 
146  void clear();
147 };
148 } // end of namespace bpp;
149 
150 #endif // _LOCUSINFO_H_
151 
The AlleleInfo interface.
Definition: AlleleInfo.h:60
The LocusInfo class.
Definition: LocusInfo.h:64
static unsigned int UNKNOWN
Definition: LocusInfo.h:74
unsigned int getPloidy() const
Get the ploidy of the locus.
Definition: LocusInfo.h:108
LocusInfo(const std::string &name, const unsigned int ploidy=DIPLOID)
Build a new LocusInfo object.
Definition: LocusInfo.cpp:55
virtual ~LocusInfo()
Destroy the LocusInfo.
Definition: LocusInfo.cpp:71
size_t getNumberOfAlleles() const
Get the number of alleles at this locus.
Definition: LocusInfo.cpp:121
void clear()
Delete all alleles from the locus.
Definition: LocusInfo.cpp:126
unsigned int getAlleleInfoKey(const std::string &id) const
Get the position of an AlleleInfo.
Definition: LocusInfo.cpp:111
static unsigned int DIPLOID
Definition: LocusInfo.h:73
unsigned int ploidy_
Definition: LocusInfo.h:67
const AlleleInfo & getAlleleInfoByKey(size_t key) const
Retrieve an AlleleInfo object of the LocusInfo.
Definition: LocusInfo.cpp:104
static unsigned int HAPLOID
Definition: LocusInfo.h:72
void addAlleleInfo(const AlleleInfo &allele)
Add an AlleleInfo to the LocusInfo.
Definition: LocusInfo.cpp:83
static unsigned int HAPLODIPLOID
Definition: LocusInfo.h:71
const AlleleInfo & getAlleleInfoById(const std::string &id) const
Retrieve an AlleleInfo object of the LocusInfo.
Definition: LocusInfo.cpp:94
std::vector< AlleleInfo * > alleles_
Definition: LocusInfo.h:68
const std::string & getName() const
Get the name of the locus.
Definition: LocusInfo.h:101
std::string name_
Definition: LocusInfo.h:66