From bca32eef261156756abaa60d3e111d61d823349a Mon Sep 17 00:00:00 2001
From: oboulle <olivier.boulle@inria.fr>
Date: Thu, 22 Aug 2024 17:33:00 +0200
Subject: [PATCH] decrease score requirement, close files

---
 partitioning/fast_clustering_t.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/partitioning/fast_clustering_t.cpp b/partitioning/fast_clustering_t.cpp
index 24a4804..3d7d6f5 100755
--- a/partitioning/fast_clustering_t.cpp
+++ b/partitioning/fast_clustering_t.cpp
@@ -52,11 +52,11 @@ std::string get_cluster_id(const std::string& read, const std::string& seq_to_fi
     SmithWaterman(read_rc, seq_to_find, score_rc, x_rc, y_rc);
 
     if (score_fw >= score_rc) { // primer found in forward sequence
-        if (score_fw >= 8 && read.size() > y_fw + split_level) {
+        if (score_fw >= 7.5 && read.size() > y_fw + split_level) {
             return read.substr(y_fw, split_level);
         }
     } else { // primer found in reverse complement sequence
-        if (score_rc >= 8 && read_rc.size() > y_rc + split_level) {
+        if (score_rc >= 7.5 && read_rc.size() > y_rc + split_level) {
             return read_rc.substr(y_rc, split_level);
         }
     }
@@ -124,7 +124,7 @@ void process_file_part(const std::string& input_filename, int part_id, int start
             continue; // reject the read
         }
 
-        // lock the mutex for this output file
+        // lock the mutex for this output file until the end of this loop iteration
         std::lock_guard<std::mutex> lock(output_mutexes[cluster_id]);
 
         // write the sequence and its id to a cluster file corresponding to the bases found after the primer
@@ -134,8 +134,10 @@ void process_file_part(const std::string& input_filename, int part_id, int start
             return;
         }
         output_file << ">" << read_name << "\n" << sequence << "\n"; // output format is fasta
+        output_file.close();
 
     }
+    input_read_file.close();
 }
 
 
@@ -155,7 +157,7 @@ int main(int argc, char* argv[]) {
 
     int n_thread; // number of threads used, default = maximum possible
     if (argc == 4) {
-        n_thread = std::thread::hardware_concurrency();
+        n_thread = 1;//std::thread::hardware_concurrency();
     } else {
         n_thread = std::stoi(argv[4]);
     }
-- 
GitLab