From 9ef1c867c60e11ace4e5c36636c4ba91405da9dc Mon Sep 17 00:00:00 2001 From: Reed Nelson Date: Fri, 1 Dec 2023 20:19:15 -0600 Subject: [PATCH] repair bio input --- README.md | 4 ++-- src/file_io.cpp | 16 +++++++++++++++- src/util.cpp | 4 ++-- test/B.csv | 9 --------- test/G.csv | 9 --------- test/H.csv | 11 ----------- 6 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 test/B.csv delete mode 100644 test/G.csv delete mode 100644 test/H.csv diff --git a/README.md b/README.md index 0655d64..3b18690 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,10 @@ This utility has the form `./minaa.exe [-B=bio] [-a=alpha] [-b=beta]`. - Default: the algorithm will run using only topological calculations. - **-a=**: alpha; the GDV-edge weight balancer. - Require: a real number in range [0, 1]. - - Default: 1 + - Default: 1 (100% GDV data). - **-b=**: beta; the topological-biological cost matrix balancer. - Require: a real number in range [0, 1]. - - Default: 1 + - Default: 1 (100% topological data). #### Uncommon diff --git a/src/file_io.cpp b/src/file_io.cpp index 42b036c..a559782 100644 --- a/src/file_io.cpp +++ b/src/file_io.cpp @@ -418,16 +418,30 @@ namespace FileIO throw std::runtime_error("Unable to open file " + filepath); } - // Parse the file directly into a matrix + // Parse the file directly into a matrix, skipping the first row and column std::vector> matrix; std::string line; + auto first_row = true; while (std::getline(fin, line)) { + if (first_row) + { + first_row = false; + continue; + } + std::stringstream ss(line); std::string cell; std::vector row; + auto first_col = true; while (std::getline(ss, cell, delim)) { + if (first_col) + { + first_col = false; + continue; + } + try { row.push_back(std::stod(cell)); diff --git a/src/util.cpp b/src/util.cpp index da6ddc8..bc01de3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -170,10 +170,10 @@ namespace Util std::vector> binarify(std::vector> double_matrix) { std::vector> binary_matrix; - for (unsigned i = 1; i < double_matrix.size(); ++i) + for (unsigned i = 0; i < double_matrix.size(); ++i) { std::vector row; - for (unsigned j = 1; j < double_matrix[i].size(); ++j) + for (unsigned j = 0; j < double_matrix[i].size(); ++j) { if (double_matrix[i][j] != 0) { diff --git a/test/B.csv b/test/B.csv deleted file mode 100644 index 1bb34f1..0000000 --- a/test/B.csv +++ /dev/null @@ -1,9 +0,0 @@ -"","h1","h2","h3","h4","h5","h6","h7","h8","h9","h10" -"g1",0.1,0.1,0.1,0.1,0.1,0.5,0.5,0.1,0.1,0.1 -"g2",0.1,0.1,0.1,0.1,0.5,0.1,0.1,0.1,0.5,0.5 -"g3",0.1,0.1,0.1,0.5,0.1,0.1,0.5,0.1,0.1,0.1 -"g4",0.1,0.1,0.5,0.1,0.1,0.5,0.1,0.1,0.1,0.1 -"g5",0.1,0.5,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1 -"g6",0.5,0.1,0.1,0.5,0.1,0.1,0.5,0.1,0.1,0.1 -"g7",0.5,0.1,0.5,0.1,0.1,0.5,0.1,0.1,0.1,0.1 -"g8",0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1 diff --git a/test/G.csv b/test/G.csv deleted file mode 100644 index 53c88ee..0000000 --- a/test/G.csv +++ /dev/null @@ -1,9 +0,0 @@ -"","g1","g2","g3","g4","g5","g6","g7","g8" -"g1",0,0,0,0,0,1,1,0 -"g2",0,0,0,0,1,0,0,0 -"g3",0,0,0,1,0,0,1,0 -"g4",0,0,1,0,0,1,0,0 -"g5",0,1,0,0,0,0,0,0 -"g6",1,0,0,1,0,0,1,0 -"g7",1,0,1,0,0,1,0,0 -"g8",0,0,0,0,0,0,0,0 diff --git a/test/H.csv b/test/H.csv deleted file mode 100644 index 733849f..0000000 --- a/test/H.csv +++ /dev/null @@ -1,11 +0,0 @@ -"","h1","h2","h3","h4","h5","h6","h7","h8","h9","h10" -"h1",0,0,1,0,0,1,0,0,0,0 -"h2",0,0,0,0,0,0,0,0,0,1 -"h3",1,0,0,1,0,1,0,0,1,0 -"h4",0,0,1,0,0,1,0,0,0,0 -"h5",0,0,0,0,0,0,1,0,0,1 -"h6",1,0,1,1,0,0,0,0,0,0 -"h7",0,0,0,0,1,0,0,0,0,0 -"h8",0,0,0,0,0,0,0,0,0,1 -"h9",0,0,1,0,0,0,0,0,0,0 -"h10",0,1,0,0,1,0,0,1,0,0