incorrect count of unique text in awk

Viewed 80

I am getting the wrong counts using the awk below. The unique text in $5 before the - is supposed to be counted.

input

chr1    955543  955763  chr1:955543-955763  AGRN-6|gc=75    1   15
chr1    955543  955763  chr1:955543-955763  AGRN-6|gc=75    2   16
chr1    955543  955763  chr1:955543-955763  AGRN-6|gc=75    3   16
chr1    1267394 1268196 chr1:1267394-1268196    TAS1R3-46|gc=68.2   553 567
chr1    1267394 1268196 chr1:1267394-1268196    TAS1R3-46|gc=68.2   554 569
chr1    9781175 9781316 chr1:9781175-9781316    PIK3CD-276|gc=63.1  46  203
chr1    9781175 9781316 chr1:9781175-9781316    PIK3CD-276|gc=63.1  47  206
chr1    9781175 9781316 chr1:9781175-9781316    PIK3CD-276|gc=63.1  48  206
chr1    9781175 9781316 chr1:9781175-9781316    PIK3CD-276|gc=63.1  49  207

current output

1

desired output (AGRN,TAS1R3, PIK3CD) are unique and counted

3

awk

awk -F '[- ]' '!seen[$6]++ {n++} END {print n}' file
2 Answers
Related