Skip to content

Commit d936d18

Browse files
dmckeanpd3
authored andcommitted
Prune plugin logs in header with bcf_hdr_append_version
1 parent b0260a9 commit d936d18

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugins/prune.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef struct
6262
int ld_max_set[VCFBUF_LD_N];
6363
char *ld_annot[VCFBUF_LD_N], *ld_annot_pos[VCFBUF_LD_N], *cluster_annot;
6464
int ld_mask;
65-
int argc, region_is_file, target_is_file, output_type, ld_filter_id, rand_missing, nsites, ld_win, rseed, clevel;
65+
int argc, region_is_file, target_is_file, output_type, ld_filter_id, rand_missing, nsites, ld_win, rseed, clevel, record_cmd_line;
6666
int max_cluster;
6767
char *nsites_mode;
6868
int keep_sites;
@@ -93,6 +93,7 @@ static const char *usage_text(void)
9393
" -a, --annotate count|LD|RD|r2 Annotate with the number of variants within the -w window (\"count\"),\n"
9494
" or with the biggest LD, RD, or r2 value and the position of the record\n"
9595
" -f, --set-filter STR Apply soft filter STR instead of discarding the site (only with -m)\n"
96+
" --no-version Do not append version and command line to the header\n"
9697
" -m, --max count|LD|RD|r2=NUM Remove clusters of more than NUM sites (\"count\") or sites with LD, RD, or r2 bigger than NUM\n"
9798
" -n, --nsites-per-win N Keep at most N sites in the -w window. See also -N, --nsites-per-win-mode\n"
9899
" -N, --nsites-per-win-mode STR Keep sites with biggest AF (\"maxAF\"); sites that come first (\"1st\"); pick randomly (\"rand\") [maxAF]\n"
@@ -195,6 +196,8 @@ static void init_data(args_t *args)
195196
}
196197
if ( args->cluster_annot )
197198
bcf_hdr_printf(args->hdr,"##INFO=<ID=%s,Number=1,Type=Integer,Description=\"The number of variants within %d bp of the site\">",args->cluster_annot,args->ld_win);
199+
if (args->record_cmd_line)
200+
bcf_hdr_append_version(args->hdr, args->argc, args->argv, "bcftools_plugin_prune");
198201
if ( bcf_hdr_write(args->out_fh, args->hdr)!=0 ) error("[%s] Error: cannot write to %s\n", __func__,args->output_fname);
199202
if ( init_index2(args->out_fh,args->hdr,args->output_fname,
200203
&args->index_fn, args->write_index)<0 )
@@ -334,12 +337,14 @@ int run(int argc, char **argv)
334337
args->nsites_mode = "maxAF";
335338
args->rseed = time(NULL);
336339
args->clevel = -1;
340+
args->record_cmd_line = 1;
337341
static struct option loptions[] =
338342
{
339343
{"keep-sites",no_argument,NULL,'k'},
340344
{"randomize-missing",no_argument,NULL,1},
341345
{"AF-tag",required_argument,NULL,2},
342346
{"random-seed",required_argument,NULL,3},
347+
{"no-version",no_argument,NULL,4},
343348
{"exclude",required_argument,NULL,'e'},
344349
{"include",required_argument,NULL,'i'},
345350
{"annotate",required_argument,NULL,'a'},
@@ -371,6 +376,7 @@ int run(int argc, char **argv)
371376
args->rseed = strtol(optarg,&tmp,10);
372377
if ( tmp==optarg || *tmp ) error("Could not parse: --random-seed %s\n", optarg);
373378
break;
379+
case 4 : args->record_cmd_line = 0; break;
374380
case 'W':
375381
if (!(args->write_index = write_index_parse(optarg)))
376382
error("Unsupported index format '%s'\n", optarg);

0 commit comments

Comments
 (0)