Commit 3185287f authored by Damien Leroux's avatar Damien Leroux
Browse files

Hardened command-line a tad.

parent 5c7a98f4
......@@ -46,7 +46,7 @@ bool check_file(const std::string& path, bool req_directory, bool req_writable,
file_stat fs(path);
if (fs.err != 0) {
if (display) {
MSG_ERROR("Error occurred trying to stat " << path << ": " << strerror(errno), "Check whether " << path << " exists and is accessible");
MSG_ERROR("Path " << path << " is invalid: " << strerror(errno), "Check whether " << path << " exists and is accessible");
}
return false;
}
......
......@@ -191,6 +191,9 @@ struct settings_t {
pop.name = pkv.first;
for (auto& kv: pop.observed_mark) {
const impl::generation_rs* g = design->generation[kv.first];
if (!g) {
continue;
}
const marker_observation_spec& mos = marker_observation_specs[kv.second.format_name];
kv.second.compute_observation_vectors(g, mos);
}
......
......@@ -36,8 +36,8 @@ COV_OBJ=$(subst .cc,.cov.o,$(SRC))
ALL_BUT_MAIN_OBJ=$(subst main.o ,,$(OBJ))
#DEBUG_OPTS=-ggdb
#DEBUG_OPTS=-ggdb -DNDEBUG
OPT_OPTS=-O3 -DEIGEN_NO_DEBUG -DNDEBUG
DEBUG_OPTS=-ggdb -DNDEBUG
#OPT_OPTS=-O3 -DEIGEN_NO_DEBUG -DNDEBUG
#OPT_OPTS=-O3 -DNDEBUG
#OPT_OPTS=-O -DEIGEN_NO_DEBUG -DNDEBUG
#OPT_OPTS=-DEIGEN_NO_DEBUG -DNDEBUG
......
......@@ -575,6 +575,7 @@ arguments = {
{&settings_t::work_directory},
[](CALLBACK_ARGS) {
ensure(target)->work_directory = *++ai;
/*check_file(ensure(target)->work_directory, true, true, true);*/
SAFE_IGNORE_CALLBACK_ARGS;
}},
......@@ -759,6 +760,15 @@ arguments = {
}
std::string gen_name(gen_and_format.cbegin(), gen_and_format.cbegin() + colon);
std::string format_name(gen_and_format.cbegin() + 1 + colon, gen_and_format.cend());
if (!ensure(target)->design->generation[gen_name]) {
MSG_ERROR("Generation '" << gen_name << "' isn't defined.", "Specify a generation name that is defined in the breeding design XML file");
}
if (0) {
const auto& mos = ensure(target)->marker_observation_specs;
if (mos.find(format_name) == mos.end()) {
MSG_ERROR("Marker observation format '" << format_name << "' isn't defined.", "");
}
}
size_t colon1 = filename.find_first_of(':');
int start = -1;
int end = -1;
......@@ -776,10 +786,11 @@ arguments = {
}
filename.resize(colon1);
}
check_file(filename, false, false);
std::ifstream ifs(filename);
p.observed_mark[gen_name] = {filename, format_name, 0,
read_data::read_marker(ifs, start, end), {}};
if (check_file(filename, false, false)) {
std::ifstream ifs(filename);
p.observed_mark[gen_name] = {filename, format_name, 0,
read_data::read_marker(ifs, start, end), {}};
}
SAFE_IGNORE_CALLBACK_ARGS;
}},
......@@ -1174,7 +1185,7 @@ struct settings_constraint_t {
static void check(const settings_t* s)
{
msg_handler_t::reset();
/*msg_handler_t::reset();*/
std::pair<bool, std::set<std::string>> ret;
/*MSG_DEBUG("constraints: " << list().size());*/
chrono::start("Consistency check");
......@@ -1281,6 +1292,24 @@ settings_constraint_t
}
return ok;
}),
#if 0
all_marker_obs_have_an_existing_generation(
"The generation doesn't exist for a marker observation dataset",
"Check the generation name is actually defined in the breeding design XML file",
PREDICATE
{
bool ok = true;
for (auto& kv: s->populations) {
for (auto& mo: kv.second.marker_observations) {
if (s->design->generation[mo.generation_name] == NULL) {
MSG_ERROR("Generation " << kv.second.qtl_generation_name << " doesn't exist", "");
ok = false;
}
}
}
return ok;
}),
#endif
all_traits_have_same_size_in_each_pop(
"There must be the same number of observations for each trait in a population",
"Check your data, here may have been a problem when the file was generated",
......@@ -1382,10 +1411,16 @@ settings_constraint_t
for (const auto& pkv: s->populations) {
const population& pop = pkv.second;
/*MSG_DEBUG(pop);*/
if (pop.observed_mark.size() == 0) {
continue;
}
for (const chromosome& chr: s->map) {
/*MSG_DEBUG(chr);*/
/*for (const auto& kv: pop.observed_mark) {*/
auto gen = s->design->generation[pop.qtl_generation_name];
if (!gen) {
continue;
}
auto obs_qtl_gen_it = pop.observed_mark.find(gen->name);
size_t n_ind;
if (obs_qtl_gen_it == pop.observed_mark.end()) {
......
......@@ -62,7 +62,7 @@ int main(int argc, const char** argv)
exit(0);
}
msg_handler_t::check(true);
/*msg_handler_t::check(true);*/
active_settings->finalize();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment