*p = 'Z'; ++p; *p = 'W'; ++p; *p = 'f'; ++p;
float val = (float)hmapIter->second;
memcpy(p, &val, 4);
- samwrite(out, tmp_b);
+ if (tmp_b->core.qual > 0) samwrite(out, tmp_b); // output only when MAPQ > 0
bam_destroy1(tmp_b); // now hmapIter->b makes no sense
}
hmap.clear();
*p = 'Z'; ++p; *p = 'W'; ++p; *p = 'f'; ++p;
float val = (float)hmapIter->second;
memcpy(p, &val, 4);
- samwrite(out, tmp_b);
+ if (tmp_b->core.qual > 0) samwrite(out, tmp_b); // If MAPQ is equal to 0, do not output this alignment
bam_destroy1(tmp_b); // now hmapIter->b makes no sense
}
hmap.clear();
float val = (float)hmapIter->second;
memcpy(p, &val, 4);
memcpy(p2, &val, 4);
-
- samwrite(out, tmp_b);
- samwrite(out, tmp_b2);
+
+ // If MAPQ is equal to 0, do not output this alignment pair
+ if (tmp_b->core.qual > 0) {
+ samwrite(out, tmp_b);
+ samwrite(out, tmp_b2);
+ }
bam_destroy1(tmp_b);
bam_destroy1(tmp_b2);
memcpy(p, &val, 4);
memcpy(p2, &val, 4);
- samwrite(out, tmp_b);
- samwrite(out, tmp_b2);
+ if (tmp_b->core.qual > 0) {
+ samwrite(out, tmp_b);
+ samwrite(out, tmp_b2);
+ }
bam_destroy1(tmp_b);
bam_destroy1(tmp_b2);