diff --git a/htsutils.c b/htsutils.c index a8ebdc6..549b915 100644 --- a/htsutils.c +++ b/htsutils.c @@ -18,6 +18,10 @@ int parseBAM(Settings *props) khiter_t k; khash_t(pass_hash) *hptr = kh_init(pass_hash); + int32_t lasttid = 0; + int counttid = 0; + + uint32_t lines = 0; uint32_t poly = 0; @@ -27,6 +31,12 @@ int parseBAM(Settings *props) while (sam_read1(fh_in, header, bam) >= 0) { + if (lasttid != bam->core.tid) + { + counttid++; + } + + // filter based on MAPQ if (props->mapq > bam->core.qual) continue; @@ -52,6 +62,7 @@ int parseBAM(Settings *props) { poly++; + // add polyBasePosition to hash k = kh_put(pass_hash, hptr, polyBasePosition, &absent); if (absent) @@ -66,6 +77,8 @@ int parseBAM(Settings *props) //printf("Tail: %d|%d\tHead: %d|%d\tSeq:: ", polyTailA,polyTailT,polyHeadA,polyHeadT); //dumpBamSeq(bam); //printf("\n"); + //printf("CHROM: %d\n", bam->core.tid); + lines++; //if (lines == 1) @@ -76,7 +89,10 @@ int parseBAM(Settings *props) fprintf(stderr, "BAM Lines: %d / %d\n", poly, lines); // loop through hash and print values + fprintf(stderr, "HASH Size: %d\n", kh_size(hptr)); + + /* for (k = kh_begin(hptr); k != kh_end(hptr); ++k) { if (kh_exist(hptr, k)) @@ -86,6 +102,7 @@ int parseBAM(Settings *props) printf("%d\t%d\n", key, val); } } + */ kh_destroy(pass_hash, hptr); bam_destroy1(bam);