As mentioned above, it does not seem to work for some lines. I tested also on some other intervals.
• 0 views
•
link
Kind of a basic awk question but just trying to take the following intervals:
chr1 10001 10150
chr1 10008 10090
chr1 10025 10207
chr1 10058 10172
And generate a file output with a single command that in the first column has the midpoint of each and in the second column next to it has the entire interval length, such as this:
10075 149
10049 82
10116 182
10115 114
Thanks.
$ awk '{print int(($2+$3)/2), $3-$2}' test.txt
10075 149
10049 82
10116 182
10115 114
Log in to answer this question.
Are we sure your expected output is correct, doesn't seem to match with cpad's answer.
Mean calculations in expected output are incorrect. It seems OP pasted exactly half of the expected range values to the last two numbers in mean column @ zx8754