Question: awk for interval midpoints and length
1
gravatar for rbronste
8 months ago by
rbronste360
rbronste360 wrote:

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 • 184 views
ADD COMMENTlink modified 8 months ago by zx87549.6k • written 8 months ago by rbronste360
3
gravatar for cpad0112
8 months ago by
cpad011214k
India
cpad011214k wrote:
$ awk '{print int(($2+$3)/2), $3-$2}' test.txt
10075 149
10049 82
10116 182
10115 114
ADD COMMENTlink written 8 months ago by cpad011214k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1175 users visited in the last hour