Unconfigured Ad

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

    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
          Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
          by SEQadmin2



          Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
          ...
          07-09-2026, 11:10 AM
        • SEQadmin2
          Cancer Drug Resistance: The Lingering Barrier to Rising Survival
          by SEQadmin2



          Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

          There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
          07-08-2026, 05:17 AM
        • GATTACAT
          Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
          by GATTACAT
          Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
          07-01-2026, 11:43 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Yesterday, 10:26 AM
        0 responses
        12 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-09-2026, 10:04 AM
        0 responses
        25 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-08-2026, 10:08 AM
        0 responses
        16 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-07-2026, 11:05 AM
        0 responses
        33 views
        0 reactions
        Last Post SEQadmin2  
        Working...