awk for interval midpoints and length
1
1
Entering edit mode
4.8 years ago
rbronste ▴ 420

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 • 965 views
ADD COMMENT
3
Entering edit mode
4.8 years ago
$ awk '{print int(($2+$3)/2), $3-$2}' test.txt
10075 149
10049 82
10116 182
10115 114
ADD COMMENT

Login before adding your answer.

Traffic: 2542 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6