Commit 98be4b2f authored by Damien Leroux's avatar Damien Leroux
Browse files

New features, bugfixes, itś a big mess, but it works.

parent 19488f00
......@@ -73,10 +73,10 @@ $(OBJ):%.o: %.cc
$C -c $< -o $@
test_graph: test_graph.cc ../static_data.o ../../include/bayes/graphnode.h
$C -O0 -ggdb $< ../static_data.o -o $@
$C -O0 -ggdb $< ../static_data.o -o $@ -lgmp
generalized_product.debug: generalized_product.cc ../static_data.o ../../include/bayes/generalized_product.h ../../include/bayes/graphnode2.h ../../include/bayes/graphnode_base.h
$C -pg -O0 -ggdb $< ../static_data.o -o $@
$C -pg -O0 -ggdb $< ../static_data.o -o $@ -lgmp
generalized_product: generalized_product.cc ../static_data.o ../../include/bayes/generalized_product.h ../../include/bayes/graphnode2.h ../../include/bayes/graphnode_base.h
$C $< ../static_data.o -o $@
$C $< ../static_data.o -o $@ -lgmp
......@@ -92,7 +92,7 @@ struct worker_local_sge : public worker_base {
if (!fifo || errno) {
MSG_ERROR("An error occurred while trying to notify the master process: " << strerror(errno), "");
}
std::string msg = MESSAGE((ok ? "\fS " : "\fF ") << i << std::endl);
std::string msg = SPELL_STRING((ok ? "\fS " : "\fF ") << i << std::endl);
fwrite(msg.c_str(), msg.size(), 1, fifo);
if (ferror(fifo)) {
MSG_ERROR("An error occurred while trying to notify the master process: " << strerror(errno), "");
......
......@@ -16,6 +16,7 @@
*/
#define SPELL_UNSAFE_OUTPUT
#include "error.h"
#include "bayes/generalized_product.h"
/*#include "graphnode.h"*/
#include "graphnode2.h"
......@@ -346,7 +347,7 @@ struct random_test {
}
MSG_QUEUE_FLUSH();
msg_handler_t::restore();
CREATE_MESSAGE(msg_channel::Out, SPELL_STRING(good << " good, " << failed << " bad, old took " << old_time << "s, new took " << new_time << "s, speedup is " << (old_time / new_time) << "x \r"));
MSG_INFO(good << " good, " << failed << " bad, old took " << old_time << "s, new took " << new_time << "s, speedup is " << (old_time / new_time) << "x \r");
}
}
......@@ -380,7 +381,7 @@ struct random_test {
}
MSG_QUEUE_FLUSH();
msg_handler_t::restore();
CREATE_MESSAGE(msg_channel::Out, SPELL_STRING(good << " good, " << failed << " bad, old took " << old_time << "s, new took " << new_time << "s \r"));
MSG_INFO(good << " good, " << failed << " bad, old took " << old_time << "s, new took " << new_time << "s \r");
}
}
};
......@@ -470,6 +471,7 @@ int
main(int argc, char** argv)
{
msg_handler_t::set_color(true);
msg_handler_t::debug_enabled() = true;
#if 0
std::map<std::vector<int>, genotype_comb_type> domains;
......@@ -571,11 +573,11 @@ main(int argc, char** argv)
MSG_DEBUG("F4 * F5 (squeeze F4) size " << factors[100].size());
MSG_DEBUG("F4 * F5 * F6 (squeeze F4&F5) size " << factors[101].size());
#endif
#if 0
#if 1
std::unique_ptr<factor_graph_type> g;
if (argc == 1) {
g = factor_graph_type::from_pedigree(read_csv("random.ped", ';'), 2, {}, {}/*, "boiboite"*/);
g = factor_graph_type::from_pedigree(read_csv("random.ped", ';'), 2, true, {}, {}/*, "boiboite"*/);
g->to_image("boiboite", "png");
/*g.dump_active();*/
......@@ -583,7 +585,7 @@ main(int argc, char** argv)
/*g.to_image("boiboite12", "png");*/
/*g.dump_active();*/
g = factor_graph_type::from_pedigree(read_csv("/home/daleroux/devel/spel/sample-data/data_magic/pedigree_clean_DH.csv", ';'), 1, {"Cervil", "Levovil", "Criollo", "Stupicke", "Plovdiv", "LA1420", "Ferum", "LA0147", "ICS3"}, {"ICS3"});
g = factor_graph_type::from_pedigree(read_csv("/home/daleroux/devel/spel/sample-data/data_magic/pedigree_clean_DH.csv", ';'), 1, true, {"Cervil", "Levovil", "Criollo", "Stupicke", "Plovdiv", "LA1420", "Ferum", "LA0147", "ICS3"}, {"ICS3"});
g->to_image("magic-dh", "png");
/*g = graph_type::from_pedigree(read_csv("/home/daleroux/devel/spel/sample-data/data_magic/pedigree_clean-norepeat.csv", ';'), 1, {}, {});*/
......@@ -615,25 +617,25 @@ main(int argc, char** argv)
{
std::stringstream(argv[2]) >> n_al;
}
MSG_DEBUG("[args] Pedigree: " << pedfile);
MSG_DEBUG("[args] Prefix: " << prefix);
MSG_DEBUG("[args] In: " << in);
MSG_DEBUG("[args] Out: " << out);
MSG_INFO("[args] Pedigree: " << pedfile);
MSG_INFO("[args] Prefix: " << prefix);
MSG_INFO("[args] In: " << in);
MSG_INFO("[args] Out: " << out);
/*g = graph_type::from_pedigree(read_csv(pedfile, ';'), 2, in, out);*/
/*g.to_image(MESSAGE(prefix << "-pre-optim"), "png");*/
/*g.to_image(SPELL_STRING(prefix << "-pre-optim"), "png");*/
/*g.optimize();*/
/*g.to_image(prefix, "png");*/
g = factor_graph_type::from_pedigree(filter_pedigree(read_csv(pedfile, ';'), in, out), n_al, in, out/*, MESSAGE("debug-" << prefix)*/);
g = factor_graph_type::from_pedigree(filter_pedigree(read_csv(pedfile, ';'), in, out), n_al, true, in, out/*, SPELL_STRING("debug-" << prefix)*/);
/*g->build_subgraphs();*/
g->dump();
/*g->to_image(MESSAGE(prefix << "-filtered-pre-optim"), "png");*/
/*g->to_image(SPELL_STRING(prefix << "-filtered-pre-optim"), "png");*/
/*g->dump_active();*/
/*g->optimize();*/
/*MSG_DEBUG("Creating png...");*/
g->to_image(MESSAGE(prefix << "-filtered"), "png");
MSG_DEBUG("Creating instance...");
/*MSG_INFO("Creating png...");*/
g->to_image(SPELL_STRING(prefix << "-filtered"), "png");
MSG_INFO("Creating instance...");
auto I = instance(g);
ofile of(MESSAGE(prefix << "-instance.data"));
ofile of(SPELL_STRING(prefix << "-instance.data"));
I->file_io(of);
rw_comb<int, bn_label_type>()(of, g->domains);
#if 1
......@@ -643,15 +645,15 @@ main(int argc, char** argv)
ifile ifs(pedfile);
I->file_io(ifs);
rw_comb<int, bn_label_type>()(ifs, domains);
MSG_DEBUG("Computing messages....");
MSG_INFO("Computing messages....");
auto ret = I->compute(0, domains);
MSG_DEBUG("MESSAGES");
MSG_INFO("MESSAGES");
for (const auto& kv: I->message_index) {
MSG_DEBUG(std::setw(4) << kv.first.first << " -> " << std::setw(4) << kv.first.second << " == " << I->messages[kv.second]);
MSG_INFO(std::setw(4) << kv.first.first << " -> " << std::setw(4) << kv.first.second << " == " << I->messages[kv.second]);
}
MSG_DEBUG("OUTPUT");
MSG_INFO("OUTPUT");
for (const auto& t: ret) {
MSG_DEBUG("" << t);
MSG_INFO("" << t);
}
#endif
}
......@@ -830,3 +832,4 @@ main(int argc, char** argv)
(void) argc; (void) argv;
}
#include "output_impl.h"
......@@ -62,7 +62,7 @@ dispatch_geno_probs(
std::map<size_t, std::vector<double>>& state_prob) /* all computed locus vectors to fetch the parents' states */
{
/*
scoped_indent _(MESSAGE("[dispatchGP] "));
scoped_indent _(SPELL_STRING("[dispatchGP] "));
MSG_DEBUG("ind " << ind);
MSG_DEBUG("lc " << lc);
MSG_DEBUG("labels " << labels);
......@@ -199,7 +199,7 @@ job_registry = {
/*fg.finalize();*/
/*fg.save(settings->job_filename("factor-graph", unique_n_alleles[n]));*/
/*fg->dump();*/
//fg->to_image(MESSAGE("factor-graph-" << unique_n_alleles[n]), "png");
//fg->to_image(SPELL_STRING("factor-graph-" << unique_n_alleles[n]), "png");
auto I = instance(fg);
ofile of(filename);
I->file_io(of);
......
......@@ -96,7 +96,7 @@ void dump_mat(const generation_rs* grs)
auto probs = sc.compute(LV);
/*MSG_DEBUG("############# " << m1 << m2 << m3);*/
/*MSG_DEBUG(probs.transpose());*/
ofile o(MESSAGE("spell_" << grs->name << '_' << m1 << m2 << m3 << ".txt"));
ofile o(SPELL_STRING("spell_" << grs->name << '_' << m1 << m2 << m3 << ".txt"));
o << probs.transpose();
}
}
......
......@@ -40,7 +40,7 @@ std::pair<bool, double>
detect_strongest_qtl(chromosome_value chr, const locus_key& lk, double threshold,
const model& M0, const std::vector<double> pos)
{
active_settings->set_title(MESSAGE("QTL detection along chromosome " << chr->name << " given " << lk));
active_settings->set_title(SPELL_STRING("QTL detection along chromosome " << chr->name << " given " << lk));
/*MatrixXd ftac = ftest_along_chromosome(chr, lk, M0, pos);*/
int max = max_col(ftac);
return {ftac(0, max) >= threshold, pos[max]};
......@@ -243,7 +243,7 @@ in_history(std::set<std::map<chromosome_value, locus_key>>& history, const std::
bool
iqtlm_backward(std::string algo_suffix, model_manager& mm, std::set<std::map<chromosome_value, locus_key>>& history)
{
report_algo_phase(MESSAGE("iQTLm" << algo_suffix << " backward"));
report_algo_phase(SPELL_STRING("iQTLm" << algo_suffix << " backward"));
// DUMP_FILE_LINE();
while (iqtlm_backward_one(mm)) {
// DUMP_FILE_LINE();
......@@ -422,7 +422,7 @@ qtl_detect_iqtlm(model_manager& mm)
};
for (const chromosome& chr: active_settings->map) {
active_settings->set_title(MESSAGE("iQTLm on " << chr.name));
active_settings->set_title(SPELL_STRING("iQTLm on " << chr.name));
try {
/* setup */
......@@ -446,7 +446,7 @@ qtl_detect_iqtlm(model_manager& mm)
for (double l: *loci) {
auto tmp_removed = mm.remove(l);
/*mm.add_test_locus(&chr, l);*/
active_settings->set_title(MESSAGE("iQTLm on " << chr.name << " checking locus " << l << " against " << mm.keys()));
active_settings->set_title(SPELL_STRING("iQTLm on " << chr.name << " checking locus " << l << " against " << mm.keys()));
result = mm.test_along_chromosome(0, mm.max_testpos());
MSG_DEBUG(result);
if (result.over_threshold) {
......@@ -479,7 +479,7 @@ qtl_detect_iqtlm(model_manager& mm)
/* step 2: forward */
if (!check_loops(&chr)) {
active_settings->set_title(MESSAGE("iQTLm on " << chr.name << " forward"));
active_settings->set_title(SPELL_STRING("iQTLm on " << chr.name << " forward"));
MSG_INFO("[iQTLm] Forward");
do {
result = mm.test_along_chromosome(0, mm.max_testpos());
......
......@@ -111,9 +111,9 @@ analysis_report_computations::prepare_qtls(std::vector<QTL> &qtls, ComputationTy
// descr.outer_interval_start, descr.outer_interval_end) = qtl.confidence_interval();
roi[qtl.chromosome][qtl.locus] = {descr.outer_interval_start, descr.outer_interval_end};
// report_lod(qtl);
std::string name = MESSAGE(mm.trait_name << " @ " << qtl.locus << " [" << descr.outer_interval_start << ':' << descr.outer_interval_end << ']');
std::string name = SPELL_STRING(mm.trait_name << " @ " << qtl.locus << " [" << descr.outer_interval_start << ':' << descr.outer_interval_end << ']');
if (poi[qtl.chromosome][qtl.locus].size()) {
poi[qtl.chromosome][qtl.locus] = MESSAGE(poi[qtl.chromosome][qtl.locus] << ',' << name);
poi[qtl.chromosome][qtl.locus] = SPELL_STRING(poi[qtl.chromosome][qtl.locus] << ',' << name);
} else {
poi[qtl.chromosome][qtl.locus] = name;
}
......@@ -184,7 +184,7 @@ analysis_report_computations::contrasts(const MatrixXd& conmat, const MatrixXd&
std::string l1(labels[i1].begin(), labels[i1].end());
for (int i2 = i1 + 1; i2 < (int) labels.size(); ++i2) {
std::string l2(labels[i2].begin(), labels[i2].end());
std::string contrast_pair = MESSAGE(l1 << " - " << l2);
std::string contrast_pair = SPELL_STRING(l1 << " - " << l2);
int a1 = columns[i1];
int a2 = columns[i2];
......@@ -192,7 +192,7 @@ analysis_report_computations::contrasts(const MatrixXd& conmat, const MatrixXd&
double delta = coef(a1) - coef(a2);
normal s(0, sigma > 0 ? sqrt(sigma) : 1.e-9);
double pvalue = 2 * cdf(complement(s, fabs(delta)));
ret.emplace_back(contrast_description{MESSAGE(key), contrast_group.str(), contrast_pair, delta, pvalue, significance_level(pvalue)});
ret.emplace_back(contrast_description{SPELL_STRING(key), contrast_group.str(), contrast_pair, delta, pvalue, significance_level(pvalue)});
}
}
}
......@@ -285,7 +285,7 @@ analysis_report::report_computation(model& Mbase, std::string chrom, std::string
include_data<MatrixXd, &computation_along_chromosome::rss, true>(c, colnames, values, "RSS", cac);
m_stream.mode(ReportMode::LOD);
select_book("computations").select_sheet(MESSAGE("computation " << m_selection_index));
select_book("computations").select_sheet(SPELL_STRING("computation " << m_selection_index));
m_stream
.matrix(values, colnames);
select_previous_book();
......@@ -318,9 +318,9 @@ analysis_report::report_algo_selection(model& Mbase, std::string chrom, double s
select_book("algo_trace").select_sheet("Computations");
auto X = mm.vMcurrent->printable_X();
m_stream
.selection(m_selection_index, chrom, MESSAGE(Mbase.keys()), score, locus, threshold);
.selection(m_selection_index, chrom, SPELL_STRING(Mbase.keys()), score, locus, threshold);
// if (m_what & AR::Model) {
select_book("algo_trace").select_sheet(MESSAGE(m_selection_index << " M0"));
select_book("algo_trace").select_sheet(SPELL_STRING(m_selection_index << " M0"));
m_stream
.matrix("", Mbase.printable_X());
// }
......@@ -333,8 +333,8 @@ inline
analysis_report&
analysis_report::report_model(const model& Mcurrent)
{
std::string modelx = MESSAGE("Final model X");
std::string modelxtx = MESSAGE("Final model XtX");
std::string modelx = SPELL_STRING("Final model X");
std::string modelxtx = SPELL_STRING("Final model XtX");
m_stream.mode(ReportMode::Model);
select_book("models");
select_sheet(modelx);
......@@ -388,9 +388,9 @@ void make_report(model_manager& mm, const std::vector<std::string>& cmdline)
.line(std::vector<std::string>{"Date", (std::strftime(mbstr, sizeof(mbstr), "%A %c", std::localtime(&t)) ? mbstr : "")})
.line(std::vector<std::string>{"Command line", cmd.str()})
.line(std::vector<std::string>{"Version", VERSION_MAJOR "." VERSION_MINOR "." VERSION_PATCH})
.line(std::vector<std::string>{"Cores used", MESSAGE(active_settings->parallel)})
.line(std::vector<std::string>{"Cores used", SPELL_STRING(active_settings->parallel)})
.line()
.header(MESSAGE("Report for " << (TM.dim_names.size() > 1 ? "pleiotropic" : "single") << " trait " << mm.trait_name))
.header(SPELL_STRING("Report for " << (TM.dim_names.size() > 1 ? "pleiotropic" : "single") << " trait " << mm.trait_name))
.line()
.report_qtls()
.line();
......@@ -403,8 +403,8 @@ void make_report(model_manager& mm, const std::vector<std::string>& cmdline)
for (int i = 0; i < (int) TM.dim_names.size(); ++i) {
std::string title;
if (TM.dim_names.size() > 1) {
// section_header(report_file, MESSAGE(mm.trait_name << " # " << TM.dim_names[i]));
title = MESSAGE(mm.trait_name << " # " << TM.dim_names[i]);
// section_header(report_file, SPELL_STRING(mm.trait_name << " # " << TM.dim_names[i]));
title = SPELL_STRING(mm.trait_name << " # " << TM.dim_names[i]);
} else {
// section_header(report_file, mm.trait_name);
title = mm.trait_name;
......@@ -433,7 +433,7 @@ void make_report(model_manager& mm, const std::vector<std::string>& cmdline)
// auto contrasts = report.contrasts(conmat, vcov, coef);
// auto L = significance_legend();
// for (const auto& descr: contrasts) {
// report.line(std::vector<std::string>{descr.key, descr.contrast_group, descr.contrast_pair, MESSAGE(descr.value), MESSAGE(descr.significance_value), L.labels[descr.significance_level]});
// report.line(std::vector<std::string>{descr.key, descr.contrast_group, descr.contrast_pair, SPELL_STRING(descr.value), SPELL_STRING(descr.significance_value), L.labels[descr.significance_level]});
// }
/*
for (int r = 0; r < conmat.rows(); ++r) {
......
......@@ -474,7 +474,7 @@ struct sim_data_map {
sim_data_map(const std::string& base_dir)
: data(), counts(0)
{
auto filelist = globVector(MESSAGE(base_dir << "/*/*/*/*.txt"));
auto filelist = globVector(SPELL_STRING(base_dir << "/*/*/*/*.txt"));
std::regex path_info(".*/counts_([0-9]+)/([0-9]+)/([0-9]+)/([a-zA-Z]{3}).txt", std::regex_constants::extended);
MSG_DEBUG("Reading " << filelist.size() << " files...");
for (const auto& path: filelist) {
......
......@@ -285,7 +285,7 @@ main(int argc, const char** argv)
/*std::map<std::string, std::map<double, std::string>> poi;*/
/*std::map<std::string, std::map<double, std::pair<double, double>>> roi;*/
// analysis_report ar(MESSAGE(active_settings->work_directory << '/' << active_settings->name << ".report"), AR::All);
// analysis_report ar(SPELL_STRING(active_settings->work_directory << '/' << active_settings->name << ".report"), AR::All);
try {
......@@ -543,7 +543,7 @@ main(int argc, const char** argv)
for (const auto& qtl: QTLs) {
if (poi[qtl.chromosome][qtl.locus].size()) {
poi[qtl.chromosome][qtl.locus] = MESSAGE(poi[qtl.chromosome][qtl.locus] << ',' << trait_pops.first);
poi[qtl.chromosome][qtl.locus] = SPELL_STRING(poi[qtl.chromosome][qtl.locus] << ',' << trait_pops.first);
} else {
poi[qtl.chromosome][qtl.locus] = trait_pops.first;
}
......@@ -555,7 +555,7 @@ main(int argc, const char** argv)
for (const auto& chr_lk: mbk.first.selection) {
for (double l: chr_lk.second) {
if (poi[chr_lk.first->name][l].size()) {
poi[chr_lk.first->name][l] = MESSAGE(poi[chr_lk.first->name][l] << ',' << trait_pops.first);
poi[chr_lk.first->name][l] = SPELL_STRING(poi[chr_lk.first->name][l] << ',' << trait_pops.first);
} else {
poi[chr_lk.first->name][l] = trait_pops.first;
}
......
......@@ -1440,7 +1440,7 @@ std::ostream& operator << (std::ostream& os, const std::map<label_type, double>&
{
os << "abundances:";
for (const auto& kv: ab) {
os << ' ' << kv.first << ": " << std::left << std::setw(12) << MESSAGE((kv.second * 100.) << '%');
os << ' ' << kv.first << ": " << std::left << std::setw(12) << SPELL_STRING((kv.second * 100.) << '%');
}
return os;
}
......@@ -1489,7 +1489,7 @@ MatrixXd test_geno_matrix(const std::string& name, geno_matrix& GEN)
/*A << 1, 0, 0, 0;*/
/*H << 0, 1, 1, 0;*/
/*B << 0, 0, 0, 1;*/
ofile ofs(MESSAGE("values-HA." << name << ".txt"));
ofile ofs(SPELL_STRING("values-HA." << name << ".txt"));
MatrixXd abundance = GEN.lim_inf().col(0);
/*MSG_DEBUG("### " << name);*/
......@@ -1624,15 +1624,15 @@ int main(int argc, char** argv)
MSG_DEBUG(std::setw(5) << i
<< " | "
<< WHITE
<< std::setw(70) << MESSAGE(BCn.cols() << ' ' << abundances(BCn) << " e=0")
<< std::setw(70) << SPELL_STRING(BCn.cols() << ' ' << abundances(BCn) << " e=0")
<< NORMAL
<< " | "
<< (abundances(BCn) == abundances(BCa) ? GREEN : YELLOW)
<< std::setw(70) << MESSAGE(BCa.cols() << ' ' << abundances(BCa) << " e=" << ntoa)
<< std::setw(70) << SPELL_STRING(BCa.cols() << ' ' << abundances(BCa) << " e=" << ntoa)
<< NORMAL
<< " | "
<< (abundances(BCn) == abundances(BCa2) ? GREEN : YELLOW)
<< std::setw(70) << MESSAGE(BCa2.cols() << ' ' << abundances(BCa2) << " e=" << ntoa2)
<< std::setw(70) << SPELL_STRING(BCa2.cols() << ' ' << abundances(BCa2) << " e=" << ntoa2)
<< NORMAL
);
}
......@@ -1659,8 +1659,8 @@ int main(int argc, char** argv)
/*Fa2 = approx_lump(Fn, 32 + i * 4);*/
Fa2 = max_lumping(lump(kronecker(Fa2, selfing_gamete)), 32);
/*auto Mn = test_geno_matrix("", Fn);*/
MatrixXd Mn = load_matrix(MESSAGE("test_geno_matrix_" << i << ".matrix"));
/*save_matrix(Mn, MESSAGE("test_geno_matrix_" << i << ".matrix"));*/
MatrixXd Mn = load_matrix(SPELL_STRING("test_geno_matrix_" << i << ".matrix"));
/*save_matrix(Mn, SPELL_STRING("test_geno_matrix_" << i << ".matrix"));*/
auto Ma = test_geno_matrix("", Fa);
auto Ma2 = test_geno_matrix("", Fa2);
double ntoa = (Mn - Ma).lpNorm<1>();
......@@ -1676,15 +1676,15 @@ int main(int argc, char** argv)
MSG_DEBUG(std::setw(5) << i
<< " | "
<< WHITE
<< std::setw(62) << OPT(MESSAGE(Fn.cols() << ' ' << OPT(abundances(Fn)) << " e=0"))
<< std::setw(62) << OPT(SPELL_STRING(Fn.cols() << ' ' << OPT(abundances(Fn)) << " e=0"))
<< NORMAL
<< " | "
/*<< (abundances(Fn) == abundances(Fa) ? GREEN : YELLOW)*/
<< std::setw(62) << MESSAGE(Fa.cols() << ' ' << OPT(abundances(Fa)) << " e=" << ntoa)
<< std::setw(62) << SPELL_STRING(Fa.cols() << ' ' << OPT(abundances(Fa)) << " e=" << ntoa)
<< NORMAL
<< " | "
/*<< (abundances(Fn) == abundances(Fa2) ? GREEN : YELLOW)*/
<< std::setw(62) << MESSAGE(Fa2.cols() << ' ' << OPT(abundances(Fa2)) << " e=" << ntoa2)
<< std::setw(62) << SPELL_STRING(Fa2.cols() << ' ' << OPT(abundances(Fa2)) << " e=" << ntoa2)
<< NORMAL
);
}
......@@ -1770,7 +1770,7 @@ int main(int argc, char** argv)
auto F = lump_using_partition(F7, P);
/*auto fs = lump(kronecker(F, selfing_gamete), true);*/
/*MSG_DEBUG("TEST SELFING F7-lump" << i << ": " << fs.inf_mat.cols());*/
test_geno_matrix(MESSAGE("F7-lump" << i), F);
test_geno_matrix(SPELL_STRING("F7-lump" << i), F);
}
auto F3a = approx_lump(kronecker(F2, selfing_gamete), (size_t) (F2.cols() * 2));
......
......@@ -1481,7 +1481,7 @@ std::ostream& operator << (std::ostream& os, const std::map<label_type, double>&
{
os << "abundances:";
for (const auto& kv: ab) {
os << ' ' << kv.first << ": " << std::left << std::setw(12) << MESSAGE((kv.second * 100.) << '%');
os << ' ' << kv.first << ": " << std::left << std::setw(12) << SPELL_STRING((kv.second * 100.) << '%');
}
return os;
}
......@@ -1530,7 +1530,7 @@ MatrixXd test_geno_matrix(const std::string& name, geno_matrix& GEN)
/*A << 1, 0, 0, 0;*/
/*H << 0, 1, 1, 0;*/
/*B << 0, 0, 0, 1;*/
ofile ofs(MESSAGE("values-HA." << name << ".txt"));
ofile ofs(SPELL_STRING("values-HA." << name << ".txt"));
MatrixXd abundance = GEN.lim_inf().col(0);
/*MSG_DEBUG("### " << name);*/
......@@ -1718,15 +1718,15 @@ int main(int argc, char** argv)
MSG_DEBUG(std::setw(5) << i
<< " | "
<< WHITE
<< std::setw(70) << MESSAGE(BCn.cols() << ' ' << abundances(BCn) << " e=0")
<< std::setw(70) << SPELL_STRING(BCn.cols() << ' ' << abundances(BCn) << " e=0")
<< NORMAL
<< " | "
<< (abundances(BCn) == abundances(BCa) ? GREEN : YELLOW)
<< std::setw(70) << MESSAGE(BCa.cols() << ' ' << abundances(BCa) << " e=" << ntoa)
<< std::setw(70) << SPELL_STRING(BCa.cols() << ' ' << abundances(BCa) << " e=" << ntoa)
<< NORMAL
<< " | "
<< (abundances(BCn) == abundances(BCa2) ? GREEN : YELLOW)
<< std::setw(70) << MESSAGE(BCa2.cols() << ' ' << abundances(BCa2) << " e=" << ntoa2)
<< std::setw(70) << SPELL_STRING(BCa2.cols() << ' ' << abundances(BCa2) << " e=" << ntoa2)
<< NORMAL
);
}
......@@ -1740,7 +1740,7 @@ int main(int argc, char** argv)
for (int i = 0; i < 12; ++i) {
Fn = lump(kronecker(kronecker(Fn, gamete), kronecker(A, gamete)));
/*auto Mn = test_geno_matrix("", Fn);*/
/*save_matrix(Mn, MESSAGE("segment_selfing_" << i << ".matrix"));*/
/*save_matrix(Mn, SPELL_STRING("segment_selfing_" << i << ".matrix"));*/
MSG_DEBUG("backcrossing^" << (i + 1));
}
}
......@@ -1753,7 +1753,7 @@ int main(int argc, char** argv)
for (int i = 0; i < 12; ++i) {
Fn = lump(kronecker(Fn, selfing_gamete));
/*auto Mn = test_geno_matrix("", Fn);*/
/*save_matrix(Mn, MESSAGE("segment_selfing_" << i << ".matrix"));*/
/*save_matrix(Mn, SPELL_STRING("segment_selfing_" << i << ".matrix"));*/
MSG_DEBUG("selfing^" << i);
}
}
......@@ -1766,7 +1766,7 @@ int main(int argc, char** argv)
for (int i = 0; i < 12; ++i) {
Fn = lump(kronecker(Fn, selfing_gamete));
auto Mn = test_geno_matrix("", Fn);
save_matrix(Mn, MESSAGE("segment_selfing_" << i << ".matrix"));
save_matrix(Mn, SPELL_STRING("segment_selfing_" << i << ".matrix"));
MSG_DEBUG("selfing^" << i);
}
}
......@@ -1794,11 +1794,11 @@ int main(int argc, char** argv)
Fa = approx_lump(kronecker(Fa, selfing_gamete), STATE_LIMIT);
/*Fa2 = approx_lump(Fn, 32 + i * 4);*/
Fa2 = max_lumping(lump(kronecker(Fa2, selfing_gamete)), STATE_LIMIT);
MatrixXd Mn = load_matrix(MESSAGE("experiments/segment_selfing_" << i << ".matrix"));
MatrixXd Mn = load_matrix(SPELL_STRING("experiments/segment_selfing_" << i << ".matrix"));
auto Ma = test_geno_matrix("", Fa);
save_matrix(Ma, MESSAGE("experiments/lumping_sur_balcon_" << i << "_" << STATE_LIMIT << "-states.matrix"));
save_matrix(Ma, SPELL_STRING("experiments/lumping_sur_balcon_" << i << "_" << STATE_LIMIT << "-states.matrix"));
auto Ma2 = test_geno_matrix("", Fa2);
save_matrix(Ma2, MESSAGE("experiments/max-lumping_" << i << "_" << STATE_LIMIT << "-states.matrix"));
save_matrix(Ma2, SPELL_STRING("experiments/max-lumping_" << i << "_" << STATE_LIMIT << "-states.matrix"));
double ntoa = (Mn - Ma).lpNorm<1>();
double ntoa2 = (Mn - Ma2).lpNorm<1>();
#define OPT(_x) ""
......@@ -1812,11 +1812,11 @@ int main(int argc, char** argv)
MSG_DEBUG(std::setw(5) << i
<< " | "
/*<< (abundances(Fn) == abundances(Fa) ? GREEN : YELLOW)*/
<< std::setw(32) << MESSAGE(Fa.cols() << ' ' << OPT(abundances(Fa)) << " e=" << ntoa)
<< std::setw(32) << SPELL_STRING(Fa.cols() << ' ' << OPT(abundances(Fa)) << " e=" << ntoa)
<< NORMAL
<< " | "
/*<< (abundances(Fn) == abundances(Fa2) ? GREEN : YELLOW)*/
<< std::setw(32) << MESSAGE(Fa2.cols() << ' ' << OPT(abundances(Fa2)) << " e=" << ntoa2)
<< std::setw(32) << SPELL_STRING(Fa2.cols() << ' ' << OPT(abundances(Fa2)) << " e=" << ntoa2)
<< NORMAL
);
}
......@@ -1903,7 +1903,7 @@ int main(int argc, char** argv)
auto F = lump_using_partition(F7, P);
/*auto fs = lump(kronecker(F, selfing_gamete), true);*/
/*MSG_DEBUG("TEST SELFING F7-lump" << i << ": " << fs.inf_mat.cols());*/
test_geno_matrix(MESSAGE("F7-lump" << i), F);
test_geno_matrix(SPELL_STRING("F7-lump" << i), F);
}
auto F3a = approx_lump(kronecker(F2, selfing_gamete), (size_t) (F2.cols() * 2));
......
......@@ -1506,7 +1506,7 @@ std::ostream& operator << (std::ostream& os, const std::map<label_type, double>&
{
os << "abundances:";
for (const auto& kv: ab) {
os << ' ' << kv.first << ": " << std::left << std::setw(12) << MESSAGE((kv.second * 100.) << '%');
os << ' ' << kv.first << ": " << std::left << std::setw(12) << SPELL_STRING((kv.second * 100.) << '%');
}
return os;
}
......@@ -1555,7 +1555,7 @@ MatrixXd test_geno_matrix(const std::string& name, geno_matrix& GEN, const std::
/*A << 1, 0, 0, 0;*/
/*H << 0, 1, 1, 0;*/
/*B << 0, 0, 0, 1;*/
ofile ofs(MESSAGE("values-" << haplo << '.' << name << ".txt"));
ofile ofs(SPELL_STRING("values-" << haplo << '.' << name << ".txt"));
MSG_DEBUG("TEST_GENO_MATRIX " << name);
/*MatrixXd abundance = GEN.lim_inf().col(0);*/
......@@ -2179,9 +2179,9 @@ int main(int argc, char** argv)
/*Fl2 = lump(kronecker(Fl2, selfing_gamete));*/
/*experimental_lumper el2(Fl2);*/
/*Fl2 = el2.do_lump(16);*/
/*test_geno_matrix(MESSAGE("F" << i << "_normal"), F);*/
/*test_geno_matrix(MESSAGE("F" << i << "_over"), Fl);*/
/*test_geno_matrix(MESSAGE("F" << i << "_inherit"), Fl2);*/
/*test_geno_matrix(SPELL_STRING("F" << i << "_normal"), F);*/
/*test_geno_matrix(SPELL_STRING("F" << i << "_over"), Fl);*/
/*test_geno_matrix(SPELL_STRING("F" << i << "_inherit"), Fl2);*/
}
#else
experimental_lumper el(F);
......
......@@ -2380,7 +2380,7 @@ std::ostream& operator << (std::ostream& os, const std::map<label_type, double>&
{
os << "abundances:";
for (const auto& kv: ab) {
os << ' ' << kv.first << ": " << std::left << std::setw(12) << MESSAGE((kv.second * 100.) << '%');
os << ' ' << kv.first << ": " << std::left << std::setw(12) << SPELL_STRING((kv.second * 100.) << '%');
}
return os;
}
......@@ -2429,7 +2429,7 @@ MatrixXd test_geno_matrix(const std::string& name, geno_matrix& GEN, const std::
/*A << 1, 0, 0, 0;*/
/*H << 0, 1, 1, 0;*/
/*B << 0, 0, 0, 1;*/
ofile ofs(MESSAGE("values-" << haplo << '.' << name << ".txt"));
ofile ofs(SPELL_STRING("values-" << haplo << '.' << name << ".txt"));
MSG_DEBUG("TEST_GENO_MATRIX " << name);
/*MatrixXd abundance = GEN.lim_inf().col(0);*/
......@@ -3729,7 +3729,7 @@ int main(int argc, char** argv)
auto CD = lump(kronecker(kronecker(C, gamete), kronecker(D, gamete)));
auto CP = lump(kronecker(kronecker(F1, gamete), kronecker(CD, gamete)));
for (size_t NSTATES: nstates) {
ofile min_angle_file(MESSAGE("min_angles_MAGIC4_" << NSTATES << ".txt"));
ofile min_angle_file(SPELL_STRING("min_angles_MAGIC4_" << NSTATES << ".txt"));
min_angle_file << "gen\tsym\tmin\tmax\tavg" << std::endl;
MSG_DEBUG("NSTATES=" << NSTATES);
......@@ -3752,9 +3752,9 @@ int main(int argc, char** argv)
F = el.derisavi().do_lump(NSTATES);
auto sym_maps = el.LUMPED_SYM;
test_geno_matrix(MESSAGE("MAGIC4-" << NSTATES << "-" << i), F, "ABA");
test_geno_matrix(MESSAGE("MAGIC4-" << NSTATES << "-" << i), F, "ABB");
test_geno_matrix(MESSAGE("MAGIC4-" << NSTATES << "-" << i), F, "ABC");
test_geno_matrix(SPELL_STRING("MAGIC4-" << NSTATES << "-" << i), F, "ABA");
test_geno_matrix(SPELL_STRING("MAGIC4-" << NSTATES << "-" << i), F, "ABB");
test_geno_matrix(SPELL_STRING("MAGIC4-" << NSTATES << "-" << i), F, "ABC");
/*MSG_DEBUG("LUMPED SYMMETRIES");*/
/*MSG_DEBUG("" << sym_maps);*/
......@@ -3911,7 +3911,7 @@ int main(int argc, char** argv)
//for (size_t NSTATES: nstates) {
for (int s = 32; s <= 32; ++s) {
size_t NSTATES = s << 1;
ofile min_angle_file(MESSAGE("min_angles_" << NSTATES << ".txt"));
ofile min_angle_file(SPELL_STRING("min_angles_" << NSTATES << ".txt"));
min_angle_file << "gen\tmin\tmax\tavg" << std::endl;
MSG_DEBUG("NSTATES=" << NSTATES);
......@@ -3963,11 +3963,11 @@ int main(int argc, char** argv)
/*auto Fl = overlump(F, 4);*/
auto aba = test_geno_matrix(MESSAGE("RIL" << NSTATES << "-" << i), F, "ABB");
auto abb = test_geno_matrix(MESSAGE("RIL" << NSTATES << "-" << i), F, "ABA");
auto aba = test_geno_matrix(SPELL_STRING("RIL" << NSTATES << "-" << i), F, "ABB");
auto abb = test_geno_matrix(SPELL_STRING("RIL" << NSTATES << "-" << i), F, "ABA");
/*auto refa = test_geno_matrix(MESSAGE("ref-" << i), ref, "ABB");*/
/*auto refb = test_geno_matrix(MESSAGE("ref-" << i), ref, "ABB");*/
/*auto refa = test_geno_matrix(SPELL_STRING("ref-" << i), ref, "ABB");*/
/*auto refb = test_geno_matrix(SPELL_STRING("ref-" << i), ref, "ABB");*/
/*double d = (aba - refa).lpNorm<1>() + (abb - refb).lpNorm<1>();*/