retrieving rows from a bed file
Hello .
my goal is to have this kind of bed file:

and be able to enter a chrom number and a range between chromeStart and chromeEnd, and to recieve all rows that match it. what is the best way to do it? Thanks
• 1,497 views
•
link
2 answers
Some clean-up work is needed. Export your file from Excel as a tab-delimited file. Clean it of Microsoft line endings and make a headerless, sorted file via sort-bed:
$ tr -d '\r' elements.tsv | sort-bed - > elements.bed
Then via bedops:
$ CHROM=chr1
$ START=12345
$ END=23456
$ bedops -e 100% elements.bed <(echo -e "${CHROM}\t${START}\t${END}") > answer.bed
The file answer.bed will contain all elements within the specified bounds, on the specified chromosome. Adjust CHROM, START, and END as needed.
Reference:
• 0 views
•
link
awk -F '\t' '($1=="chr1" && !( $2>10000 || $3 <= 100))' input.bed
or use bedtools intersect
• 0 views
•
link
Log in to answer this question.