From 84a877bbc166a5f417d2ac840da261f5d4515a0c Mon Sep 17 00:00:00 2001
From: Veronique Legrand <vlegrand@pasteur.fr>
Date: Tue, 15 Mar 2016 13:56:19 +0100
Subject: [PATCH] bug fix+ traces for debug

---
 src/rock.cpp | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/rock.cpp b/src/rock.cpp
index 24391ec..c915439 100644
--- a/src/rock.cpp
+++ b/src/rock.cpp
@@ -30,6 +30,7 @@
 
 using namespace std;
 
+//#define DEBUG
 
 #define BENCHMARK
 #ifdef BENCHMARK
@@ -121,24 +122,31 @@ void lowFilterCMS(FqBaseBackend* map_id_backend[],int nb_be,int k, CountMinSketc
     for (i=0;i<nb_be;i++){
         map_id_backend[i]->openFile();
     }
-    
+    cout<<"all input files are open"<<endl;
     for (it=io_sr->begin(); it!=io_sr->end(); ++it) {
         for (it_offs=it->second.begin();it_offs!=it->second.end();it_offs++) {
             unsigned int j=it_offs->first;
             for (it_struct=it_offs->second.begin();it_struct!=it_offs->second.end();it_struct++) {
-                // read dna string corresponding to fastq record
-                DnaSeqStr a_seqs[2];
-                init_DnaSeqStr(&a_seqs[0]);
-                init_DnaSeqStr(&a_seqs[1]);
-                getDNASeqstr(map_id_backend,*it_struct,j,a_seqs);
-                // decompose dna string into k-mers and turn k_mers into numbers.
-                decomposeReadInKMerNums(read_p, nbrKmerDecompo,k,a_seqs);
-                ret=pcms->isBeneathMinKappa(nbrKmerDecompo);
-                if (ret) it_struct->fileid=0;
-                nbrKmerDecompo.clear();
+                if (it_struct->fileid) {
+                    // read dna string corresponding to fastq record
+                    DnaSeqStr a_seqs[2];
+                    init_DnaSeqStr(&a_seqs[0]);
+                    init_DnaSeqStr(&a_seqs[1]);
+                    getDNASeqstr(map_id_backend,*it_struct,j,a_seqs);
+#ifdef DEBUG
+cout<<a_seqs[0].fq_record_buf<<" "<<a_seqs[0].start_idx<<" "<<a_seqs[0].length<<endl;
+cout<<a_seqs[1].fq_record_buf<<" "<<a_seqs[1].start_idx<<" "<<a_seqs[1].length<<endl;
+#endif
+                    // decompose dna string into k-mers and turn k_mers into numbers.
+                    decomposeReadInKMerNums(read_p, nbrKmerDecompo,k,a_seqs);
+                    ret=pcms->isBeneathMinKappa(nbrKmerDecompo);
+                    if (ret) it_struct->fileid=0;
+                    nbrKmerDecompo.clear();
+                 }
             }
         }
     }
+    cout<<"going to close input files."<<endl;
     for (i=0;i<nb_be;i++){
         map_id_backend[i]->closeFile();
     }
-- 
GitLab