This is a test version of Biostars. For the public version, visit https://www.biostars.org.
comparing coordinates between two files

Hi,

I have two files with content:

File1

1   32030000    32080000    0.294180714 -1.124178317
1   32810000    32860000    -0.011122006    -0.508257648
2   32110000    32160000    -0.011122006    -0.613642043

File2:

1   32037085    32058287    NM_022164   
1   32219260    32229336    NR_036216   
2   32187705    32234664    NM_001294336    
2   32112847    32174768    NM_001856

Desired Output file:

1   32030000    32080000    0.294180714 -1.124178317   NM_022164
2   32110000    32160000    -0.011122006    -0.613642043   NM_001294336
2   32110000    32160000    -0.011122006    -0.613642043   NM_001856

I wanna compare the coordinate of first three columns between two files. and if the ranges overlap print them in seperate file..

Can anyone please guide me ??

Thanks!

linux ngs

I solved this partially by myself using bedtools...

bedtools intersect -a file1.bed -b file2.bed -u > output.txt

Thanks! That helped me.

1 answer

Just use bedmap in BEDOPS. Easy-peasy, lemon-squeezy:

$ bedmap --echo --echo-map-id-uniq A.bed B.bed > answer.bed

Log in to answer this question.