Limiting interval sizes with awk
1
1
Entering edit mode
4.5 years ago
rbronste ▴ 420

Kind of a basic awk question. I have a bed file where I have been doing the following to limit interval sizes to those under 1000bp with the following awk script, how would I go about doing the same thing but limiting the output to those between 150-200bp only? Thanks!

awk '{if($3-$2 <= 1000) print}' test.bedpe > test_under1000.bedpe
awk bed bedtools bedops interval • 1.4k views
ADD COMMENT
1
Entering edit mode

But something like the condition below will not work in awk, will it?

awk '{if(150 <= $3-$2 <= 200) print}' test.bedpe > test_under150_200.bedpe

Many thanks!

Natasha

ADD REPLY
1
Entering edit mode

This seems to work fine:

awk '{if($3-$2 >= 150 && $3-$2 <= 200) print}' test.bedpe > test_between_150-200.bedpe
ADD REPLY
6
Entering edit mode
4.5 years ago
h.mon 35k

Use awk AND operator:

awk '{if (CONDITION && CONDITION) print}' test.bedpe > test_between_150-200.bedpe
ADD COMMENT

Login before adding your answer.

Traffic: 1968 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