11
11
for population genetics analysis.
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".
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
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.
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.
40
40
#include "BiAlleleMonolocusGenotype.h"
42
42
using namespace bpp;
43
43
using namespace std;
45
//** Class constructor: *******************************************************/
45
// ** Class constructor: *******************************************************/
47
47
BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype(
48
unsigned int first_allele_index,
49
unsigned int second_allele_index): allele_index_(vector<unsigned int>(2))
48
size_t first_allele_index,
49
size_t second_allele_index) : allele_index_(vector<size_t>(2))
51
51
allele_index_[0] = first_allele_index;
52
52
allele_index_[1] = second_allele_index;
55
BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype(std::vector<unsigned int> allele_index) throw (BadIntegerException): allele_index_(vector<unsigned int>(2))
55
BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype(std::vector<size_t> allele_index) throw (BadSizeException) : allele_index_(vector<size_t>(2))
57
57
if (allele_index.size() != 2)
58
throw BadIntegerException("BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype: allele_index must containes two values.", allele_index.size());
58
throw BadSizeException("BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype: allele_index must contain two values.", allele_index.size(), 2);
59
59
allele_index_[0] = allele_index[0];
60
60
allele_index_[1] = allele_index[1];
63
BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype(const BiAlleleMonolocusGenotype& bmg): allele_index_(vector<unsigned int>(2))
63
BiAlleleMonolocusGenotype::BiAlleleMonolocusGenotype(const BiAlleleMonolocusGenotype& bmg) : allele_index_(vector<size_t>(2))
65
for (unsigned int i=0 ; i<2 ; i++)
65
for (size_t i = 0; i < 2; i++)
66
67
allele_index_[i] = bmg.getAlleleIndex()[i];
69
//** Class destructor: ********************************************************/
71
// ** Class destructor: ********************************************************/
71
73
BiAlleleMonolocusGenotype::~BiAlleleMonolocusGenotype()
73
75
allele_index_.clear();
76
//** Other methodes: **********************************************************/
78
// ** Other methodes: **********************************************************/
78
BiAlleleMonolocusGenotype& BiAlleleMonolocusGenotype::operator= (const BiAlleleMonolocusGenotype& bmg)
80
BiAlleleMonolocusGenotype& BiAlleleMonolocusGenotype::operator=(const BiAlleleMonolocusGenotype& bmg)
80
for(unsigned int i = 0; i < 2; i++)
82
for (size_t i = 0; i < 2; i++)
81
84
allele_index_.push_back(bmg.getAlleleIndex()[i]);
85
bool BiAlleleMonolocusGenotype::operator== (const BiAlleleMonolocusGenotype& bmg) const
89
bool BiAlleleMonolocusGenotype::operator==(const BiAlleleMonolocusGenotype& bmg) const
87
return ((allele_index_[0] == bmg.getAlleleIndex()[0] && allele_index_[1] == bmg.getAlleleIndex()[1])
88
|| (allele_index_[0] == bmg.getAlleleIndex()[1] && allele_index_[1] == bmg.getAlleleIndex()[0]));
91
return (allele_index_[0] == bmg.getAlleleIndex()[0] && allele_index_[1] == bmg.getAlleleIndex()[1])
92
|| (allele_index_[0] == bmg.getAlleleIndex()[1] && allele_index_[1] == bmg.getAlleleIndex()[0]);
91
unsigned int BiAlleleMonolocusGenotype::getFirstAlleleIndex() const
95
size_t BiAlleleMonolocusGenotype::getFirstAlleleIndex() const
93
97
return allele_index_[0];
96
unsigned int BiAlleleMonolocusGenotype::getSecondAlleleIndex() const
100
size_t BiAlleleMonolocusGenotype::getSecondAlleleIndex() const
98
102
return allele_index_[1];
101
105
bool BiAlleleMonolocusGenotype::isHomozygous() const
103
return (allele_index_[0] == allele_index_[1]);
107
return allele_index_[0] == allele_index_[1];
106
std::vector<unsigned int> BiAlleleMonolocusGenotype::getAlleleIndex() const
110
std::vector<size_t> BiAlleleMonolocusGenotype::getAlleleIndex() const
108
112
return allele_index_;
111
115
BiAlleleMonolocusGenotype* BiAlleleMonolocusGenotype::clone() const
113
return new BiAlleleMonolocusGenotype(* this);
117
return new BiAlleleMonolocusGenotype(*this);