vawk icon indicating copy to clipboard operation
vawk copied to clipboard

Parsing sample names as external variable are not recognized in the Sample field.

Open acontrerasg opened this issue 3 years ago • 1 comments

Given a multisample VCF file with different samples, if the sample name is given as a external variable, such as

sample_name="NA00001" zcat MULTI_VCF | vawk -v ext_var=$sample_name '{print S$ext_var$GT}'

will not work.
However when manually typing the name at the field, it does:

zcat MULTI_VCF | vawk '{print S$NA00001$GT}'

Any workaround?

Thanks!

acontrerasg avatar Jan 28 '22 14:01 acontrerasg

This is probably too late to be helpful, but writing for posterity.

This is a feature that I have also wanted but could not come up with an elegant way to do it. With the current structure it becomes difficult to parse a variable in that field. Maybe using an R-like pattern S['sample_name']['GT'] would be better but this would involve a substantial rewrite of the code, and may over-complicate things for most use cases.

For now, I have used vawk in a stream with BCFtools or some downstream parser when I've needed this behavior.

Open to a pull request on this issue though

cc2qe avatar May 10 '24 12:05 cc2qe