~ubuntu-branches/ubuntu/trusty/libbpp-popgen/trusty

« back to all changes in this revision

Viewing changes to src/Bpp/PopGen/MultilocusGenotype.h

  • Committer: Package Import Robot
  • Author(s): Julien Dutheil
  • Date: 2013-03-07 10:51:00 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130307105100-7ij3w7iyab9t2mbt
Tags: 2.1.0-1
Bug fixed and warnings removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
//
6
6
 
7
7
/*
8
 
   Copyright or © or Copr. CNRS, (November 17, 2004)
 
8
   Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9
9
 
10
10
   This software is a computer program whose purpose is to provide classes
11
11
   for population genetics analysis.
12
12
 
13
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, 
 
14
   abiding by the rules of distribution of free software.  You can  use,
15
15
   modify and/ or redistribute the software under the terms of the CeCILL
16
16
   license as circulated by CEA, CNRS and INRIA at the following URL
17
 
   "http://www.cecill.info". 
 
17
   "http://www.cecill.info".
18
18
 
19
19
   As a counterpart to the access to the source code and  rights to copy,
20
20
   modify and redistribute granted by the license, users are provided only
21
21
   with a limited warranty  and the software's author,  the holder of the
22
22
   economic rights,  and the successive licensors  have only  limited
23
 
   liability. 
 
23
   liability.
24
24
 
25
25
   In this respect, the user's attention is drawn to the risks associated
26
26
   with loading,  using,  modifying and/or developing or reproducing the
29
29
   therefore means  that it is reserved for developers  and  experienced
30
30
   professionals having in-depth computer knowledge. Users are therefore
31
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. 
 
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
35
 
36
36
   The fact that you are presently reading this means that you have had
37
37
   knowledge of the CeCILL license and that you accept its terms.
38
 
   */
 
38
 */
39
39
 
40
40
#ifndef _MULTILOCUSGENOTYPE_H_
41
41
#define _MULTILOCUSGENOTYPE_H_
55
55
 
56
56
namespace bpp
57
57
{
58
 
 
59
 
  /**
60
 
   * @brief The MultilocusGenotype class.
61
 
   *
62
 
   * This is a MonolocusGenotype containor.
63
 
   *
64
 
   * @author Sylvain Gaillard
65
 
   */
66
 
  class MultilocusGenotype
67
 
  {
68
 
    private:
69
 
      std::vector<MonolocusGenotype*> loci_;
70
 
 
71
 
    public: // Constructors and Destructor
72
 
      /**
73
 
       * @brief Build a MultilocusGenotype linked to an AnalyzedLoci object.
74
 
       *
75
 
       * @throw BadIntegerException if loci_number < 1.
76
 
       */
77
 
      MultilocusGenotype(unsigned int loci_number) throw (BadIntegerException);
78
 
 
79
 
      /**
80
 
       * @brief Copy constructor.
81
 
       */
82
 
      MultilocusGenotype(const MultilocusGenotype& genotype);
83
 
 
84
 
      /**
85
 
       * @brief Destroy a MultilocusGenotype.
86
 
       */
87
 
      ~MultilocusGenotype();
88
 
 
89
 
    public:
90
 
      /**
91
 
       * @brief Set a MonolocusGenotype.
92
 
       */
93
 
      void setMonolocusGenotype(unsigned int locus_position,
94
 
          const MonolocusGenotype& monogen) throw (IndexOutOfBoundsException);
95
 
 
96
 
      /**
97
 
       * @brief Set a MonolocusGenotype by allele keys.
98
 
       *
99
 
       * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
100
 
       * @throw Exception if there is no key in allele_keys.
101
 
       */
102
 
      void setMonolocusGenotypeByAlleleKey(unsigned int locus_position,
103
 
          const std::vector<unsigned int>& allele_keys) throw (Exception);
104
 
 
105
 
      /**
106
 
       * @brief Set a MonolocusGenotype by allele id.
107
 
       *
108
 
       * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
109
 
       * @throw AlleleNotFoundException if at least one of the id is not found in the LocusInfo.
110
 
       */
111
 
      void setMonolocusGenotypeByAlleleId(unsigned int locus_position,
112
 
          const std::vector<std::string>& allele_id, const LocusInfo& locus_info) throw (Exception);
113
 
 
114
 
      /**
115
 
       * @brief Set a MonolocusGenotype as missing data.
116
 
       *
117
 
       * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
118
 
       */
119
 
      void setMonolocusGenotypeAsMissing(unsigned int locus_position) throw (IndexOutOfBoundsException);
120
 
 
121
 
      /**
122
 
       * @brief Tell if a MonolocusGenotype is a missing data.
123
 
       *
124
 
       * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
125
 
       */
126
 
      bool isMonolocusGenotypeMissing(unsigned int locus_position) const throw (IndexOutOfBoundsException);
127
 
 
128
 
      /**
129
 
       * @brief Get a MonolocusGenotype.
130
 
       */
131
 
      const MonolocusGenotype& getMonolocusGenotype(unsigned int locus_position) const
132
 
        throw (IndexOutOfBoundsException);
133
 
 
134
 
      /**
135
 
       * @brief Count the number of loci.
136
 
       *
137
 
       * Return the size of _loci.
138
 
       */
139
 
      unsigned int size() const;
140
 
 
141
 
      /**
142
 
       * @brief Count the number of non missing MonolocusGenotype.
143
 
       */
144
 
      unsigned int countNonMissingLoci() const;
145
 
 
146
 
      /**
147
 
       * @brief Count the number of homozygous MonolocusGenotype.
148
 
       */
149
 
      unsigned int countHomozygousLoci() const;
150
 
 
151
 
      /**
152
 
       * @brief Count the number of heterozygous MonolocusGenotype.
153
 
       */
154
 
      unsigned int countHeterozygousLoci() const;
155
 
  };
156
 
 
157
 
} //end of namespace bpp;
 
58
/**
 
59
 * @brief The MultilocusGenotype class.
 
60
 *
 
61
 * This is a MonolocusGenotype containor.
 
62
 *
 
63
 * @author Sylvain Gaillard
 
64
 */
 
65
class MultilocusGenotype
 
66
{
 
67
private:
 
68
  std::vector<MonolocusGenotype*> loci_;
 
69
 
 
70
public:
 
71
  // Constructors and Destructor
 
72
  /**
 
73
   * @brief Build a MultilocusGenotype linked to an AnalyzedLoci object.
 
74
   *
 
75
   * @throw BadIntegerException if loci_number < 1.
 
76
   */
 
77
  MultilocusGenotype(size_t loci_number) throw (BadIntegerException);
 
78
 
 
79
  /**
 
80
   * @brief Copy constructor.
 
81
   */
 
82
  MultilocusGenotype(const MultilocusGenotype& genotype);
 
83
 
 
84
  /**
 
85
   * @brief Destroy a MultilocusGenotype.
 
86
   */
 
87
  ~MultilocusGenotype();
 
88
 
 
89
public:
 
90
  /**
 
91
   * @brief Set a MonolocusGenotype.
 
92
   */
 
93
  void setMonolocusGenotype(size_t locus_position,
 
94
                            const MonolocusGenotype& monogen) throw (IndexOutOfBoundsException);
 
95
 
 
96
  /**
 
97
   * @brief Set a MonolocusGenotype by allele keys.
 
98
   *
 
99
   * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
 
100
   * @throw Exception if there is no key in allele_keys.
 
101
   */
 
102
  void setMonolocusGenotypeByAlleleKey(size_t locus_position,
 
103
                                       const std::vector<size_t>& allele_keys) throw (Exception);
 
104
 
 
105
  /**
 
106
   * @brief Set a MonolocusGenotype by allele id.
 
107
   *
 
108
   * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
 
109
   * @throw AlleleNotFoundException if at least one of the id is not found in the LocusInfo.
 
110
   */
 
111
  void setMonolocusGenotypeByAlleleId(size_t locus_position,
 
112
                                      const std::vector<std::string>& allele_id, const LocusInfo& locus_info) throw (Exception);
 
113
 
 
114
  /**
 
115
   * @brief Set a MonolocusGenotype as missing data.
 
116
   *
 
117
   * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
 
118
   */
 
119
  void setMonolocusGenotypeAsMissing(size_t locus_position) throw (IndexOutOfBoundsException);
 
120
 
 
121
  /**
 
122
   * @brief Tell if a MonolocusGenotype is a missing data.
 
123
   *
 
124
   * @throw IndexOutOfBoundsException if locus_position excedes the number of loci.
 
125
   */
 
126
  bool isMonolocusGenotypeMissing(size_t locus_position) const throw (IndexOutOfBoundsException);
 
127
 
 
128
  /**
 
129
   * @brief Get a MonolocusGenotype.
 
130
   */
 
131
  const MonolocusGenotype& getMonolocusGenotype(size_t locus_position) const
 
132
  throw (IndexOutOfBoundsException);
 
133
 
 
134
  /**
 
135
   * @brief Count the number of loci.
 
136
   *
 
137
   * Return the size of _loci.
 
138
   */
 
139
  size_t size() const;
 
140
 
 
141
  /**
 
142
   * @brief Count the number of non missing MonolocusGenotype.
 
143
   */
 
144
  size_t countNonMissingLoci() const;
 
145
 
 
146
  /**
 
147
   * @brief Count the number of homozygous MonolocusGenotype.
 
148
   */
 
149
  size_t countHomozygousLoci() const;
 
150
 
 
151
  /**
 
152
   * @brief Count the number of heterozygous MonolocusGenotype.
 
153
   */
 
154
  size_t countHeterozygousLoci() const;
 
155
};
 
156
} // end of namespace bpp;
158
157
 
159
158
#endif // _MULTILOCUSGENOTYPE_H_
160
159