Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Comment


    • #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


      • #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

        • seqadmin
          Best Practices for Single-Cell Sequencing Analysis
          by seqadmin



          While isolating and preparing single cells for sequencing was historically the bottleneck, recent technological advancements have shifted the challenge to data analysis. This highlights the rapidly evolving nature of single-cell sequencing. The inherent complexity of single-cell analysis has intensified with the surge in data volume and the incorporation of diverse and more complex datasets. This article explores the challenges in analysis, examines common pitfalls, offers...
          06-06-2024, 07:15 AM
        • seqadmin
          Latest Developments in Precision Medicine
          by seqadmin



          Technological advances have led to drastic improvements in the field of precision medicine, enabling more personalized approaches to treatment. This article explores four leading groups that are overcoming many of the challenges of genomic profiling and precision medicine through their innovative platforms and technologies.

          Somatic Genomics
          “We have such a tremendous amount of genetic diversity that exists within each of us, and not just between us as individuals,”...
          05-24-2024, 01:16 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 06-07-2024, 06:58 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 06-06-2024, 08:18 AM
        0 responses
        21 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 06-06-2024, 08:04 AM
        0 responses
        20 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 06-03-2024, 06:55 AM
        0 responses
        14 views
        0 likes
        Last Post seqadmin  
        Working...
        X