I have a csv file from which I extract data relevant to me. These are reference numbers on the one hand and genetic information in the form of the letters G, A, T and C on the other.
Content csv:
1,S188823,188823,,,,ACTCTCGA,,CTGTACCA,ID23,
1,S189843,189843,,,,ACCCTGGA,,CTTGTACA,ID23,
...
The information relevant to me is 188823,,,,ACCCTGGA,,CTTGTACA
From each line. Duplicates must be removed in the process. Also the first two lines have to be truncated.
This is what I currently do:
cat File.csv | cut -d "," -f 3,9,7 | uniq | sed -e '1d' -e '2d'
The result looks like this:
188823,ACTCTCGA,CTGTACCA
189843,ACCCTGGA,CTTGTACA
...
But now two things have to be done, which I fail at. Field 3 and field 2 have to be swapped
188823,CTGTACCA,ACTCTCGA
189843,CTTGTACA,ACCCTGGA
...
and now from field2 the bases have to be "reverse complemented" This means that each A becomes a T, each C becomes a G, each G becomes a C and each T becomes an A and the sequence order is reversed. So, CTGTACCA
becomes TGGTACAG
.
The final result must then look like this:
188823,TGGTACAG,ACTCTCGA
188823,TGTACAAG,ACCCTGGA
I hope it is understandable and you can help me. Some help about reverse complement building can be found here: revcomp builder online