Commit 2a898e5c authored by Romain Feron's avatar Romain Feron
Browse files

More bugfix in depths function, added function to popmap to find an...

More bugfix in depths function, added function to popmap to find an individual's group and return an empty string if not in popmap
parent 4cee4ee2
......@@ -8,10 +8,11 @@ void depth(Parameters& parameters) {
Popmap popmap = load_popmap(parameters, false);
log("RADSex depth started");
Header header;
Header header = get_header(parameters.markers_table_path);
uint n_individuals = static_cast<uint>(header.size()) - 2; // Number of columns - 2 (id and seq columns)
Depths depths(popmap.n_individuals);
std::vector<uint32_t> n_markers(popmap.n_individuals, 0);
Depths depths(n_individuals);
std::vector<uint32_t> n_markers(n_individuals, 0);
bool parsing_ended = false;
MarkersQueue markers_queue;
......@@ -35,6 +36,8 @@ void depth(Parameters& parameters) {
const auto end = depths[i].end() - 1;
const auto size = depths[i].size();
const std::string group = popmap.get_group(header[i + 2]);
const uint16_t min_depth = *start;
const uint16_t max_depth = *end;
const uint64_t total_depth = static_cast<uint64_t>(std::accumulate(depths[i].begin(), depths[i].end(), 0));
......@@ -60,7 +63,7 @@ void depth(Parameters& parameters) {
median_depth = *median_it;
}
output_file << header[i+2] << "\t" << popmap.groups[header[i+2]] << "\t" << n_markers[i] << "\t" << size << "\t" << min_depth << "\t" <<
output_file << header[i+2] << "\t" << group << "\t" << n_markers[i] << "\t" << size << "\t" << min_depth << "\t" <<
max_depth << "\t" << median_depth << "\t" << total_depth / size << "\n";
}
......
......@@ -11,6 +11,14 @@ struct Popmap {
std::unordered_map<std::string, uint> counts; // Number of individual in each group
uint16_t n_individuals = 0; // Total number of individuals
std::string get_group(const std::string& individual) {
std::string group = "";
if (this->groups.find(individual) != this->groups.end()) group = this->groups[individual];
return group;
}
};
Popmap load_popmap(Parameters& parameters, bool compare = true);
......
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