]> git.donarmstrong.com Git - rsem.git/blobdiff - BamConverter.h
Allowed > 2^31 hits
[rsem.git] / BamConverter.h
index cca0eae895fd347b243cc8f2f315be471c64498c..bd81127d5fcb4728ad4e43efd9a0d9f723e4f78f 100644 (file)
@@ -14,6 +14,7 @@
 #include "sam_rsem_cvt.h"
 
 #include "utils.h"
+#include "my_assert.h"
 #include "bc_aux.h"
 #include "Transcript.h"
 #include "Transcripts.h"
@@ -44,12 +45,13 @@ private:
 BamConverter::BamConverter(const char* inpF, const char* outF, const char* chr_list, Transcripts& transcripts)
        : transcripts(transcripts)
 {
-       if (transcripts.getType() != 0)
-               exitWithError("Genome information is not provided! RSEM cannot convert the transcript bam file!");
+       general_assert(transcripts.getType() == 0, "Genome information is not provided! RSEM cannot convert the transcript bam file!");
 
        in = samopen(inpF, "rb", NULL);
        assert(in != 0);
 
+       transcripts.buildMappings(in->header->n_targets, in->header->target_name);
+
        bam_header_t *out_header = sam_header_read2(chr_list);
        refmap.clear();
        for (int i = 0; i < out_header->n_targets; i++) {
@@ -74,7 +76,7 @@ void BamConverter::process() {
        std::string cqname;
        bool isPaired = false;
 
-       int cnt = 0;
+       HIT_INT_TYPE cnt = 0;
 
        cqname = "";
        b = bam_init1(); b2 = bam_init1();
@@ -93,7 +95,7 @@ void BamConverter::process() {
                // at least one segment is not properly mapped
                if ((b->core.flag & 0x0004) || (isPaired && (b2->core.flag & 0x0004))) continue;
 
-               const Transcript& transcript = transcripts.getTranscriptAt(b->core.tid + 1);
+               const Transcript& transcript = transcripts.getTranscriptViaEid(b->core.tid + 1);
 
                convert(b, transcript);
                if (isPaired) {
@@ -123,7 +125,7 @@ void BamConverter::convert(bam1_t* b, const Transcript& transcript) {
        int pos = b->core.pos;
        int readlen = b->core.l_qseq;
 
-       if (readlen == 0) exitWithError("One alignment line has SEQ field as *. RSEM does not support this currently!");
+       general_assert(readlen > 0, "One alignment line has SEQ field as *. RSEM does not support this currently!");
 
        iter = refmap.find(transcript.getSeqName());
        assert(iter != refmap.end());