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

Merge branch 'log_output'

parents c0accf56 6425b734
......@@ -31,7 +31,7 @@ int GetNextColnamePosition(std::string Line, int FirstPos, int line_length, char
}
// Make the list of colnames of the file
void make_list_of_colnames(std::string file_name, std::string output_path,
void make_list_of_colnames(std::string file_name, std::string output_path, std::ofstream &log_file,
std::list<std::string> &list_supp_colnames,
std::list<std::string> &list_main_colnames,
char comment_sign,
......@@ -40,7 +40,6 @@ void make_list_of_colnames(std::string file_name, std::string output_path,
int begin_colname = 0, begin_next_colname = 0, nb_columns = 0;
std::string colname, line_of_colnames;
bool comment_line = true;
std::ofstream log_file((output_path + "log.txt").c_str(), std::ios_base::app);
assert(log_file.is_open());
std::ifstream myfile(file_name.c_str(), std::ifstream::in | std::ifstream::binary);
......@@ -80,14 +79,12 @@ void make_list_of_colnames(std::string file_name, std::string output_path,
}
myfile.close();
log_file << file_name << " :" << std::endl;
log_file << "Number of colnames - " << list_supp_colnames.size() + list_main_colnames.size() << std::endl;
log_file.close();
log_file << " - Number of colnames: " << list_supp_colnames.size() + list_main_colnames.size() << std::endl;
}
// Make the list of rownames of the file
std::list<std::string> make_list_of_rownames(std::string file_name, std::string output_path, char comment_sign,
std::list<std::string> make_list_of_rownames(std::string file_name, std::string output_path, std::ofstream &log_file, char comment_sign,
char separator, int num_col_sort)
{
std::string rowname, line_of_rownames;
......@@ -95,7 +92,6 @@ std::list<std::string> make_list_of_rownames(std::string file_name, std::string
std::list<std::string> list_of_rownames;
std::ifstream myfile(file_name.c_str(), std::ifstream::in | std::ifstream::binary);
std::ofstream log_file((output_path + "log.txt").c_str(), std::ios_base::app);
// std::ofstream rownames_file ("/.../rownames.txt");
assert(myfile.is_open());
assert(log_file.is_open());
......@@ -125,8 +121,7 @@ std::list<std::string> make_list_of_rownames(std::string file_name, std::string
}
myfile.close();
log_file << "Number of rownames - " << list_of_rownames.size() << "." << std::endl << std::endl;
log_file.close();
log_file << " - Number of rownames: " << list_of_rownames.size() << "." << std::endl;
return(list_of_rownames);
}
......@@ -249,7 +244,7 @@ int infer_nb_supp_lines(std::string & filename, char comment_sign)
// Merge two files in one using initial files and merged lists of rownames and colnames
void fusion(std::string liststring, std::string filename_1, std::string filename_2, std::string output_path, std::string output_filename,
void fusion(std::string liststring, std::string filename_1, std::string filename_2, std::string output_path, std::string output_filename, std::ofstream& log_file,
std::list<Triple> merged_list_rows,
std::list<Triple> merged_list_cols, char comment_sign,
std::string unknown, char separator,
......@@ -430,6 +425,9 @@ void fusion(std::string liststring, std::string filename_1, std::string filename
OfsFile2.close();
std::remove(OfsFileName1.c_str());
std::remove(OfsFileName2.c_str());
log_file << " - Number of colnames: " << merged_list_cols.size() << "." << std::endl;
log_file << " - Number of rownames: " << merged_list_rows.size() << "." << std::endl;
}
// Take value from line using the position of corresponding colname
......@@ -514,12 +512,20 @@ void process_data(std::string liststring, std::string file_name_1, std::string f
list_colnames_supp_1, list_colnames_main_1, list_colnames_supp_2, list_colnames_main_2;
Couple *list_indexed_rows_1, *list_indexed_rows_2, *list_indexed_cols_1, *list_indexed_cols_2;
std::list<Triple> general_list_rownames, general_list_colnames;
std::ofstream log_file((output_path + "log.txt").c_str(), std::ios_base::app);
assert(log_file.is_open());
make_list_of_colnames(file_name_1, output_path, list_colnames_supp_1, list_colnames_main_1, comment_sign, nb_supp_elements, separator);
list_rownames_1 = make_list_of_rownames(file_name_1, output_path, comment_sign, separator, num_col_sort);
log_file << "Merge:" << std::endl;
log_file << " - Input:" << std::endl;
log_file << " - " << file_name_1 << std::endl;
make_list_of_colnames(file_name_2, output_path, list_colnames_supp_2, list_colnames_main_2, comment_sign, nb_supp_elements, separator);
list_rownames_2 = make_list_of_rownames(file_name_2, output_path, comment_sign, separator, num_col_sort);
make_list_of_colnames(file_name_1, output_path, log_file, list_colnames_supp_1, list_colnames_main_1, comment_sign, nb_supp_elements, separator);
list_rownames_1 = make_list_of_rownames(file_name_1, output_path, log_file, comment_sign, separator, num_col_sort);
log_file << " - " << file_name_2 << std::endl;
make_list_of_colnames(file_name_2, output_path, log_file, list_colnames_supp_2, list_colnames_main_2, comment_sign, nb_supp_elements, separator);
list_rownames_2 = make_list_of_rownames(file_name_2, output_path, log_file, comment_sign, separator, num_col_sort);
list_indexed_rows_1 = enumerate_list(list_rownames_1, {}, IsSorted);
list_indexed_rows_2 = enumerate_list(list_rownames_2, {}, IsSorted);
......@@ -535,5 +541,10 @@ void process_data(std::string liststring, std::string file_name_1, std::string f
delete[] list_indexed_cols_1;
delete[] list_indexed_cols_2;
fusion(liststring, file_name_1, file_name_2, output_path, output_filename, general_list_rownames, general_list_colnames, comment_sign, unknown, separator, nb_supp_elements, value_length, file_extension, nb_supp_lines, last_iteration);
log_file << " - Output:" << std::endl;
log_file << " - " << output_filename << std::endl;
fusion(liststring, file_name_1, file_name_2, output_path, output_filename, log_file, general_list_rownames, general_list_colnames, comment_sign, unknown, separator, nb_supp_elements, value_length, file_extension, nb_supp_lines, last_iteration);
log_file << std::endl;
log_file.close();
}
......@@ -17,14 +17,14 @@ bool CommentLine(std::string Line, char CommentChar);
int GetNextColnamePosition(std::string Line, int FirstPos,
int line_length, char separator);
void make_list_of_colnames(std::string file_name, std::string output_path,
void make_list_of_colnames(std::string file_name, std::string output_path, std::ofstream &log_file,
std::list<std::string> &list_supp_colnames,
std::list<std::string> &list_main_colnames,
char comment_sign = '#',
int nb_supp_elements = 9,
char separator = '\t');
std::list<std::string> make_list_of_rownames(std::string file_data, std::string output_path,
std::list<std::string> make_list_of_rownames(std::string file_data, std::string output_path, std::ofstream &log_file,
char comment_sign = '#', char separator = '\t');
Couple *enumerate_list(std::list<std::string> list_main, std::list<std::string> list_supp, bool IsSorted = false);
......@@ -36,7 +36,7 @@ std::string take_value_from_line(std::string line, int current_col, int &OffsetS
int nb_supp_elements = 9, int value_length = 3,
char separator = '\t', std::string unknown = "./.");
void fusion(std::string liststring, std::string filename_1, std::string filename_2, std::string output_path, std::string output_filename, std::list<Triple> merged_list_rows,
void fusion(std::string liststring, std::string filename_1, std::string filename_2, std::string output_path, std::string output_filename, std::ofstream &log_file, std::list<Triple> merged_list_rows,
std::list<Triple> merged_list_cols, char comment_sign = '#',
std::string unknown = "./.", char separator = '\t', int nb_supp_elements = 9, int value_length = 3, std::string file_extension = "vcf", int nb_supp_lines = 5, bool last_iteration = 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