]> git.donarmstrong.com Git - rsem.git/blobdiff - wiggle.cpp
tested version for tbam2gbam
[rsem.git] / wiggle.cpp
index 90b6f8b49d83ad5ddc45e3a9cd7d144d884c73ca..19f52b480a00dcd991b30b583fce2ce0177a628b 100644 (file)
@@ -2,13 +2,15 @@
 #include <cstdlib>
 #include <cassert>
 
-#include "wiggle.h"
-
+#include <stdint.h>
 #include "sam/bam.h"
 #include "sam/sam.h"
 
+#include "wiggle.h"
+
 void add_bam_record_to_wiggle(const bam1_t *b, Wiggle& wiggle) {
-    float w = bam_aux2f(bam_aux_get(b, "ZW"));
+    uint8_t *p_tag = bam_aux_get(b, "ZW");
+    float w = (p_tag != NULL ? bam_aux2f(p_tag) : 1.0);
     int pos = b->core.pos;
     uint32_t *p = bam1_cigar(b);
     
@@ -41,6 +43,8 @@ void build_wiggles(const std::string& bam_filename,
     bam1_t *b = bam_init1();
     Wiggle wiggle;
        while (samread(bam_in, b) >= 0) {
+               if (b->core.flag & 0x0004) continue;
+
                if (b->core.tid != cur_tid) {
                        if (cur_tid >= 0) processor.process(wiggle);
                        cur_tid = b->core.tid;