]> git.donarmstrong.com Git - samtools.git/commitdiff
added more comments
authorHeng Li <lh3@live.co.uk>
Sat, 13 Jun 2009 13:06:24 +0000 (13:06 +0000)
committerHeng Li <lh3@live.co.uk>
Sat, 13 Jun 2009 13:06:24 +0000 (13:06 +0000)
examples/calDepth.c

index 6a4be14c070c4a1a4b76f2d93eadc61cece0a61a..7a3239c0380de1cbc67641f05dfd561f3815103a 100644 (file)
@@ -35,25 +35,25 @@ int main(int argc, char *argv[])
                fprintf(stderr, "Fail to open BAM file %s\n", argv[1]);
                return 1;
        }
-       if (argc == 2) {
+       if (argc == 2) { // if a region is not specified
                sampileup(tmp.in, -1, pileup_func, &tmp);
        } else {
                int ref;
                bam_index_t *idx;
                bam_plbuf_t *buf;
-               idx = bam_index_load(argv[1]);
+               idx = bam_index_load(argv[1]); // load BAM index
                if (idx == 0) {
                        fprintf(stderr, "BAM indexing file is not available.\n");
                        return 1;
                }
-               bam_parse_region(tmp.in->header, argv[2], &ref, &tmp.beg, &tmp.end);
+               bam_parse_region(tmp.in->header, argv[2], &ref, &tmp.beg, &tmp.end); // parse the region
                if (ref < 0) {
                        fprintf(stderr, "Invalid region %s\n", argv[2]);
                        return 1;
                }
-               buf = bam_plbuf_init(pileup_func, &tmp);
+               buf = bam_plbuf_init(pileup_func, &tmp); // initialize pileup
                bam_fetch(tmp.in->x.bam, idx, ref, tmp.beg, tmp.end, buf, fetch_func);
-               bam_plbuf_push(0, buf);
+               bam_plbuf_push(0, buf); // finalize pileup
                bam_index_destroy(idx);
                bam_plbuf_destroy(buf);
        }