Skip to content

Commit

Permalink
tid is the chromosome identifier, how to accumulate ?
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-tushevg committed Sep 8, 2016
1 parent fc4e7e1 commit c9b948a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions htsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -52,6 +62,7 @@ int parseBAM(Settings *props)
{
poly++;


// add polyBasePosition to hash
k = kh_put(pass_hash, hptr, polyBasePosition, &absent);
if (absent)
Expand All @@ -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)
Expand All @@ -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))
Expand All @@ -86,6 +102,7 @@ int parseBAM(Settings *props)
printf("%d\t%d\n", key, val);
}
}
*/

kh_destroy(pass_hash, hptr);
bam_destroy1(bam);
Expand Down

0 comments on commit c9b948a

Please sign in to comment.