Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • pipe two inputs to a command (coverageBed)

    Hi,
    I am trying to run coverageBed on my data. Since it is huge, I have to split the data into each chromosome and run them separately. coverageBed takes two input files, the data.bed file (contains the sequencing data) and the windows.bed (a file with defined windows in which the sequencing coverage has to be estimated). I thought it would be a good idea to grep for each chromosome in the data.bed and windows.bed and pipe that input to the coverageBed command. How do I simultaneously grep from two files and pass the two outputs to coverageBed? I figured how I can pipe one file (shown below), but struggling with piping two files simultaneously.
    grep -w 'chr[1]' data.bed| coverageBed -counts -a stdin -b ExtraFiles_for_Analysis/windows_chr1.bed | sortBed -i stdin > chr1_coverage.txt

    In the above command, windows_chr1.bed is the file containing only the windows in chromosome-1, which I had to create separately. So my goal is not to create separate files for each chromosomes a priori, and instead be able to create that in the same line.

    And secondly, can I use some loop so that I can do this for each chromosome?
    I searched a lot in online forums and couldn't get anything.
    Thanks for any help or pointers.
    Hari

  • #2
    You could do this with named pipes.

    Code:
    mkfifo data
    mkfifo windows
    This will create two special files in the current directory named data and windows respectively.

    Code:
    grep -w 'chr[1]' data.bed > data &
    grep -w 'chr[1]' windows.bed > windows &
    
    coverageBed -counts -a data -b windows | sortBed -i stdin > chr1_coverage.txt
    When the coverageBed task completes the grep jobs in the background will terminate. You can then reuse the same named pipes while iterating through each of the chromosomes.

    Comment


    • #3
      coverageBed -counts -a <(grep chr1 data.beg) -b <(grep chr1 windows.beg)

      Comment


      • #4
        Originally posted by lh3 View Post
        coverageBed -counts -a <(grep chr1 data.beg) -b <(grep chr1 windows.beg)
        That looks great, thanks.
        Of course do not forget the "-w" option to only grep the chr1 and not chr10, chr11 etc (I would actually use awk ' $1=="chr1" ' < data.bed).

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM
        • seqadmin
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        30 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        32 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        28 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        53 views
        0 likes
        Last Post seqadmin  
        Working...
        X