Commit b97fc4eb authored by Jean-Benoist Leger's avatar Jean-Benoist Leger
Browse files

print duplicated

parent a9585e7e
......@@ -134,6 +134,39 @@ std::list<std::string> make_list_of_rownames(std::string file_name,
return (list_of_rownames);
}
void log_duplicated_rowname(std::ofstream &log_file,
std::list<std::string> &list_of_rownames) {
bool header_not_printed = true;
unsigned int number_dup = 0;
std::string last_rowname;
for (std::list<std::string>::iterator rni = list_of_rownames.begin();
rni != list_of_rownames.end(); rni++) {
if (*rni == last_rowname) {
number_dup += 1;
} else {
if (number_dup > 0) {
if (header_not_printed) {
header_not_printed = false;
log_file << " - Duplicated pos:" << std::endl;
}
log_file << " - " << last_rowname << " (" << number_dup
<< ")" << std::endl;
number_dup = 0;
}
}
last_rowname = *rni;
}
if (number_dup > 0) {
if (header_not_printed) {
header_not_printed = false;
log_file << " - Duplicated pos:" << std::endl;
}
log_file << " - " << last_rowname << " (" << number_dup << ")"
<< std::endl;
number_dup = 0;
}
}
// Enumerate each element of the list (of colnames/rownames) and sort the list
// in alphabetic order
Couple *enumerate_list(std::list<std::string> list_main,
......@@ -568,6 +601,7 @@ void process_data(std::string liststring, std::string file_name_1,
list_rownames_1 =
make_list_of_rownames(file_name_1, output_path, log_file, comment_sign,
separator, num_col_sort);
log_duplicated_rowname(log_file, list_rownames_1);
log_file << " - " << file_name_2 << std::endl;
make_list_of_colnames(file_name_2, output_path, log_file,
......@@ -576,6 +610,7 @@ void process_data(std::string liststring, std::string file_name_1,
list_rownames_2 =
make_list_of_rownames(file_name_2, output_path, log_file, comment_sign,
separator, num_col_sort);
log_duplicated_rowname(log_file, list_rownames_2);
list_indexed_rows_1 = enumerate_list(list_rownames_1, {}, IsSorted);
list_indexed_rows_2 = enumerate_list(list_rownames_2, {}, IsSorted);
......
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