Question: awk for interval midpoints and length
1
gravatar for rbronste
4 weeks ago by
rbronste340
rbronste340 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 • 97 views
ADD COMMENTlink modified 4 weeks ago by zx87549.0k • written 4 weeks ago by rbronste340
3
gravatar for cpad0112
4 weeks ago by
cpad011212k
India
cpad011212k wrote:
$ awk '{print int(($2+$3)/2), $3-$2}' test.txt
10075 149
10049 82
10116 182
10115 114
ADD COMMENTlink written 4 weeks ago by cpad011212k
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: 795 users visited in the last hour