Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anagari
    Member
    • Jun 2011
    • 18

    #1

    Compare two files using awk command

    Hi all,

    I am trying to compare two files and get the output: The files are tab separated.

    File1:
    chr12 45677 45999 3000 a b
    chrX 90999 100000 34 c d

    File2:
    chr12 45680 46000 300 d g h k
    chrY 47800 80000 560 l y z m

    I want the all the columns from both files which has:

    The ‪first column should be same‬
    2 col of file 1 < 3col in file 2
    3col in file 1 > 2col in file 2


    I would really appreciate if anyone could help me in this regard ASAP.


    Thanks in advance,

    PS: I tried to use this command but, didn't understand how to change or modify it for my need:

    awk -F"/t" 'NR==FNR{a[$2]=$1FS$3;next} a[$3]{print $0 FS a[$3]}' 2.txt 1.txt > outputfile
  • steven
    Senior Member
    • Aug 2009
    • 269

    #2
    Hi,
    Not sure i got it, but my guess is that you are looking for overlapping intervals.. consider BEDtools.

    Comment

    • gringer
      David Eccles (gringer)
      • May 2011
      • 845

      #3
      I'm also not sure what you're asking here. Do you have an example output?

      for comparing files side-by-side, 'diff -y' is probably better than awk. If you want to join files on a common field, use 'join'. If you just want to combine files so that one file appears to the left of the other, use 'paste'. [all standard Linux commands]

      Comment

      • Clare S
        Junior Member
        • Jan 2010
        • 5

        #4
        Hi anagari,

        I don't know if this is the kind of path you want to go down (non command-line) but galaxy (usegalaxy.org) has built-in tools for finding overlapping intervals as well.

        You can essentially upload your files and then from the tools on the left select Operate on Genomic Intervals -> Intersect

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          Yesterday, 09:55 AM
        • SEQadmin2
          New Genomics Technologies Take Aim at Long-Standing Limits
          by SEQadmin2


          Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

          We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
          ...
          09-28-2026, 10:25 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Today, 10:52 AM
        0 responses
        8 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 05:39 AM
        0 responses
        17 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-13-2026, 09:56 AM
        0 responses
        15 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-09-2026, 11:14 AM
        0 responses
        27 views
        0 reactions
        Last Post SEQadmin2  
        Working...