bpp-popgen  2.1.0
 All Classes Namespaces Files Functions Variables Friends Pages
Individual.h
Go to the documentation of this file.
1 //
2 // File Individual.h
3 // Author : Sylvain Gaillard
4 // Last modification : Tuesday August 03 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 _INDIVIDUAL_H_
41 #define _INDIVIDUAL_H_
42 
43 // From STL
44 #include <vector>
45 #include <memory>
46 
47 #include <Bpp/Graphics/Point2D.h>
48 #include <Bpp/Exceptions.h>
49 #include <Bpp/Text/TextTools.h>
50 
51 // From SeqLib
52 #include <Bpp/Seq/Sequence.h>
56 
57 // From PopGenLib
58 #include "Locality.h"
59 #include "Date.h"
60 #include "MultilocusGenotype.h"
61 #include "GeneralExceptions.h"
62 
63 namespace bpp
64 {
76 {
77 protected:
78  std::string id_;
79  unsigned short sex_;
80  std::auto_ptr<Date> date_;
81  std::auto_ptr< Point2D<double> > coord_;
83  std::auto_ptr<MapSequenceContainer> sequences_;
84  std::auto_ptr<MultilocusGenotype> genotype_;
85 
86 public:
87  // Constructors and destructor :
91  Individual();
92 
96  Individual(const std::string& id);
97 
108  Individual(const std::string& id,
109  const Date& date,
110  const Point2D<double>& coord,
111  Locality<double>* locality,
112  const unsigned short sex);
113 
117  Individual(const Individual& ind);
118 
122  virtual ~Individual();
123 
124 public:
125  // Methods
132  Individual& operator=(const Individual& ind);
133 
139  void setId(const std::string& id);
140 
146  const std::string& getId() const { return id_; }
147 
153  void setSex(const unsigned short sex);
154 
160  unsigned short getSex() const { return sex_; }
161 
167  void setDate(const Date& date);
168 
175  const Date& getDate() const throw (NullPointerException);
176 
180  bool hasDate() const;
181 
187  void setCoord(const Point2D<double>& coord);
188 
195  void setCoord(const double x, const double y);
196 
203  const Point2D<double>& getCoord() const throw (NullPointerException);
204 
208  bool hasCoord() const;
209 
218  void setX(const double x) throw (NullPointerException);
219 
228  void setY(const double y) throw (NullPointerException);
229 
236  double getX() const throw (NullPointerException);
237 
244  double getY() const throw (NullPointerException);
245 
251  void setLocality(const Locality<double>* locality);
252 
258  const Locality<double>* getLocality() const throw (NullPointerException);
259 
263  bool hasLocality() const;
264 
277  void addSequence(size_t sequence_key, const Sequence& sequence)
278  throw (Exception);
279 
288  const Sequence& getSequenceByName(const std::string& sequence_name)
289  const throw (Exception);
290 
299  const Sequence& getSequenceAtPosition(const size_t sequence_position)
300  const throw (Exception);
301 
309  void deleteSequenceByName(const std::string& sequence_name) throw (Exception);
310 
318  void deleteSequenceAtPosition(size_t sequence_position) throw (Exception);
319 
326  bool hasSequences() const;
327 
331  bool hasSequenceAtPosition(size_t position) const;
332 
338  const Alphabet* getSequenceAlphabet() const throw (NullPointerException);
339 
346  std::vector<std::string> getSequencesNames() const throw (NullPointerException);
347 
354  std::vector<size_t> getSequencesPositions() const throw (NullPointerException);
355 
362  size_t getSequencePosition(const std::string& sequence_name) const throw (Exception);
363 
367  size_t getNumberOfSequences() const;
368 
372  void setSequences(const MapSequenceContainer& msc);
373 
379  const OrderedSequenceContainer& getSequences() const throw (NullPointerException);
380 
386  void setGenotype(const MultilocusGenotype& genotype);
387 
394  void initGenotype(size_t loci_number) throw (Exception);
395 
399  const MultilocusGenotype& getGenotype() const throw (NullPointerException);
400 
404  void deleteGenotype();
405 
409  bool hasGenotype() const;
410 
417  void setMonolocusGenotype(size_t locus_position, const MonolocusGenotype& monogen)
418  throw (Exception);
419 
427  void setMonolocusGenotypeByAlleleKey(size_t locus_position, const std::vector<size_t> allele_keys)
428  throw (Exception);
429 
437  void setMonolocusGenotypeByAlleleId(size_t locus_position, const std::vector<std::string> allele_id, const LocusInfo& locus_info)
438  throw (Exception);
439 
446  const MonolocusGenotype& getMonolocusGenotype(size_t locus_position) throw (Exception);
447 
453  size_t countNonMissingLoci() const throw (NullPointerException);
454 
460  size_t countHomozygousLoci() const throw (NullPointerException);
461 
467  size_t countHeterozygousLoci() const throw (NullPointerException);
468 };
469 } // end of namespace bpp;
470 
471 #endif // _INDIVIDUAL_H_
472