From d04e0ad44dc7f2f60cc4a84729af44455240126d Mon Sep 17 00:00:00 2001
From: oboulle <olivier.boulle@inria.fr>
Date: Mon, 10 Jun 2024 17:34:24 +0200
Subject: [PATCH] added option to chose matrix or graph on run

---
 partitioning/partitioning.cpp | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/partitioning/partitioning.cpp b/partitioning/partitioning.cpp
index d84efe6..742de42 100755
--- a/partitioning/partitioning.cpp
+++ b/partitioning/partitioning.cpp
@@ -238,14 +238,18 @@ void minlist_to_csv(const std::vector<std::vector<int>>& minimizer_list, int rea
 int main(int argc, char* argv[]) {
 
     // Check if the input and output file paths are provided as arguments
-    if (argc != 3) {
-        std::cerr << "Usage: " << argv[0] << " <input_fastq> <output_file>" << std::endl;
+    if (argc != 4) {
+        std::cerr << "Usage: " << argv[0] << " <input_fastq> <output_file> [--graph|--matrix]" << std::endl;
         return 1;
     }
 
     // Get the input and output file paths from the arguments
     std::string input_fastq = argv[1];
     std::string output_file = argv[2];
+    std::string option = argv[3];
+
+    // Extract the minimizers from the input file
+    std::vector<std::vector<int>> minimizer_list = get_minimizers(input_fastq);
 
     // get the number of sequences from the fastq
     std::ifstream file(input_fastq);
@@ -258,13 +262,17 @@ int main(int argc, char* argv[]) {
         }
     }
 
-    // Extract the minimizers from the input file
-    std::vector<std::vector<int>> minimizer_list = get_minimizers(input_fastq);
-
-    // Write the minimizer matrix to the output file in CSV format
-    //minlist_to_csv(minimizer_list, seq_number, output_file);
-
-    minlist_to_graph(minimizer_list, seq_number, output_file);
+    // Call the appropriate function based on the option
+    if (option == "--graph") {
+        minlist_to_graph(minimizer_list, seq_number, output_file);
+        std::cout << "Minimizer graph written to " << output_file << std::endl;
+    } else if (option == "--matrix") {
+        minlist_to_csv(minimizer_list, seq_number, output_file);
+        std::cout << "Minimizer matrix written to " << output_file << std::endl;
+    } else {
+        std::cerr << "Invalid option: " << option << std::endl;
+        return 1;
+    }
 
     return 0;
 }
-- 
GitLab