Results 1 to 1 of 1
Hello Everyone,
I am trying to write a command using awk but I am a bit stuck....
I need to compare the characters in 19th and 20th column and if ...
- 07-27-2011 #1Just Joined!
- Join Date
- May 2011
- Location
- Germany
- Posts
- 5
awk command
Hello Everyone,
I am trying to write a command using awk but I am a bit stuck....
I need to compare the characters in 19th and 20th column and if they are of a particular pattern, it needs to be counted. So the two columns look like this
Ref Obs
A T
T C
G A
C G
So I need them in two groups- Ti and Tv, so any combination of A-C, T-G, G-T and C-A needs to go under Tv and any combination of G-A , C-T, A-G and T-C needs to go under Ti.
So I need the output like this:
Ti Tv
24 20
So I tried something out but obviously, its not the right one :
$ awk '
BEGIN {
FORMAT="%-10s%-8s%-8s%-8s%s\n"
{printf FORMAT,"Ti","Tv"}
}
{ n[$1]++
Tv1_[$1] += ($18 == "A")&&($19 == "C" )
Tv2_[$1] += ($18 == "C")&&($19 == "A" )
Tv3_[$1] += ($18 == "T")&&($19 == "G" )
Tv4_[$1] += ($18 == "G")&&($19 == "T" )
Ti1_[$1] += ($18 == "A")&&($19 == "G" )
Ti2_[$1] += ($18 == "G")&&($19 == "A" )
Ti3_[$1] += ($18 == "C")&&($19 == "T" )
Ti4_[$1] += ($18 == "T")&&($19 == "C" )
}
END {
for (i in n) {
printf FORMAT,i,Ti_[Ti1,Ti2,Ti3,Ti4],Tv_[Tv1,Tv2,Tv3,Tv4]
}
}' details.txt
Any suggestions ? Thank you.
nandini_bn is online now Report Post Edit/Delete Message


Reply With Quote