bpp-popgen  2.2.0
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>
53 #include <Bpp/Seq/SequenceExceptions.h>
54 #include <Bpp/Seq/Container/OrderedSequenceContainer.h>
55 #include <Bpp/Seq/Container/MapSequenceContainer.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 
virtual ~Individual()
Destroy an Individual.
Definition: Individual.cpp:113
size_t getNumberOfSequences() const
Get the number of sequences.
Definition: Individual.cpp:461
void setSex(const unsigned short sex)
Set the sex of the Individual.
Definition: Individual.cpp:168
std::string id_
Definition: Individual.h:78
void setDate(const Date &date)
Set the date of the Individual.
Definition: Individual.cpp:176
const Point2D< double > & getCoord() const
Get the coordinates of the Induvidual.
Definition: Individual.cpp:215
void initGenotype(size_t loci_number)
Init the genotype.
Definition: Individual.cpp:495
double getX() const
Get the X coordinate of the Individual.
Definition: Individual.cpp:252
const Alphabet * getSequenceAlphabet() const
Return the alphabet of the sequences.
Definition: Individual.cpp:452
bool hasCoord() const
Tell if this Individual has coordinates.
Definition: Individual.cpp:225
void setX(const double x)
Set the X coordinate of the Individual.
Definition: Individual.cpp:232
bool hasLocality() const
Tell if this Individual has a locality.
Definition: Individual.cpp:290
std::vector< std::string > getSequencesNames() const
Get the sequences&#39; names.
Definition: Individual.cpp:389
void setSequences(const MapSequenceContainer &msc)
Set all the sequences with a MapSequenceContainer.
Definition: Individual.cpp:470
const Locality< double > * locality_
Definition: Individual.h:82
const MonolocusGenotype & getMonolocusGenotype(size_t locus_position)
Get a MonolocusGenotype.
Definition: Individual.cpp:590
Individual()
Build a void new Individual.
Definition: Individual.cpp:47
STL namespace.
void setId(const std::string &id)
Set the id of the Individual.
Definition: Individual.cpp:160
The Individual class.
Definition: Individual.h:75
const Sequence & getSequenceByName(const std::string &sequence_name) const
Get a sequence by its name.
Definition: Individual.cpp:323
The MultilocusGenotype class.
The Date class.
Definition: Date.h:56
const Locality< double > * getLocality() const
Get the locality of the Individual.
Definition: Individual.cpp:280
bool hasGenotype() const
Tell if the Individual has a MultilocusGenotype.
Definition: Individual.cpp:527
std::vector< size_t > getSequencesPositions() const
Get the sequences&#39; positions.
Definition: Individual.cpp:398
bool hasSequences() const
Tell if the Individual has some sequences.
Definition: Individual.cpp:429
size_t getSequencePosition(const std::string &sequence_name) const
Get the position of a sequence.
Definition: Individual.cpp:413
bool hasDate() const
Tell if this Individual has a date.
Definition: Individual.cpp:193
void setMonolocusGenotypeByAlleleKey(size_t locus_position, const std::vector< size_t > allele_keys)
Set a MonolocusGenotype.
Definition: Individual.cpp:550
const std::string & getId() const
Get the id of the Individual.
Definition: Individual.h:146
void setMonolocusGenotypeByAlleleId(size_t locus_position, const std::vector< std::string > allele_id, const LocusInfo &locus_info)
Set a MonolocusGenotype.
Definition: Individual.cpp:570
std::auto_ptr< Point2D< double > > coord_
Definition: Individual.h:81
std::auto_ptr< Date > date_
Definition: Individual.h:80
void setGenotype(const MultilocusGenotype &genotype)
Set a genotype.
Definition: Individual.cpp:488
size_t countHeterozygousLoci() const
Count the number of heterozygous MonolocusGenotype.
Definition: Individual.cpp:624
unsigned short sex_
Definition: Individual.h:79
Individual & operator=(const Individual &ind)
The Individual copy operator.
Definition: Individual.cpp:117
bool hasSequenceAtPosition(size_t position) const
Tell if the Individual has a sequence at a given position.
Definition: Individual.cpp:436
const Sequence & getSequenceAtPosition(const size_t sequence_position) const
Get a sequence by its position.
Definition: Individual.cpp:340
size_t countHomozygousLoci() const
Count the number of homozygous MonolocusGenotype.
Definition: Individual.cpp:615
void deleteGenotype()
Delete the genotype of the individual.
Definition: Individual.cpp:520
void deleteSequenceByName(const std::string &sequence_name)
Delete a sequence.
Definition: Individual.cpp:357
std::auto_ptr< MultilocusGenotype > genotype_
Definition: Individual.h:84
const Date & getDate() const
Get the date of the Individual.
Definition: Individual.cpp:183
The MonolocusGenotype virtual class.
void setCoord(const Point2D< double > &coord)
Set the coodinates of the Individual.
Definition: Individual.cpp:201
The LocusInfo class.
Definition: LocusInfo.h:63
unsigned short getSex() const
Get the sex of the Individual.
Definition: Individual.h:160
void setLocality(const Locality< double > *locality)
Set the locality of the Individual.
Definition: Individual.cpp:273
const OrderedSequenceContainer & getSequences() const
Get a reference to the sequence container.
Definition: Individual.cpp:477
const MultilocusGenotype & getGenotype() const
Get the genotype.
Definition: Individual.cpp:511
void addSequence(size_t sequence_key, const Sequence &sequence)
Add a sequence to the Individual.
Definition: Individual.cpp:298
void setMonolocusGenotype(size_t locus_position, const MonolocusGenotype &monogen)
Set a MonolocusGenotype.
Definition: Individual.cpp:534
double getY() const
Get the Y coordinate of the Individual.
Definition: Individual.cpp:262
void setY(const double y)
Set the Y coordinate of th Individual.
Definition: Individual.cpp:242
std::auto_ptr< MapSequenceContainer > sequences_
Definition: Individual.h:83
void deleteSequenceAtPosition(size_t sequence_position)
Delete a sequence.
Definition: Individual.cpp:373
size_t countNonMissingLoci() const
Count the number of non missing MonolocusGenotype.
Definition: Individual.cpp:606