awkbioinformaticsgenome

How to use AWK for printing a line only if that line is different from the previous one?


Very new into bioinformatics here!

I have a file that looks like this:

Where $1 is a gene, $2 is a match with a chromosome in another spp, $3 is the starting point of that match. But I have too many hits. In order to graphic this I need to reduce the hits so I figured I´ll use just one match of a gene with the same chromosome with whatever value on col$3 (it doesn´t matter which value, but I do need that value).

I tried to use awk so that it prints the line only if $1 AND $2 are different from the previous one. But it is not working for me. In this example the output should be:

Thank you in advance!


Solution

  • A more simple way.

    awk '$1$2!=n;{n=$1$2}'