Hello,
I want to see if element exists in array, if so then, check it's corresponding value.
Column 4 is position and column 1 is the chromosome for it. There are duplicates for one position on one chromosome.
I want to check if same position exists on different chromosome:
Data format:
2 rs267607987 0 47702411 0 T
2 seq-rs587779123 0 47702411 0 I
2 seq-rs587779124 0 47702411 0 D
11 seq-rs730880711 0 47364479 0 I
11 seq-rs863225110 0 47364479 0 I
11 seq-rs863225271 0 47364479 0 I
11 seq-rs397515973 0 47359006 0 D
11 seq-rs727503187 0 47359006 0 D
11 seq-rs730880654 0 47359006 0 D
17 DUP-rs80358150 0 41209068 0 C
17 rs273901754 0 41209068 0 D
17 rs80358150 0 41209068 0 C
17 seq-rs5827779124 0 47702411 0 D
I want to check if position column 4 has duplicates on different values for column 1.
in this case:
2 seq-rs587779124 0 47702411 0 D
17 seq-rs5827779124 0 47702411 0 D
Following code fails:
awk ' {if ($4 in arr) && if (arr[$4]==$1){ print arr[$4],$4} else {arr[$4]=$1} }' testcol.txt
Error:
awk: {if ($4 in arr) && if (arr[$4]==$1){ print arr[$4],$4} else {arr[$4]=$1} }
awk: ^ syntax error
Would really appreciate any guidance here.