How to print lines of two file where column 2 and 3 of File 1 fall in between column 2 and 3 of file 2
1
1
Entering edit mode
4.6 years ago
Obex33 ▴ 30

I have a file delimited File 1:

NC_025345       4569   4950   KX838946.2      
NC_025345       16546   17066   KJ641660.1      
NC_025345       11996   12085   KX932454.2

And another File 2:

NC_025345.1     RefSeq  gene    5690    7513    .       +       .       ID=gene-NZ82_gp4;Dbxref=GeneID:20964334;Name=NZ82_gp4;gbkey=Gene;gene_biotype=protein_coding;locus_tag=NZ82_gp4
NC_025345.1     RefSeq  gene    8016    10046   .       +       .       ID=gene-NZ82_gp5;Dbxref=GeneID:20964335;Name=NZ82_gp5;gbkey=Gene;gene_biotype=protein_coding;locus_tag=NZ82_gp5
NC_025345.1     RefSeq  gene    10337   16933   .       +       .       ID=gene-NZ82_gp6;Dbxref=GeneID:20964336;Name=NZ82_gp6;gbkey=Gene;gene_biotype=protein_coding;locus_tag=NZ82_gp6

I want to use each lines of File 1 to search File 2 and print lines where column 2 and 3 of File 1 fall in between column 2 and 3 of File 2 to a new output file. So that I will have a final output file like this:

NC_025345       11996   12085   KX932454.2     NC_025345.1     RefSeq  gene    10337   16933   .       +       .       ID=gene-NZ82_gp6;Dbxref=GeneID:20964336;Name=NZ82_gp6;gbkey=Gene;gene_biotype=protein_coding;locus_tag=NZ82_gp6
Python awk bash • 784 views
ADD COMMENT
4
Entering edit mode
4.6 years ago

you're looking for bedtools intersect

ADD COMMENT
0
Entering edit mode

Hi, bedtools intersect does not work for this kind of file entries. Where column1 of file1 macthes column2 of file2 and then column 2 and 3 of file1 is >= and <= column 4 and 5 of file2 respectively, both lines should be printed in new file3. thanks

ADD REPLY
0
Entering edit mode

Hi, bedtools intersect does not work for this kind of file entries.

of course it doesn't. You'll first need to move your columns and then apply bedtools.

https://www.google.com/search?q=linux+change+columns+order

ADD REPLY

Login before adding your answer.

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