-2

我有一个包含如下所示列的文件,

 chr1 412573  .   A   C 2754.00      .  AC=2;AF=1.00;AN=2;DP=59;Dels=0.00;FS=0.000;HaplotypeScore=0.0000;MLEAC=2;MLEAF=1.00;MQ=59.22;M  
 Q0=0;QD=35.08;SB=-5.570e+02;resource.EFF=NON_SYNONYMOUS_CODING(MODERATE|MISSENSE|gCg/gTg|A124V
|RBFA|protein_coding|CODING|ENSCAFT00000037436|5)

我想拆分并提取第 8 列中的数据,如下所示,

chr1 412573  .   A   C 2754.00      .  59    59.22    NON_SYNONYMOUS_CODING    MODERATE    MISSENSE    gCg/gTg    A124V    RBFA   protein_coding    CODING    ENSCAFT00000037436    5
4

2 回答 2

1
awk '/DP=/ || /MQ=/ || /EFF=/ {gsub("[\\|()]", "\t"); print $2}' RS=';' ORS='\t' FS='='

结果

59 59.22 NON_SYNONYMOUS_CODING 中度错义 gCg/gTg A124V RBFA 蛋白质编码编码 ENSCAFT00000037436 5
于 2013-05-15T07:52:29.773 回答
0

One way using awk:

Content of script.awk:

BEGIN {
        FS = ";"
}

{
        str = $NF
        sub( /^[^=]*=/, "", str )
        gsub( /[|()]/, "\t", str )
        print str
}

Run it like:

awk -f script.awk infile

That yields:

NON_SYNONYMOUS_CODING   MODERATE    MISSENSE    gCg/gTg A124V   RBFA    protein_coding  CODING  ENSCAFT00000037436  5
于 2013-05-15T07:44:30.270 回答