I have two files, file A looks like this:
1 101427 GENE|ACT-A 1 101589 GENE|ACT-B 0.0357 1 101427 GENE|ACT-A 1
awk 'FNR == NR {keys[$1]; next} $3 in keys || $6 in keys' fileB fileA
I would use the awk solution as it only has to examine each file once, but here's an alternative.
{ join -1 3 <(sort -k3 fileA) <(sort fileB) join -1 6 <(sort -k6 fileA) <(sort fileB) } > output