uniq_ppi_pair.awk 454 B

12345678910111213141516171819202122
  1. BEGIN{
  2. FS=OFS="\t"
  3. }
  4. {
  5. a[$1"\t"$2"\t"$3]=$0
  6. if(!pair[$1"\t"$2] || pair[$1"\t"$2] < $3){
  7. pair[$1"\t"$2]=$3
  8. }
  9. }
  10. END{
  11. for(i in pair){
  12. split(i,g,"\t")
  13. if(!pair[g[2]"\t"g[1]]){
  14. print a[i"\t"pair[i]]
  15. }else if(pair[g[2]"\t"g[1]] == pair[g[1]"\t"g[2]]){
  16. print a[i"\t"pair[i]]
  17. delete pair[g[2]"\t"g[1]]
  18. }else if(pair[g[2]"\t"g[1]] < pair[g[1]"\t"g[2]]){
  19. print a[i"\t"pair[i]]
  20. }
  21. }
  22. }