I need to automatize a command line software (pvacseq tools) where I need the 12th column of the row that contains "CHROM" of each file to be a parameter, this is what I have thought:
for i in *.vcf ; do pvacseq run \
$i \
awk'/CHROM/{print $12}' ${i}\
HLA-A*02:01,HLA-B*35:01,DRB1*11:01 \
MHCflurry MHCnuggetsI MHCnuggetsII NNalign NetMHC PickPocket SMM SMMPMBEC SMMalign \
"${i%%_vep*}_pvac-result" ; done
The problem seems that with each space of the awk command, pvacseq unserstands that a new option It's been introduced.
So I guess what I need is a way of automatizing the extraction of that column in a single command without spaces or a way for the program to understand that the awk command is a single command even thought if It has spaces.
About the replication of the problem I don't know how to approach It since installing pvaseq can be complicated.
2 answers
I found the solution
for i in *.vcf
do
x=$(awk '/CHROM/{print $12}' ${i})
pvacseq run $i $x HLA-A*02:01,HLA-B*35:01,DRB1*11:01 ...
# ^^
done
I'm not sure I understand your problem instead of awk'/CHROM/{print $12}' ${i}\
may be you just want:
$( bcftools query -l "${i}" | awk '(NR==3)')
using a command substitution https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html
Log in to answer this question.