Commit 6870b5f9 authored by Damien Leroux's avatar Damien Leroux
Browse files

All tests pass. Test code coverage about OK.

parent 50d88c16
......@@ -91,121 +91,10 @@ inline std::ostream& operator << (std::ostream& os, const impl::f_polynom& p)
return os;
}
#if 0
inline std::ostream& operator << (std::ostream& os, const impl::d_polynom& p)
{
bool started = false;
if (p.valuation > 0) {
started = true;
os << 'X';
if (p.valuation > 1) {
os << '^' << p.valuation;
}
}
if (!(p.size() == 1 && p[0] == 1 && started)) {
if (started) {
os << "*(";
}
auto i = p.rbegin();
auto j = p.rend();
if (i == j) {
os << '0';
} else {
int exponent = p.size() - 1;
os << (*i++);
if (exponent > 0) {
os << "*X";
if (exponent > 1) {
os << '^' << exponent;
}
--exponent;
}
while (i != j) {
os << '+' << (*i++);
if (exponent > 0) {
os << "*X";
if (exponent > 1) {
os << '^' << exponent;
}
--exponent;
}
}
}
if (started) {
os << ')';
}
}
return os;
}
inline std::ostream& operator << (std::ostream& os, const impl::f_polynom& p)
{
bool started = false;
if (p.r_exp > 0) {
os << "X";
if (p.r_exp > 1) {
os << '^' << p.r_exp;
}
started = true;
}
if (p.s_exp > 0) {
if (started) {
os << "*";
}
os << "(1-X)";
if (p.s_exp > 1) {
os << '^' << p.s_exp;
}
started = true;
}
if (!(p.P.size() == 1 && p.P[0] == 1 && started)) {
if (started) {
os << '*';
if (p.P.size() > 1) {
os << '(';
}
}
auto i = p.P.rbegin();
auto j = p.P.rend();
if (i == j) {
os << '0';
} else {
int exponent = p.P.size() - 1;
os << (*i++);
if (exponent > 0) {
os << "*X";
if (exponent > 1) {
os << '^' << exponent;
}
--exponent;
}
while (i != j) {
if (*i < 0) {
os << (*i++);
} else {
os << '+' << (*i++);
}
if (exponent > 0) {
os << "*X";
if (exponent > 1) {
os << '^' << exponent;
}
--exponent;
}
}
if (started && p.P.size() > 1) {
os << ')';
}
}
}
return os;
}
#endif
inline std::ostream& operator << (std::ostream& os, const fast_polynom& f)
{
return os << ((const impl::f_polynom&)f);
return os << ((const impl::d_polynom&)f);
}
inline std::ostream& operator << (std::ostream& os, const impl::polynom& p)
......
......@@ -12,6 +12,7 @@
/*#define RIL_ORDER 10*/
#define RIL_ORDER 10
#define MAX_EXACT_LUMP_SIZE 512
#define FUZZY_COMPARE
......@@ -168,7 +169,7 @@ GenoMatrix self_gametes()
if (!init) {
ret = kroneckerProduct(gametes(), gametes());
init = true;
std::cout << ret << std::endl;
/*std::cout << ret << std::endl;*/
}
return ret;
}
......@@ -321,9 +322,8 @@ struct generation_rs {
MatrixXb compute_mask(multi_generation_observations& mgo)
{
static MatrixXb gam = MatrixXb::Ones(2, 1);
auto p1 = kroneckerProduct(parent1->design->compute_possibles(mgo), gam);
auto p2 = kroneckerProduct(parent2->design->compute_possibles(mgo), gam);
/*MatrixXb ret = g->lumper * kroneckerProduct(p1, p2);*/
MatrixXb p1 = kroneckerProduct(parent1->design->compute_possibles(mgo), gam);
MatrixXb p2 = kroneckerProduct(parent2->design->compute_possibles(mgo), gam);
MatrixXb ret(g->lumper.innerSize(), p1.outerSize());
for (int i = 0; i < p1.outerSize(); ++i) {
ret.col(i) = g->lumper * kroneckerProduct(p1.col(i), p2.col(i));
......@@ -385,6 +385,7 @@ struct generation_rs {
void update_locus_vectors(multi_generation_observations& mgo)
{
/*std::cout << "design " << design << std::endl;*/
design->compute_possibles(mgo);
}
......@@ -513,32 +514,48 @@ struct generation_rs {
struct segment_computer_t {
const generation_rs& g_this;
geno_prob_computer<GenerationRS> gpc;
std::vector<geno_prob_computer<GenerationRS>> gpc_vec;
std::vector<double> steps;
double noise;
segment_computer_t(const generation_rs& g)
: g_this(g), gpc(), steps(), noise(0)
{}
segment_computer_t(const generation_rs& g, const std::vector<double>& loci)
: g_this(g), gpc_vec(), steps(), noise(0)
{
gpc_vec.resize(g.P.size());
size_t i = 0;
for (auto& p: g.P) {
gpc_vec[i].locus = loci;
gpc_vec[i].init(p.G);
++i;
}
}
labelled_matrix<MatrixXd, allele_pair, double>
compute(const MatrixXb& LV)
{
gpc.LV = g_this.noisy_LV(LV, noise);
auto lv = g_this.noisy_LV(LV, noise);
for (auto& g: gpc_vec) {
g.LV = lv;
}
return compute();
}
labelled_matrix<MatrixXd, allele_pair, double>
compute()
{
/*std::cerr << "POUEEEEEEEEEEEET" << std::endl;*/
auto pbegin = g_this.P.begin(), pend = g_this.P.end();
auto output = gpc.COMPUTE_SEGMENT(steps);
/*std::cout << "Process " << (*pbegin) << std::endl;*/
auto output = gpc_vec.front().COMPUTE_SEGMENT(steps);
output.data *= pbegin->weight;
/*std::cout << output.transpose() << std::endl;*/
size_t i = 1;
for (++pbegin; pbegin != pend; ++pbegin) {
gpc.init(pbegin->G);
auto tmp = gpc.COMPUTE_SEGMENT(steps);
tmp.data *= pbegin->weight;
output.data += tmp.data;
/*std::cout << "Process " << (*pbegin) << std::endl;*/
/*gpc.init(pbegin->G);*/
auto tmp = gpc_vec[i++].COMPUTE_SEGMENT(steps);
output.data += tmp.data * pbegin->weight;
/*std::cout << output.transpose() << std::endl;*/
}
return output;
}
......@@ -547,12 +564,16 @@ struct generation_rs {
compute(const std::vector<char> obs,
const std::vector<std::pair<char, std::vector<allele_pair>>>& obs_spec)
{
auto& gpc = gpc_vec.front();
auto pbegin = g_this.P.begin();
gpc.LV = MatrixXd::Zero(pbegin->G.innerSize(), gpc.locus.size());
auto OV = g_this.observation_vectors(obs_spec);
for (size_t i = 0; i < gpc.locus.size(); ++i) {
gpc.LV.col(i) = g_this.noisy_LV(OV[obs[i]], noise);
}
for (size_t i = 1; i < gpc_vec.size(); ++i) {
gpc_vec[i].LV = gpc_vec.front().LV;
}
return compute();
}
};
......@@ -562,11 +583,11 @@ struct generation_rs {
double step,
double noise) const
{
segment_computer_t ret(*this);
segment_computer_t ret(*this, loci);
ret.steps = compute_steps(loci, step);
ret.gpc.locus = loci;
auto pbegin = P.begin();
ret.gpc.init(pbegin->G);
/*ret.gpc.locus = loci;*/
/*auto pbegin = P.begin();*/
/*ret.gpc.init(pbegin->G);*/
return ret;
}
......@@ -790,7 +811,7 @@ public:
ret->P.emplace_back((process){pg, p1.weight * p2.weight});
}
}
std::cout << "NEW GENERATION " << new_name << std::endl;
/*std::cout << "NEW GENERATION " << new_name << std::endl;*/
ret->lump();
return ret;
}
......@@ -804,9 +825,12 @@ public:
generation_rs* to_ril(const std::string& ril_name) const
{
fast_polynom ril_dl = {1, -2};
fast_polynom one = {1};
/*fast_polynom one = {1};*/
fast_polynom half = {.5};
generation_rs* ret = fetch_impl(ril_name);
if (ret->design != NULL) {
return ret;
}
GenoMatrix tmp(1, 1);
process p = P.front();
ret->design = design->clone(ret);
......@@ -820,7 +844,7 @@ public:
fast_polynom ril = ril_dl;
double w = .5;
for (int i = 1; i < RIL_ORDER; ++i) {
fast_polynom q = (one - ril) * half;
fast_polynom q = (fast_polynom::one - ril) * half;
/*std::cout << "q=" << q << std::endl;*/
tmp(0, 0) = {{{0, 0}, {0,0}},
algebraic_genotype::Type::RilPolynom,
......@@ -832,10 +856,10 @@ public:
w *= .5;
}
ril *= ril_dl;
fast_polynom q = (one - ril) * half;
fast_polynom q = (fast_polynom::one - ril) * half;
tmp(0, 0) = {{{0, 0}, {0,0}},
algebraic_genotype::Type::RilPolynom,
{0, 0, q}};
q};
ret->P.emplace_back((process){
convert(kroneckerProduct(tmp, p.G.data)),
2 * w});
......
......@@ -43,13 +43,13 @@ PCH=$(subst .h,.h.gch,$(INCLUDES))
OBJ=$(subst .cc,.o,$(SRC))
COV_OBJ=$(subst .cc,.cov.o,$(SRC))
DEBUG_OPTS=-gdwarf-2 -gstrict-dwarf -Winvalid-pch
#DEBUG_OPTS=-gdwarf-2 -gstrict-dwarf -Winvalid-pch
OPT_OPTS=-O3 -DEIGEN_NO_DEBUG -DNDEBUG
COV_OPTS=-g -fprofile-arcs -ftest-coverage
COV_OPTS=$(DEBUG_OPTS) --coverage
PROF_OPTS=-pg -O
#PROF_OPTS=-pg -O
INFO_FILE=test-coverage.info
......
......@@ -10,6 +10,7 @@ using namespace Eigen;
#define MCQTL_PATH "/media/Stock/devel/MCQTL/MultiCrossQTL/build/bin/Linux/"
#define TRANSLATE_DATA MCQTL_PATH "TranslateData"
#define PROBAPOP MCQTL_PATH "ProbaPop"
#define REDIRECT_QUIET " > /dev/null"
labelled_matrix<MatrixXd, double, double>
/*MatrixXd*/
......@@ -17,7 +18,7 @@ test_probapop(const chromosome& chr, const marker_data& md, double step)
{
if (md.data_type == "cp") {
std::stringstream pp;
pp << PROBAPOP << ' ' << chr.name << ' ' << step;
pp << PROBAPOP << ' ' << chr.name << ' ' << step << REDIRECT_QUIET;
system(pp.str().c_str());
std::stringstream xml_name;
xml_name << chr.name.substr(0, chr.name.size() - 4) << ".xml";
......@@ -55,11 +56,11 @@ test_probapop(const chromosome& chr, const marker_data& md, double step)
unlink("pimpam.cfg");
chrono::stop("probapop[génération fichiers]");
chrono::start("probapop[translate_data]");
system(TRANSLATE_DATA " /tmp/probapop.map /tmp/probapop.phen /tmp/probapop.gen /tmp/probapop.inf");
system(TRANSLATE_DATA " /tmp/probapop.map /tmp/probapop.phen /tmp/probapop.gen /tmp/probapop.inf" REDIRECT_QUIET);
chrono::stop("probapop[translate_data]");
std::stringstream pp;
unlink("pimpam.xml");
pp << PROBAPOP << " pimpam.cfg " << step;
pp << PROBAPOP << " pimpam.cfg " << step << REDIRECT_QUIET;
chrono::start("probapop[calculs]");
system(pp.str().c_str());
chrono::stop("probapop[calculs]");
......@@ -73,12 +74,13 @@ test_probapop(const chromosome& chr, const marker_data& md, double step)
if (md.data_type == "bc") {
ret.data.row(1) += ret.data.row(2);
ret.row_labels = {ret.row_labels[0], ret.row_labels[1]};
ret.data = ret.data.topRows(2);
}
if (md.data_type == "ril") {
MatrixXd tmp = ret.data.topRows(2);
ret.data = tmp;
} else if (md.data_type == "ril" || md.data_type == "dh") {
ret.data.row(1) = ret.data.row(3);
ret.row_labels = {ret.row_labels[0], ret.row_labels[1]};
ret.data = ret.data.topRows(2);
ret.row_labels = {ret.row_labels[0], ret.row_labels[3]};
MatrixXd tmp = ret.data.topRows(2);
ret.data = tmp;
}
delete po;
return ret;
......
......@@ -77,7 +77,7 @@ static inline std::string readline(std::istream& is, int& lineno)
++lineno;
line = trim(line);
}
std::cout << ">> " << line << " <<" << std::endl;
/*std::cout << ">> " << line << " <<" << std::endl;*/
return line;
}
......
# TranslateData version 1.2 - Tue Jun 11 12:14:34 CEST 2013
*poptype
OUTBRED
*line
LM2T
*line
DA10D
*popName
LM2TDA10D
*nbInd
1
*nbMark
249
*nameMark
mEgCIR1713 mEgCIR3803 mEgCIR3788 mEgCIR3819 mEgCIR0399 mEgCIR3297 mEgCIR3316 mEgCIR0380 mEgCIR3428 mEgCIR0268 mEgCIR3813 mEgCIR0874 mEgCIR0280 mEgCIR3809 mEgCIR3782 mEgCIR2763 mEgCIR3847 mEgCIR3392 mCnCIR67 mEgCIR0332 mEgCIR0802 mEgCIR3792 mEgCIR2149 mEgCIR0793 mEgCIR3282 mEgCIR0408 mEgCIR3649 mEgCIR2659 mEgCIR2575 mEgCIR2215 mEgCIR3683 mEgCIR3698 mEgCIR2518 mEgCIR0369 mEgCIR0882 mCnCIRH6 mEgCIR0425 mEgCIR0173 mEgCIR3544 mEgCIR0912 mEgCIR3301 mEgCIR2347 mEgCIR3260 ECAA132 Sh0 mEgCIR3275 mEgCIR3194 mEgCIR3286 mEgCIR3526 mEgCIR3439 mEgCIR1917 mEgCIR0786 mCnCIR213 mEgCIR3232 mEgCIR3310 mEgCIR3535 mEgCIR2423 mEgCIR1716 mEgCIR3693 mEgCIR3533 mEgCIR3769 mCnCIR246 mEgCIR0074 mEgCIR2595 mEgCIR3160 mEgCIR3705 mEgCIR2577 mEgCIR0801 mEgCIR3477 mEgCIR3775 mEgCIR0059 mEgCIR0795 mEgCIR3557 mEgCIR3691 mEgCIR3828 mEgCIR3902 mEgCIR3574 mEgCIR2813 mEgCIR3427 mEgCIR3747 mEgCIR3358 mEgCIR3281 mCnCIR105 mCnCIR69 mEgCIR3643 mEgCIR3543 mEgCIR0804 mEgCIR0195 mEgCIR3869 mEgCIR0219 mEgCIR3383 mEgCIR0783 mEgCIR0580 mEgCIR0254 mEgCIR3590 mEgCIR0894 mEgCIR3365 mEgCIR3307 mEgCIR0905b mCnCIR146 mEgCIR3389 mCnCIR236 mEgCIR3567 mEgCIR3387 mCnCIR139 mEgCIR0055 mEgCIR2387 mEgCIR2029 mEgCIR3728 mEgCIR3563 mEgCIR0555 mEgCIR0910 mEgCIR3622 mCnCIR192 mEgCIR0246 mEgCIR0886 mEgCIR0439 mEgCIR3711 mEgCIR3808 mEgCIR0778 mEgCIR2291 mEgCIR0774 mEgCIR3376 mEgCIR0163 mCnCIR109 mEgCIR3328 mEgCIR0836 mEgCIR0775 mEgCIR3890 mEgCIR3732 mEgCIR2450 mEgCIR2440 mCnCIRG9 mEgCIR3363 mEgCIR1740 mEgCIR2887 mEgCIR1996 mEgCIR2224 mEgCIR3592 mEgCIR3886 mEgCIR3271 mEgCIR3787 mEgCIR3878 mEgCIR3305 mEgCIR0844 mEgCIR2188 mEgCIR2332 mEgCIR3684 mEgCIR3663 mEgCIR0803 mEgCIR3296 mCnCIRE10 mCnCIRG6 mEgCIR0825 mEgCIR0243 mEgCIR3826 mEgCIR0788 mEgCIR3213 mEgCIR2492 mEgCIR2628 mEgCIR3519 mEgCIR0146 mEgCIR2020 mEgCIR0433 mEgCIR0366 mEgCIR3321 mEgCIR0446 mEgCIR0445 mEgCIR3785 mEgCIR3696 mEgCIR3739 mEgCIR0878 mEgCIR3362 mEgCIR3587 mEgCIR3755 mEgCIR3293 mEgCIR2110 mEgCIR3653 mEgCIR0192 mEgCIR3766 mEgCIR1977 mEgCIR3382 mEgCIR0067 mEgCIR2414 mEgCIR1730 mCnCIRB5 mEgCIR3672 mEgCIR2433 mEgCIR2525 mEgCIR2422 mEgCIR2621 mEgCIR0827 mEgCIR1773 mEgCIR0906 mEgCIR0465 mEgCIR3825 mEgCIR3538 mEgCIR0790 mEgCIR3311 mEgCIR3555 mEgCIR2569 mEgCIR0832 mCnCIR38 mEgCIR2212 mEgCIR3399 mEgCIR3569 mEgCIR3350 mEgCIR0779 mEgCIR2427 mCnCIR124 mEgCIR3546 mEgCIR3607 mEgCIR0772 mEgCIR0588 mEgCIR3633 mEgCIR1492 mEgCIR0037 mEgCIR0781 mEgCIR2409 mEgCIR3346 mEgCIR0177 mEgCIR0409 mEgCIR2670 mEgCIR3593 mEgCIR3727 mEgCIR3737 mEgCIR3655 mEgCIR3534 mEgCIR3718 mEgCIR2144 mEgCIR2860 mEgCIR2590 mEgCIR0521 mEgCIR3295 mEgCIR2380 mEgCIR0773 mEgCIR0230 mEgCIR1729 mEgCIR3292 mEgCIR3433 mEgCIR3402 mEgCIR3745 mEgCIR3639 mEgCIR0353 mEgCIR3298 mEgCIR2436 mEgCIR3750 mEgCIR0782 mEgCIR0905a
*typeMark
1 1 1 1 1 1 1 1 1 1 1 1 3 2 2 5 4 3 2 1 1 4 2 2 5 2 4 5 5 5 5 1 1 5 2 2 4 1 5 1 5 1 4 1 1 5 1 1 2 2 5 1 1 1 4 1 1 1 5 1 1 4 2 5 5 5 4 5 5 5 4 5 5 4 5 1 5 2 1 1 4 5 5 4 4 1 1 1 1 5 1 2 3 2 1 1 1 1 1 1 1 1 1 5 2 2 5 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 5 2 4 1 5 1 5 2 5 4 5 4 4 4 5 2 2 1 2 5 4 4 4 5 1 1 5 2 5 5 4 5 4 5 1 5 1 4 5 5 1 2 1 5 2 2 5 5 5 2 2 5 1 1 5 1 1 1 1 1 1 1 1 1 1 2 2 5 1 1 5 4 1 5 5 4 1 5 2 5 4 1 1 5 4 2 1 1 5 5 1 5 1 4 1 4 4 2 5 4 5 4 2 5 4 1 1 5 1 5 5 5 1 5 2 4 1 5 4 5 4 1 5 5
*phaseMark
5 2 2 5 2 2 5 5 2 2 2 2 4 7 7 1 1 1 7 5 2 4 8 8 3 7 6 1 3 3 3 2 2 1 7 8 1 5 3 5 4 2 6 5 2 1 5 5 8 7 1 5 2 5 1 2 2 2 6 5 2 4 8 3 6 6 1 3 3 4 3 6 3 6 1 5 4 7 5 5 3 3 6 1 1 5 5 2 5 1 2 8 4 8 2 2 2 2 5 5 2 2 2 1 7 8 1 1 4 2 5 5 5 2 5 2 2 2 5 2 2 5 5 5 6 6 7 6 2 1 5 3 8 4 4 6 6 4 4 3 8 8 2 7 3 3 6 6 4 5 2 4 7 1 1 6 1 6 1 2 4 2 1 6 3 5 8 2 6 8 7 6 1 1 8 8 3 5 2 4 2 5 5 5 2 2 5 2 5 2 7 8 4 2 2 3 6 2 4 1 6 2 4 7 3 4 5 5 1 4 7 5 5 4 6 2 1 2 1 5 4 1 7 1 4 6 3 8 6 6 5 2 1 2 3 6 4 5 4 8 3 2 4 6 3 4 5 4 1
*ratio
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*nameChrom
groupLG1
*distances
18.7 17.9 19.2 13.4 8.1 11.1 4.8 11.9 11.3 6.4 13.0 2.4 4.8 2.6 2.1 7.0 7.6 12.5 19.1 9.3 18.9 15.6 2.4 10.6 27.0 17.4 11.9 10.3 13.0 5.9 2.2 11.2 14.5 3.6 5.3 15.0 1.1 2.3 1.6 3.1 5.2 19.7 7.8 3.9 3.0 1.9 4.6 18.7 11.7 14.9 18.3 13.1 4.3 18.9 19.2 18.4 15.2 12.2 11.1 1.7 5.0 10.4 9.4 10.5 15.2 1.9 17.2 8.8 12.3 6.1 12.2 15.3 2.9 15.6 19.1 3.4 17.4 10.5 14.7 5.4 5.5 10.7 7.4 10.8 14.8 19.3 11.1 18.3 18.9 5.4 16.1 15.1 11.9 7.0 10.4 4.6 3.8 13.6 1.8 1.6 6.1 16.3 13.1 15.9 5.2 4.2 9.8 5.1 6.0 6.4 9.3 1.5 17.2 5.1 18.1 17.3 4.4 11.8 13.8 13.5 17.9 10.4 12.9 19.5 19.9 0.7 0.6 10.9 17.3 1.5 15.2 19.8 12.4 14.4 14.2 14.1 6.7 10.4 3.3 19.3 1.5 16.8 2.9 11.9 19.1 9.0 17.9 4.4 1.6 8.8 1.6 13.4 14.1 2.0 7.1 11.2 3.3 10.4 16.9 13.0 19.7 19.3 16.1 18.8 5.5 18.3 7.5 3.5 5.1 18.1 8.8 1.7 4.7 8.1 17.4 23.6 18.9 17.7 4.7 18.4 4.2 12.3 12.6 5.8 12.2 5.3 3.2 18.3 17.7 8.3 6.1 8.3 2.3 13.5 1.2 11.6 16.4 5.3 16.1 15.0 1.0 19.3 11.4 17.4 17.0 16.0 10.9 19.7 17.0 7.4 15.6 12.6 8.1 2.2 11.3 13.1 19.8 6.3 4.9 9.3 12.1 7.5 8.6 17.2 6.2 3.7 5.7 19.2 19.1 18.7 9.1 6.5 17.9 4.7 4.0 16.3 12.6 5.2 6.5 1.9 10.8 12.9 1.3 14.4 16.8 8.4 11.1 8.3
*phenoMark
2 2 1 2 1 1 2 2 1 1 1 1 0 1 1 10 0 0 1 1 2 2 2 2 12 0 11 10 12 13 12 1 1 12 2 1 10 2 10 2 0 2 11 1 2 13 1 1 2 1 11 1 2 1 0 2 2 2 12 1 2 1 2 13 12 12 2 13 13 10 11 12 13 10 0 1 12 2 1 2 1 10 11 10 1 0 2 1 2 11 1 1 0 1 1 1 1 1 2 0 1 1 1 10 2 1 12 0 11 1 2 2 2 0 2 1 1 1 2 1 1 2 2 2 11 13 1 11 1 10 2 12 2 11 2 13 11 2 2 12 2 2 1 1 12 10 0 11 11 2 1 10 2 13 11 0 11 10 11 2 10 2 2 12 0 1 2 0 12 1 2 11 12 12 2 2 0 2 1 11 1 2 1 0 2 0 1 2 0 0 1 2 11 1 1 13 10 2 10 10 11 1 11 1 12 0 0 0 0 2 1 2 1 10 12 1 10 1 1 2 2 10 2 13 11 11 1 1 11 0 2 0 12 1 0 11 12 1 12 2 11 2 10 0 13 1 1 10 13
GCC_VERSION=-4.9
CXX=g++$(GCC_VERSION)
CXXARGS=--std=gnu++0x -Wall -Wno-unused-local-typedefs
COV=gcov$(GCC_VERSION)
INC=-I../include -I../include/input -I/usr/local/include/eigen3
LD=$(CXX)
LIBS=-lexpat
VERSION_DEFINES=$(shell git tag | sed 's/\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)/-DVERSION_MAJOR=\\\"\1\\\" -DVERSION_MINOR=\\\"\2\\\" -DVERSION_PATCH=\\\"\3\\\"/')
C=$(CXX) $(CXXARGS) $(INC) -DTEST_POLY $(VERSION_DEFINES)
SRC=main.cc fast_polynom.cc markov_population.cc ../src/input/read_map.cc ../src/outbred.cc ../src/probapop_dtd.cc ../src/input/invoke_probapop.cc ../src/algebraic_genotype.cc
OBJ=$(subst .cc,.o,$(SRC))
DEBUG_OPTS=-gdwarf-2 -gstrict-dwarf -Winvalid-pch
OPT_OPTS=-O3 -DEIGEN_NO_DEBUG -DNDEBUG
COV_OPTS=-g -fprofile-arcs -ftest-coverage
COV_OPTS=$(DEBUG_OPTS) --coverage
PROF_OPTS=-pg -O
INFO_FILE=test-coverage.info
#C=$(CXX) $(CXXARGS) $(INC) $(DEBUG_OPTS)
C=$(CXX) $(CXXARGS) $(INC) $(DEBUG_OPTS) $(PROF_OPTS) $(VERSION_DEFINES) $(COV_OPTS)
#C=$(CXX) $(CXXARGS) $(INC) $(OPT_OPTS) $(VERSION_DEFINES)
all: test_suite
include .depend
pch: $(PCH)
$(PCH):%.h.gch: %.h Makefile
$C $<
test_suite: $(OBJ)
$C $(OBJ) -o $@ $(LIBS)
test: test_suite
./$<
zerocounters:
lcov --zerocounters --directory .
test-coverage: zerocounters test
lcov --gcov-tool $(COV) --no-checksum --directory . --capture --output-file $(INFO_FILE)
lcov --remove $(INFO_FILE) "/usr*" -o $(INFO_FILE)
lcov --remove $(INFO_FILE) "catch.hpp" -o $(INFO_FILE)
genhtml --highlight --legend --output-directory TestCodeCoverage $(INFO_FILE)
.depend: $(SRC) Makefile
$C --depend $(SRC) > $@
$(OBJ):%.o: %.cc
$C -c $< -o $@
clean:
rm -f $(OBJ) *.gcno *.gcda
opt-tests: $(SRC)
$(CXX) $(CXXARGS) $(INC) $(OPT_OPTS) $(VERSION_DEFINES) $(SRC) $(LIBS) -o $@
#g++-4.9 --std=gnu++0x -Wall -Wno-unused-local-typedefs -I../include -I../include/input -I/usr/local/include/eigen3 -gdwarf-2 -gstrict-dwarf -Winvalid-pch -DVERSION_MAJOR=\"0\" -DVERSION_MINOR=\"0\" -DVERSION_PATCH=\"0\" main.o fast_polynom.o markov_population.o -o test_suite -lexpat
#markov_population.o: In function `from_argv_outbred(int, char const* const*, double&)':
#/media/Stock/devel/MCQTL/v6/tests/markov_population.cc:110: undefined reference to `read_data::read_map(std::istream&)'
#/media/Stock/devel/MCQTL/v6/tests/markov_population.cc:112: undefined reference to `read_data::read_outbred(std::istream&)'
#markov_population.o: In function `test_segment(int, char const* const*)':
#/media/Stock/devel/MCQTL/v6/tests/markov_population.cc:255: undefined reference to `test_probapop(chromosome const&, marker_data const&, double)'
#markov_population.o: In function `test_segment_outbred(int, char const* const*)':
#/media/Stock/devel/MCQTL/v6/tests/markov_population.cc:328: undefined reference to `test_probapop(chromosome const&, marker_data const&, double)'
#markov_population.o: In function `algebraic_genotype::operator*(algebraic_genotype) const':
#/media/Stock/devel/MCQTL/v6/tests/../include/algebraic_genotype.h:561: undefined reference to `algebraic_genotype::null'
#/media/Stock/devel/MCQTL/v6/tests/../include/algebraic_genotype.h:613: undefined reference to `algebraic_genotype::null'
#/media/Stock/devel/MCQTL/v6/tests/../include/algebraic_genotype.h:657: undefined reference to `algebraic_genotype::null'
#collect2: error: ld returned 1 exit status
#make: *** [test_suite] Error 1
#include "fast_polynom.h"
#include <iostream>
#include "catch.hpp"
TEST_CASE("degree_and_valuation", "Check some wrappers")
{
impl::polynom_tables::reset();
CHECK(fast_polynom::one.degree() == 0);
CHECK(fast_polynom::zero.degree() == 0);
CHECK(fast_polynom::r.degree() == 1);
CHECK(fast_polynom::s.degree() == 1);
CHECK(fast_polynom::one.valuation() == 0);
CHECK(fast_polynom::zero.valuation() == 0);
CHECK(fast_polynom::r.valuation() == 1);
CHECK(fast_polynom::s.valuation() == 0);
fast_polynom p = {1., 0., 1.};
CHECK(p.degree() == 2);
CHECK(p.valuation() == 0);
fast_polynom q = {0., 0., 0., 1.};
CHECK(q.degree() == 3);
CHECK(q.valuation() == 3);
fast_polynom fs = (const impl::f_polynom&) fast_polynom::s;
fast_polynom fr = (const impl::f_polynom&) fast_polynom::r;
fast_polynom fone = (const impl::f_polynom&) fast_polynom::one;
fast_polynom fzero = (const impl::f_polynom&) fast_polynom::zero;
CHECK(fone.degree() == 0);
CHECK(fzero.degree() == 0);
CHECK(fr.degree() == 1);
CHECK(fs.degree() == 1);
CHECK(fone.valuation() == 0);
CHECK(fzero.valuation() == 0);
CHECK(fr.valuation() == 1);
CHECK(fs.valuation() == 0);
std::cout << p << std::endl;
}
TEST_CASE("basic.reg", "Check all four axiomatic polynoms are correctly registered")
{
impl::polynom_tables::reset();
CHECK(fast_polynom::zero != fast_polynom::one);
CHECK(fast_polynom::zero != fast_polynom::r);
CHECK(fast_polynom::zero != fast_polynom::s);
CHECK(fast_polynom::one != fast_polynom::r);
CHECK(fast_polynom::one != fast_polynom::s);
CHECK(fast_polynom::r != fast_polynom::s);
}
TEST_CASE("adv.reg", "Check new polynoms are correctly registered")
{
impl::polynom_tables::reset();
fast_polynom a = {1., 2., 1.};
fast_polynom b = {1., 1., 1.};
fast_polynom _s = {1., -1.};
CHECK(_s == fast_polynom::s);
CHECK(a != fast_polynom::zero);
CHECK(a != fast_polynom::one);
CHECK(a != fast_polynom::r);
CHECK(a != fast_polynom::s);
CHECK(b != fast_polynom::zero);
CHECK(b != fast_polynom::one);
CHECK(b != fast_polynom::r);
CHECK(b != fast_polynom::s);
CHECK(a != b);
}
TEST_CASE("basic.add", "Check simple additions of axiomatic polynoms")
{
impl::polynom_tables::reset();
/*std::cout << "Add table" << std::endl << impl::polynom_tables::add_table() << std::endl;*/
fast_polynom _2s = {2., -2.};
std::cout << ((const impl::d_polynom&) _2s) << std::endl;
std::cout << ((const impl::f_polynom&) _2s) << std::endl;
/*std::cout << "Add table" << std::endl << impl::polynom_tables::add_table() << std::endl;*/
fast_polynom _2r = {0., 2.};
/*std::cout << "Add table" << std::endl << impl::polynom_tables::add_table() << std::endl;*/
fast_polynom a = fast_polynom::r + fast_polynom::r;
/*std::cout << "Add table" << std::endl << impl::polynom_tables::add_table() << std::endl;*/
fast_polynom b = fast_polynom::s + fast_polynom::s;
/*std::cout << "Add table" << std::endl << impl::polynom_tables::add_table() << std::endl;*/
/*std::cout << "fb " << ((const impl::f_polynom&) b) << std::endl;*/
/*std::cout << "db " << ((const impl::d_polynom&) b) << std::endl;*/
CHECK((fast_polynom::r + fast_polynom::s) == fast_polynom::one);
CHECK((fast_polynom::zero + fast_polynom::zero) == fast_polynom::zero);
CHECK((fast_polynom::one + fast_polynom::zero) == fast_polynom::one);
CHECK((fast_polynom::r + fast_polynom::zero) == fast_polynom::r);
CHECK((fast_polynom::s + fast_polynom::zero) == fast_polynom::s);
CHECK(_2r == a);
CHECK(_2s == b);
fast_polynom _s = {1., -1.};
CHECK(_s == fast_polynom::s);
fast_polynom __2s = _s + _s;
CHECK(__2s == _2s);
CHECK((fast_polynom::r + fast_polynom::s) == (fast_polynom::s + fast_polynom::r));
}
TEST_CASE("more.add", "Check more additions")
{
fast_polynom p;
p = fast_polynom::s + fast_polynom::s;
p += fast_polynom::s;
CHECK((p == fast_polynom{3., -3.}));
/*std::cout << p << " " << ((const impl::f_polynom&)p) << std::endl;*/
p = fast_polynom::s + fast_polynom::s;
p += fast_polynom::r;
CHECK((p == fast_polynom{2., -1.}));
/*std::cout << p << " " << ((const impl::f_polynom&)p) << std::endl;*/
}
TEST_CASE("adv.ops", "Check more combinations")
{
fast_polynom p;
p = fast_polynom::s * fast_polynom::s + fast_polynom::r.pow(3);
/*std::cout << p << " " << ((const impl::f_polynom&)p) << std::endl;*/
CHECK((p == fast_polynom{1. , -2., 1., 1.}));
p = fast_polynom::s * fast_polynom::s + fast_polynom::r.pow(3) - fast_polynom::s;
/*std::cout << p << " " << ((const impl::f_polynom&)p) << std::endl;*/
CHECK((p == fast_polynom{0 , -1., 1., 1.}));