diff --git a/NEWS b/NEWS index be7091e3c..2712236c0 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ Changes affecting specific commands: - Support higher-ploidy genotypes with `-H, --haplotype` (#1892) + - Allow `--mark-ins` and `--mark-snv` with a character, similarly to `--mark-del` + * bcftools merge - New `-M, --missing-rules` option to control the behavior of merging of vector tags diff --git a/consensus.c b/consensus.c index 85cb8a44d..6ba23f2b9 100644 --- a/consensus.c +++ b/consensus.c @@ -54,8 +54,8 @@ #define PICK_SHORT 8 #define PICK_IUPAC 16 -#define TO_UPPER 0 -#define TO_LOWER 1 +#define TO_UPPER 1 +#define TO_LOWER 2 typedef struct { @@ -466,25 +466,37 @@ static char *mark_del(char *ref, int rlen, char *alt, int mark) static void mark_ins(char *ref, char *alt, char mark) { int i, nref = strlen(ref), nalt = strlen(alt); - if ( mark=='l' ) + if ( mark==TO_LOWER ) for (i=nref; imark_del = optarg[0]; break; case 2 : - if ( !strcasecmp(optarg,"uc") ) args->mark_ins = 'u'; - else if ( !strcasecmp(optarg,"lc") ) args->mark_ins = 'l'; + if ( !strcasecmp(optarg,"uc") ) args->mark_ins = TO_UPPER; + else if ( !strcasecmp(optarg,"lc") ) args->mark_ins = TO_LOWER; + else if ( !optarg[1] && optarg[0]>32 && optarg[0]<127 ) args->mark_ins = optarg[0]; else error("The argument is not recognised: --mark-ins %s\n",optarg); break; case 3 : - if ( !strcasecmp(optarg,"uc") ) args->mark_snv = 'u'; - else if ( !strcasecmp(optarg,"lc") ) args->mark_snv = 'l'; + if ( !strcasecmp(optarg,"uc") ) args->mark_snv = TO_UPPER; + else if ( !strcasecmp(optarg,"lc") ) args->mark_snv = TO_LOWER; + else if ( !optarg[1] && optarg[0]>32 && optarg[0]<127 ) args->mark_snv = optarg[0]; else error("The argument is not recognised: --mark-snv %s\n",optarg); break; case 'p': args->chr_prefix = optarg; break; diff --git a/doc/bcftools.txt b/doc/bcftools.txt index 83ed92d64..5e1a03591 100644 --- a/doc/bcftools.txt +++ b/doc/bcftools.txt @@ -957,13 +957,13 @@ Note that the *-H, --haplotype* option requires the *-s, --samples* option, unle from REF,ALT columns and sample genotypes were not considered. *--mark-del* 'CHAR':: - instead of removing sequence, insert CHAR for deletions + instead of removing sequence, insert character CHAR for deletions -*--mark-ins* 'uc'|'lc':: - highlight inserted sequence in uppercase (uc) or lowercase (lc), leaving the rest of the sequence as is +*--mark-ins* 'uc'|'lc'|'CHAR':: + highlight inserted sequence in uppercase (uc), lowercase (lc), or a provided character CHAR, leaving the rest of the sequence as is *--mark-snv* 'uc'|'lc':: - highlight substitutions in uppercase (uc) or lowercase (lc), leaving the rest of the sequence as is + highlight substitutions in uppercase (uc), lowercase (lc), or a provided character CHAR, leaving the rest of the sequence as is *-m, --mask* 'FILE':: BED file or TAB file with regions to be replaced with N (the default) or as specified by diff --git a/test/consensus.19.out b/test/consensus.19.out new file mode 100644 index 000000000..84a241db0 --- /dev/null +++ b/test/consensus.19.out @@ -0,0 +1,20 @@ +>1:2-501 +TAC:A:AT:Tga::t+++AT:AaAAAGAACATAACCTACGTATCAACTAAAGTGGTTGTT +TG:AGAAAAGGAAGACTTAAAAAGAGTCAGTACTAACCTACATAATATATACAATGTTCA +TTAAATAATAAAATGAGCTCATCATACTTAGGTCATCATAAATATATCTGAAATTCACAA +ATATTGATCAAATGGTAAAATAGACAAGTAGATTTTAATAGGTTAAACAATTACTGATTC +TCTTGAAAGAATAAATTTAATATGAGACCTATTTCATTATAATGAACTCACAAATTAGAA +ACTTCACACTGGGGGCTGGAGAGATGGCTCAGTAGTTAAGAACACTGACTGCTCTTCTGA +AGGTCCTGAGTTCAAATCCCAGCAACCACATGGTGACTTACAACCATCTGTAATGACATC +TGATGCCCTCTGGTGTGTCTGAAGACAGCTACAGTGTACTTACATAAAATAATAAATAAA +TCTTTAAAAACAAAAAAAAAGAA +>2 +gaagatcttttccttattaaggatctgaagctctgtagatttgtattctattaaacatgg +A:::attagtgattttccatattctttaagtcattttagagtaatgtgttcttaagat:: +:tcagaaaaacaaaaacttgtgctttcctgtttgaaaaacaaacagctgtggggaatgG+ ++++++++tgtcgggacagcctttttatA----------aaataatgttgaggctttgata +cgtcaaagttatatttcaaatggaatcacttagacctcgtttctgagtgtcaatggccat +attggggAtttgctgctgccaatgacaGcacaccctgggaatgccccaactacttactac +aaagcagtgttacatggagaagatcttcaagagtctttttgctagatctttccttggctt +ttgatgtgactcctctcaataaaatccacagtaatatagtgagtggtctcctgctccaaa +ccagtatt:cagacacagttaatccagac diff --git a/test/test.pl b/test/test.pl index ac3131f46..dd63de7b8 100755 --- a/test/test.pl +++ b/test/test.pl @@ -786,6 +786,7 @@ run_test(\&test_vcf_consensus,$opts,in=>'consensus.13',out=>'consensus.13.out',fa=>'consensus.13.fa',args=>'-s -'); run_test(\&test_vcf_consensus,$opts,in=>'consensus.14',out=>'consensus.14.out',fa=>'consensus.14.fa',args=>'-s -'); run_test(\&test_vcf_consensus,$opts,in=>'consensus.12',out=>'consensus.15.out',fa=>'consensus.12.fa',args=>'-s - --mark-del - --mark-ins uc --mark-snv uc'); +run_test(\&test_vcf_consensus,$opts,in=>'consensus.12',out=>'consensus.19.out',fa=>'consensus.12.fa',args=>'-s - --mark-del - --mark-ins + --mark-snv :'); run_test(\&test_vcf_consensus,$opts,in=>'consensus.15',out=>'consensus.17.out',fa=>'consensus.15.fa',args=>'-H I --mark-ins lc --mark-snv lc'); run_test(\&test_vcf_consensus,$opts,in=>'consensus.16',out=>'consensus.18.out',fa=>'consensus.fa',args=>'-s - -I'); run_test(\&test_vcf_consensus,$opts,in=>'consensus.16',out=>'consensus.18.out',fa=>'consensus.fa',args=>'-H I');