我有一个CD命中结果文件(谁熟悉CD命中)。我想将另一个文件(由两列制表符分隔的表)的第二列值粘贴到相应匹配的RUN ID(如示例图像中以绿色突出显示的文件)旁边的CD-hit文件中。 “运行ID”是制表符分隔表(如下所示)中的第一列。sample image for CD-hit file
CD命中结果文件(第一个文件)
>Cluster 0
0 108nt, >ERR123456.1016542.1... *
1 108nt, >ERR123456.3114223.2... at +/93.52%
2 108nt, >ERR345678.217087.1... at -/89.81%
3 108nt, >ERR345678.291581.2... at -/92.59%
4 108nt, >ERR567890.3381351.2... at +/87.96%
5 108nt, >ERR987654.126640.2... at -/86.11%
6 108nt, >ERR987654.2492930.2... at +/84.26%
7 108nt, >ERR987654.3327702.1... at +/92.59%
>Cluster 1
0 108nt, >ERR876543.626414.2... *
1 108nt, >ERR123456.3213598.2... at +/85.19%
2 108nt, >ERR567890.1158706.2... at +/97.22%
3 108nt, >ERR345678.146372.1... at -/88.89%
4 108nt, >ERR765432.201531.2... at -/92.59%
5 108nt, >ERR765432.2770540.1... at -/87.04%
制表符分隔表(第二个文件)
ERR123456 1650
ERR345678 2350
ERR567890 1520
ERR876543 4520
ERR987654 3960
ERR765432 2550
我希望输出文件在制表符分隔表的第二列中包含其各自的RUN ID(表中的第一列)旁边的值。
>Cluster 0
0 108nt, >ERR123456.1016542.1... * 1650 #matching RUN ID
1 108nt, >ERR123456.3114223.2... at +/93.52% 1650
2 108nt, >ERR345678.217087.1... at -/89.81% 2350
3 108nt, >ERR345678.291581.2... at -/92.59% 2350
4 108nt, >ERR567890.3381351.2... at +/87.96% 1520
5 108nt, >ERR987654.126640.2... at -/86.11% 3960
6 108nt, >ERR987654.2492930.2... at +/84.26% 3960
7 108nt, >ERR987654.3327702.1... at +/92.59% 3960
>Cluster 1
0 108nt, >ERR876543.626414.2... * 4520
1 108nt, >ERR123456.3213598.2... at +/85.19% 1650
2 108nt, >ERR567890.1158706.2... at +/97.22% 1520
3 108nt, >ERR345678.146372.1... at -/88.89% 2350
4 108nt, >ERR765432.201531.2... at -/92.59% 2550
5 108nt, >ERR765432.2770540.1... at -/87.04% 2550
答案 0 :(得分:0)
$ awk 'NR==FNR{map[$1]=$2; next} {print $0, map[$2]}' FS='\t' tab.txt FS='[>.]' OFS='\t' cd.txt
>Cluster 0
0 108nt, >ERR123456.1016542.1... * 1650
1 108nt, >ERR123456.3114223.2... at +/93.52% 1650
2 108nt, >ERR345678.217087.1... at -/89.81% 2350
3 108nt, >ERR345678.291581.2... at -/92.59% 2350
4 108nt, >ERR567890.3381351.2... at +/87.96% 1520
5 108nt, >ERR987654.126640.2... at -/86.11% 3960
6 108nt, >ERR987654.2492930.2... at +/84.26% 3960
7 108nt, >ERR987654.3327702.1... at +/92.59% 3960
>Cluster 1
0 108nt, >ERR876543.626414.2... * 4520
1 108nt, >ERR123456.3213598.2... at +/85.19% 1650
2 108nt, >ERR567890.1158706.2... at +/97.22% 1520
3 108nt, >ERR345678.146372.1... at -/88.89% 2350
4 108nt, >ERR765432.201531.2... at -/92.59% 2550
5 108nt, >ERR765432.2770540.1... at -/87.04% 2550