bpp-popgen  2.2.0
PolymorphismMultiGContainer.h
Go to the documentation of this file.
1 //
2 // File PolymorphismMultiGContainer.h
3 // Author : Sylvain Gaillard
4 //
5 
6 /*
7  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
8 
9  This software is a computer program whose purpose is to provide classes
10  for population genetics analysis.
11 
12  This software is governed by the CeCILL license under French law and
13  abiding by the rules of distribution of free software. You can use,
14  modify and/ or redistribute the software under the terms of the CeCILL
15  license as circulated by CEA, CNRS and INRIA at the following URL
16  "http://www.cecill.info".
17 
18  As a counterpart to the access to the source code and rights to copy,
19  modify and redistribute granted by the license, users are provided only
20  with a limited warranty and the software's author, the holder of the
21  economic rights, and the successive licensors have only limited
22  liability.
23 
24  In this respect, the user's attention is drawn to the risks associated
25  with loading, using, modifying and/or developing or reproducing the
26  software by the user in light of its specific status of free software,
27  that may mean that it is complicated to manipulate, and that also
28  therefore means that it is reserved for developers and experienced
29  professionals having in-depth computer knowledge. Users are therefore
30  encouraged to load and test the software's suitability as regards their
31  requirements in conditions enabling the security of their systems and/or
32  data to be ensured and, more generally, to use and operate it in the
33  same conditions as regards security.
34 
35  The fact that you are presently reading this means that you have had
36  knowledge of the CeCILL license and that you accept its terms.
37  */
38 
39 #ifndef _POLYMORPHYSMMULTIGCONTAINER_H_
40 #define _POLYMORPHYSMMULTIGCONTAINER_H_
41 
42 // From Utils
43 #include <Bpp/Clonable.h>
44 #include <Bpp/Exceptions.h>
45 #include <Bpp/Utils/MapTools.h>
46 #include <Bpp/Text/TextTools.h>
47 
48 // From popgenlib
49 #include "MultilocusGenotype.h"
50 #include "GeneralExceptions.h"
51 
52 // From STL
53 #include <string>
54 #include <vector>
55 #include <map>
56 #include <set>
57 
58 namespace bpp
59 {
68 {
69 private:
70  std::vector<MultilocusGenotype*> multilocusGenotypes_;
71  std::vector<size_t> groups_; // group id for each multilocusgenotype
72  std::map<size_t, std::string> groups_names_;
73 
74 public:
75  // Constructors and destructor
80 
85 
90 
91 public:
96 
100  void addMultilocusGenotype(const MultilocusGenotype& mg, size_t group);
101 
107  const MultilocusGenotype* getMultilocusGenotype(size_t position) const throw (IndexOutOfBoundsException);
108 
114  MultilocusGenotype* removeMultilocusGenotype(size_t position) throw (IndexOutOfBoundsException);
115 
121  void deleteMultilocusGenotype(size_t position) throw (IndexOutOfBoundsException);
122 
126  bool isAligned() const;
127 
133  size_t getNumberOfLoci() const throw (Exception);
134 
140  size_t getGroupId(size_t position) const throw (IndexOutOfBoundsException);
141 
147  void setGroupId(size_t position, size_t group_id) throw (IndexOutOfBoundsException);
148 
152  std::set<size_t> getAllGroupsIds() const;
153 
157  std::vector<std::string> getAllGroupsNames() const;
158 
162  bool groupExists(size_t group) const;
163 
167  size_t getNumberOfGroups() const;
168 
172  size_t getGroupSize(size_t group) const;
173 
177  std::string getGroupName(size_t group_id) const throw (GroupNotFoundException);
178 
182  void setGroupName(size_t group_id, std::string name) throw (GroupNotFoundException);
183 
187  void addGroupName(size_t group_id, std::string name);
188 
192  size_t getLocusGroupSize(size_t group, size_t locus_position) const;
193 
197  size_t size() const;
198 
202  void clear();
203 };
204 } // end of namespace bpp;
205 
206 #endif // _POLYMORPHYSMMULTIGCONTAINER_H_
void setGroupId(size_t position, size_t group_id)
Set the Group id of a MultilocusGenotype.
std::vector< MultilocusGenotype * > multilocusGenotypes_
size_t getNumberOfGroups() const
Get the number of groups.
MultilocusGenotype * removeMultilocusGenotype(size_t position)
Remove a MultilocusGenotype.
The GroupNotFoundException class.
PolymorphismMultiGContainer & operator=(const PolymorphismMultiGContainer &pmgc)
The assignation operator=.
std::set< size_t > getAllGroupsIds() const
Get the groups&#39; ids.
std::map< size_t, std::string > groups_names_
bool isAligned() const
Tell if the MultilocusGenotypes are aligned (i.e. same size).
STL namespace.
PolymorphismMultiGContainer()
Build a new PolymorphismMultilocusGenotypeContainer.
The MultilocusGenotype class.
~PolymorphismMultiGContainer()
Destroy a PolymorphismMultilocusGenotypeContainer.
size_t getGroupId(size_t position) const
Get the Group id of a MultilocusGenotype.
void deleteMultilocusGenotype(size_t position)
Delete a MultilocusGenotype.
std::vector< std::string > getAllGroupsNames() const
Get the groups names or ids if not available.
size_t getLocusGroupSize(size_t group, size_t locus_position) const
Get the size of a group for a given locus.
void addMultilocusGenotype(const MultilocusGenotype &mg, size_t group)
Add a MultilocusGenotype to the container.
size_t getGroupSize(size_t group) const
Get group size.
The PolymorphismMultiGContainer class.
const MultilocusGenotype * getMultilocusGenotype(size_t position) const
Get a MultilocusGenotype at a position.
void setGroupName(size_t group_id, std::string name)
Set the name for the given group id.
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&#39;s id...
size_t size() const
Get the number of MultilocusGenotype.
void addGroupName(size_t group_id, std::string name)
Inserts a name for the given group id.
bool groupExists(size_t group) const
Tell if a group exists.
size_t getNumberOfLoci() const
Get the number of loci if the MultilocusGenotypes are aligned.