I am trying to confirm the counts from another code and tried the below awk
, but the syntax is incorrect. Basically, outputting the counts of each condition in $8. Thank you
awk '$8==/TYPE=snp/ /TYPE=ins/ /TYPE=del/ {count++} END{print count}' "C:\Users\cmccabe\Desktop\counts\TSVC_004_HIQ.txt" > "C:\Users\cmccabe\Desktop\counts\count.txt"
Desired output
snp=5000
ins=200
del=100
Aia
December 9, 2015, 10:31am
2
Would that work?
awk '$8 ~ /TYPE/ {split($8, type, "="); count[type[2]]++} END{for(t in count){print t"="count[t]}}' "C:\Users\cmccabe\Desktop\counts\TSVC_004_HIQ.txt" > "C:\Users\cmccabe\Desktop\counts\count.txt"
in the spirit of cmccabe:
awk '$8=="snp"{a++};$8=="ins"{b++};$8=="del"{c++}END{print "snp="a "\n" "ins="b "\n" "del="c}'
Aia
December 9, 2015, 11:06am
4
$8
appears to contain the string TYPE=snp
, etc..., therefore that would not do. Perhaps:
awk '$8 ~ /snp/ {a++} $8 ~ /ins/ {b++} $8 ~ /del/ {c++}END{print "snp="a "\n" "ins="b "\n" "del="c}'
1 Like
Ok, i correct...
awk '$8=="TYPE=snp"{a++};$8=="TYPE=ins"{b++};$8=="TYPE=del"{c++}END{print "snp="a "\n" "ins="b "\n" "del="c}'
1 Like
RudiC
December 9, 2015, 12:21pm
6
Try also
awk 'sub (/^TYPE=/, "", $8) {CNT[$8]++} END {for (c in CNT) print c "=" CNT[c]}' file
1 Like