From ff6faf811a543ca2acebd81ecd0de727a6779a32 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 19 Nov 2013 11:08:45 -0500 Subject: [PATCH] r419: print the @PG line --- bwa.c | 2 ++ main.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bwa.c b/bwa.c index f8949f7d..33edd7f2 100644 --- a/bwa.c +++ b/bwa.c @@ -277,9 +277,11 @@ void bwa_idx_destroy(bwaidx_t *idx) void bwa_print_sam_hdr(const bntseq_t *bns, const char *rg_line) { int i; + extern char *bwa_pg; for (i = 0; i < bns->n_seqs; ++i) err_printf("@SQ\tSN:%s\tLN:%d\n", bns->anns[i].name, bns->anns[i].len); if (rg_line) err_printf("%s\n", rg_line); + err_printf("%s\n", bwa_pg); } static char *bwa_escape(char *s) diff --git a/main.c b/main.c index 8f767060..a7839240 100644 --- a/main.c +++ b/main.c @@ -1,9 +1,10 @@ #include #include +#include "kstring.h" #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.5a-r418" +#define PACKAGE_VERSION "0.7.5a-r419" #endif int bwa_fa2pac(int argc, char *argv[]); @@ -24,6 +25,8 @@ int main_mem(int argc, char *argv[]); int main_pemerge(int argc, char *argv[]); +char *bwa_pg; + static int usage() { fprintf(stderr, "\n"); @@ -63,7 +66,11 @@ int main(int argc, char *argv[]) { int i, ret; double t_real; + kstring_t pg = {0,0,0}; t_real = realtime(); + ksprintf(&pg, "@PG\tID:bwa\tPN:bwa\tVN:%s\tCL:%s", PACKAGE_VERSION, argv[0]); + for (i = 1; i < argc; ++i) ksprintf(&pg, " %s", argv[i]); + bwa_pg = pg.s; if (argc < 2) return usage(); if (strcmp(argv[1], "fa2pac") == 0) ret = bwa_fa2pac(argc-1, argv+1); else if (strcmp(argv[1], "pac2bwt") == 0) ret = bwa_pac2bwt(argc-1, argv+1); @@ -93,5 +100,6 @@ int main(int argc, char *argv[]) fprintf(stderr, " %s", argv[i]); fprintf(stderr, "\n[%s] Real time: %.3f sec; CPU: %.3f sec\n", __func__, realtime() - t_real, cputime()); } + free(bwa_pg); return ret; }