Created
June 6, 2014 16:52
-
-
Save MauricioCarneiro/282843879718c6b98d5b to your computer and use it in GitHub Desktop.
Quick test for vcf/bcf loading using htslib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include "htslib/vcf.h" | |
int main(int argc, char *argv[]) | |
{ | |
int c, is_sam = 0, is_copy = 0; | |
long cnt = 0; | |
vcfFile *fp; | |
bcf_hdr_t *h; | |
bcf1_t *b; | |
while ((c = getopt(argc, argv, "Sc")) >= 0) { | |
if (c == 'S') is_sam = 1; | |
else if (c == 'c') is_copy = 1; | |
} | |
if (argc == optind) { | |
fprintf(stderr, "Usage: test-dup [-Sc] <in.sam> | <in.bam>\n"); | |
return 1; | |
} | |
fp = bcf_open(argv[optind], is_sam? "r" : "rb"); | |
h = bcf_hdr_read(fp); | |
b = bcf_init1(); | |
while (bcf_read1(fp, h, b) >= 0) { | |
if (is_copy) { | |
bcf1_t *b2; | |
b2 = bcf_dup(b); | |
bcf_destroy1(b2); | |
} | |
++cnt; | |
} | |
bcf_destroy1(b); | |
bcf_close(fp); | |
fprintf(stderr, "%ld records processed.\n", cnt); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment