]> git.donarmstrong.com Git - rsem.git/commitdiff
Added error detection for cases such as a read's two mates having different names... master
authorBo Li <bli@cs.wisc.edu>
Wed, 3 Sep 2014 21:43:53 +0000 (16:43 -0500)
committerBo Li <bli@cs.wisc.edu>
Wed, 3 Sep 2014 21:43:53 +0000 (16:43 -0500)
SamParser.h
parseIt.cpp

index 81d4097cf0033dee55d012abeaf8ea106120b9d9..4747ef4281af593f714450d68ccfc65090662891 100644 (file)
@@ -62,7 +62,7 @@ private:
        }
 
        std::string getName(const bam1_t* b) {
        }
 
        std::string getName(const bam1_t* b) {
-               return std::string((char*)bam1_qname(b));
+               return std::string(bam1_qname(b));
        }
 
        std::string getReadSeq(const bam1_t*);
        }
 
        std::string getReadSeq(const bam1_t*);
@@ -190,6 +190,8 @@ int SamParser::parseNext(PairedEndRead& read, PairedEndHit& hit) {
                mp1 = b2; mp2 = b;
        }
 
                mp1 = b2; mp2 = b;
        }
 
+       general_assert(!strcmp(bam1_qname(mp1), bam1_qname(mp2)), "Detected a read pair whose two mates have different names: " + getName(mp1) + " , " + getName(mp2) + " !");
+
        int readType = getReadType(mp1, mp2);
        std::string name = getName(mp1);
 
        int readType = getReadType(mp1, mp2);
        std::string name = getName(mp1);
 
@@ -242,6 +244,8 @@ int SamParser::parseNext(PairedEndReadQ& read, PairedEndHit& hit) {
                mp1 = b2; mp2 = b;
        }
 
                mp1 = b2; mp2 = b;
        }
 
+       general_assert(!strcmp(bam1_qname(mp1), bam1_qname(mp2)), "Detected a read pair whose two mates have different names: " + getName(mp1) + " , " + getName(mp2) + " !");
+
        int readType = getReadType(mp1, mp2);
        std::string name = getName(mp1);
 
        int readType = getReadType(mp1, mp2);
        std::string name = getName(mp1);
 
index 91a4c141da95323dc58b5a8b45e47cb543fa0a75..f40f82295302c48b16923d6655f3757d4057e09b 100644 (file)
@@ -94,6 +94,9 @@ void parseIt(SamParser *parser) {
                                record_read.write(n_os, cat[record_val]);
                                ++N[record_val];
                        }
                                record_read.write(n_os, cat[record_val]);
                                ++N[record_val];
                        }
+
+                       general_assert(record_val == 1 || hits.getNHits() == 0, "Read " + record_read.getName() + " is both unalignable and alignable according to the input SAM/BAM file!");
+
                        // flush out previous read's hits if the read is alignable reads
                        if (record_val == 1) {
                                hits.updateRI();
                        // flush out previous read's hits if the read is alignable reads
                        if (record_val == 1) {
                                hits.updateRI();