Dear all, I have a file as shown below:
chrBase chr base strand coverage freqC freqT
chrLG1.6955 chrLG1 6955 R 12 0.00 100.00
I would like to print this as a new file with the following format :
Chr"\t"Position"\t"Coverage"\t"Numbers_of_reads_in_T
Which will give me
chrLG1 6955 12 12
Usually I will just do
awk'{print$1"/t"$2} input.txt > output.txt
but this time it involves some mathematical conversions. Can anyone here guide me on how to do this conversion in UNIX?
Many thanks in advance and I wish you a good Monday!
Awk has rounding through using printf in place of print, but there's a gotcha for the unweary ... Awk uses C's sprintf function, which by default does 'even' rounding on tie breaks (rounding towards the nearest even number) ...
Depending on your C libraries, it's configurable (see here), but in my experience, few systems support this.
However, assuming the calculated proportion must basically fall back to an integer number of reads +- float arithmetic error, this shouldn't make any difference here. So...
Good to know!