comparative-genomics-project/workflow/scripts/keep_heaviest_edge_abc.awk

31 lines
444 B
Awk
Raw Permalink Normal View History

2024-11-04 11:37:20 +01:00
#!/usr/bin/env -S awk -f
# Usage: $0 file.abc > filtered_file.abc
BEGIN {
OFS = FS = "\t"
}
{
a=$1
b=$2
c=$3
if (a > b) {
tmp=a
a=b
b=tmp
}
if (!(b in graph[a])) {
graph[a][b] = c
} else {
if (graph[a][b] < c) {
graph[a][b] = c
}
}
}
END {
for (a in graph) {
for (b in graph[a]) {
print a, b, graph[a][b]
}
}
}