Question: 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
gravatar for akinyemiibukun
10 days ago by
akinyemiibukun20 wrote:

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
bash awk python • 88 views
ADD COMMENTlink modified 10 days ago by Pierre Lindenbaum123k • written 10 days ago by akinyemiibukun20
4
gravatar for Pierre Lindenbaum
10 days ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum123k wrote:

you're looking for bedtools intersect

ADD COMMENTlink written 10 days ago by Pierre Lindenbaum123k

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 REPLYlink written 2 days ago by akinyemiibukun20

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 REPLYlink written 2 days ago by Pierre Lindenbaum123k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 883 users visited in the last hour