bpp-popgen  2.1.0
 All Classes Namespaces Files Functions Variables Friends Pages
Group.h
Go to the documentation of this file.
1 //
2 // File Group.h
3 // Author : Sylvain Gaillard
4 // Khalid Belkhir
5 // Last modification : Thursday July 29 2004
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for population genetics analysis.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39  */
40 
41 #ifndef _GROUP_H_
42 #define _GROUP_H_
43 
44 // From STL
45 #include <vector>
46 #include <memory>
47 
48 #include <Bpp/Exceptions.h>
49 #include <Bpp/Graphics/Point2D.h>
50 
51 // From SeqLib
55 
56 // From local
57 #include "Individual.h"
58 #include "GeneralExceptions.h"
59 
60 namespace bpp
61 {
70 class Group
71 {
72 protected:
73  size_t id_;
74  std::string name_;
75  std::vector<Individual*> individuals_;
76 
77 public:
78  // Constructors and destructor :
82  Group(size_t group_id);
83 
90  Group(const Group& group);
91 
95  Group(const Group& group, size_t group_id);
96 
100  ~Group();
101 
102 public:
106  Group& operator=(const Group& group);
107 
113  void setGroupId(size_t group_id);
114 
120  const std::string& getGroupName() const { return name_; }
121 
127  void setGroupName(const std::string& group_name);
128 
134  size_t getGroupId() const { return id_; }
135 
144  void addIndividual(const Individual& ind) throw (BadIdentifierException);
145 
151  void addEmptyIndividual(const std::string& individual_id) throw (BadIdentifierException);
152 
158  size_t getNumberOfIndividuals() const;
159 
166  size_t getMaxNumberOfSequences() const;
167 
173  size_t getIndividualPosition(const std::string& individual_id) const
175 
183  const Individual& getIndividualById(const std::string& individual_id) const throw (IndividualNotFoundException);
184 
193  const Individual& getIndividualAtPosition(size_t individual_position) const
195 
207  std::auto_ptr<Individual> removeIndividualById(const std::string& individual_id) throw (IndividualNotFoundException);
208 
219  std::auto_ptr<Individual> removeIndividualAtPosition(size_t individual_position) throw (IndexOutOfBoundsException);
220 
231  void deleteIndividualById(const std::string& individual_id) throw (IndividualNotFoundException);
232 
240  void deleteIndividualAtPosition(size_t individual_position) throw (IndexOutOfBoundsException);
241 
247  void clear();
248 
249  // -- Dealing with Individuals -----------------------------
255  void setIndividualSexAtPosition(size_t individual_position, const unsigned short sex)
257 
263  unsigned short getIndividualSexAtPosition(size_t individual_position) const
265 
271  void setIndividualDateAtPosition(size_t individual_position, const Date& date)
273 
280  const Date& getIndividualDateAtPosition(size_t individual_position) const
281  throw (Exception);
282 
288  void setIndividualCoordAtPosition(size_t individual_position, const Point2D<double>& coord)
290 
297  const Point2D<double>& getIndividualCoordAtPosition(size_t individual_position) const
298  throw (Exception);
299 
305  void setIndividualLocalityAtPosition(size_t individual_position, const Locality<double>* locality)
307 
314  const Locality<double>& getIndividualLocalityAtPosition(size_t individual_position) const
315  throw (Exception);
316 
325  void addIndividualSequenceAtPosition(size_t individual_position,
326  size_t sequence_position, const Sequence& sequence)
327  throw (Exception);
328 
336  const Sequence& getIndividualSequenceByName(size_t individual_position, const std::string& sequence_name) const
337  throw (Exception);
338 
346  const Sequence& getIndividualSequenceAtPosition(size_t individual_position, size_t sequence_position) const
347  throw (Exception);
348 
356  void deleteIndividualSequenceByName(size_t individual_position, const std::string& sequence_name)
357  throw (Exception);
358 
366  void deleteIndividualSequenceAtPosition(size_t individual_position, size_t sequence_position)
367  throw (Exception);
368 
374  bool hasIndividualSequences(size_t individual_position) const throw (IndexOutOfBoundsException);
375 
382  std::vector<std::string> getIndividualSequencesNames(size_t individual_position) const throw (Exception);
383 
391  size_t getIndividualSequencePosition(size_t individual_position, const std::string& sequence_name) const
392  throw (Exception);
393 
400  size_t getIndividualNumberOfSequences(size_t individual_position) const throw (Exception);
401 
407  void setIndividualSequences(size_t individual_position, const MapSequenceContainer& msc)
409 
415  void setIndividualGenotype(size_t individual_position, const MultilocusGenotype& genotype) throw (IndexOutOfBoundsException);
416 
424  void initIndividualGenotype(size_t individual_position, size_t loci_number)
425  throw (Exception);
426 
432  void deleteIndividualGenotype(size_t individual_position) throw (IndexOutOfBoundsException);
433 
439  bool hasIndividualGenotype(size_t individual_position) const throw (IndexOutOfBoundsException);
440 
448  void setIndividualMonolocusGenotype(size_t individual_position, size_t locus_position,
449  const MonolocusGenotype& monogen) throw (Exception);
450 
459  void setIndividualMonolocusGenotypeByAlleleKey(size_t individual_position, size_t locus_position,
460  const std::vector<size_t>& allele_keys) throw (Exception);
461 
470  void setIndividualMonolocusGenotypeByAlleleId(size_t individual_position, size_t locus_position,
471  const std::vector<std::string>& allele_id, const LocusInfo& locus_info) throw (Exception);
472 
480  const MonolocusGenotype& getIndividualMonolocusGenotype(size_t individual_position,
481  size_t locus_position) const throw (Exception);
482 
486  bool hasSequenceData() const;
487 
491  const Alphabet* getAlphabet() const throw (NullPointerException);
492 
496  size_t getGroupSizeForLocus(size_t locus_position) const;
497 
501  size_t getGroupSizeForSequence(size_t sequence_position) const;
502 };
503 } // end of namespace bpp;
504 
505 #endif // _GROUP_H_
506