我想创建 awk 代码,它将像这样修改文本:
- 制表符分隔所有列
- 删除所有以“##text”开头的列
- 并保留以“#header”开头的标题
我有这段代码,但不好:
#!/bin/bash
for i
in *.vcf;
do
awk 'BEGIN {print "CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILT\tINFO\tFORMAT"}' |
awk '{$1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7 "\t" $8 "\t" $9}' $i |
awk '!/#/' > ${i%.vcf}.tsv;
done
输入:
> ##fileformat=VCFv4.1
> ##FORMAT=<ID=GQX,Number=1,Type=Integer,Description="Minimum of {Genotype quality assuming variant position,Genotype quality assuming
> non-variant position}">
> #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT 1 chr1 10385471 rs17401966 A G 100.00 PASS DP=67;TI=NM_015074;GI=KIF1B;FC=Silent GT:GQ:AD:VF:NL:SB:GQX 0/1:100:29,38:0.5672:20:-100.0000:100
> chr1 17380497 rs2746462 G T 100.00 PASS DP=107;TI=NM_003000;GI=SDHB;FC=Synonymous_A6A;EXON GT:GQ:AD:VF:NL:SB:GQX 1/1:100:0,107:1.0000:20:-100.0000:100
> chr1 222045446 rs6691170 G T 100.00 PASS DP=99 GT:GQ:AD:VF:NL:SB:GQX 0/1:100:49,50:0.5051:20:-100.0000:100
输出:我想要什么
> CHROM POS ID REF ALT QUAL FILTER INFO etc...
> hr1 10385471 rs17401966 A
> G 100.00 PASS DP=67;TI=NM_015074;GI=KIF1B;