Thank you very much it worked
• 108 views
•
link
Hi I have 2 files
file1
contig1 10037203 10038203 blah
contig1 10037203 10038203 blah
contig1 10037203 10038203 blah
file2
contig1 997329 938329 blab11
contig1 10037329 10038329 blah11
contig1 10037329 10038329 blah11
I want to get my output as below
contig1 10037203 10038203 blah
contig1 10037203 10038203 blah
contig1 10037203 10038203 blah
contig1 10037329 10038329 blah11
contig1 10037329 10038329 blah11
i,e., if the overlap exists first output all the overlapping ones of file1 and then of file2. Can anybody help me know how to do that?
sort-bed file1 > file1.sorted
sort-bed file2 > file2.sorted
bedops -e -1 file1.sorted file2.sorted > answer.bed
bedops -e -1 file2.sorted file1.sorted >> answer.bed
The answer.bed file will not be sorted per sort-bed since you catted on the results. If you want to maintain sorted order, then change the final line above to:
bedops -e -1 file2.sorted file1.sorted | bedops -u - answer.bed > final.answer.bed
Thank you very much it worked
Use BEDOPS bedmap and set operations for this problem:
$ sort-bed file1 > file1.sorted
$ sort-bed file2 > file2.sorted
$ bedmap --echo-map file1.sorted file2.sorted > 2_overlapped_by_1
$ bedmap --echo-map file2.sorted file1.sorted > 1_overlapped_by_2
$ bedops --everything 1_overlapped_by_2 2_overlapped_by_1 > answer.bed
Log in to answer this question.
http://bedtools.readthedocs.org/en/latest/content/example-usage.html
No Pierre, I have already checked with bedtools. It gives
m*nlines and I don't want that. For example if 3 lines in file 1 overlap with 2 lines in file 2 the output that bedtools produces is3*2=6lines but I want only 5 - 3 from the first file followed by 2 from the secondYou just need to modify the options,
-w -a -oto get what you need.