Linux awk给fasta中重复的染色体名做重复标记

发布时间 2023-10-13 14:38:01作者: 小鲨鱼2018

 

001、

[root@pc1 test1]# ls
a.txt
[root@pc1 test1]# cat a.txt       ## 测试文件
>jcf7180003470556
2 7
>jcf7180003470556
3 8
>jcf7180003470552
4 9 6
>jcf7180003470546
5 3
>jcf7180003470558
6 2
>jcf7180003470556
7 1
>jcf7180003470550
8 5
>jcf7180003470558
10 4 3
[root@pc1 test1]# awk '{if($0 ~ />/) {ay[$0]++}; if($0 ~ />/ && ay[$0] > 1) {$0 = $0"_"ay[$0]}; print $0}' a.txt
>jcf7180003470556             ## 给重复的染色体名做标记
2 7
>jcf7180003470556_2
3 8
>jcf7180003470552
4 9 6
>jcf7180003470546
5 3
>jcf7180003470558
6 2
>jcf7180003470556_3
7 1
>jcf7180003470550
8 5
>jcf7180003470558_2
10 4 3