Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kennels
    Senior Member
    • Feb 2011
    • 149

    #1

    Appending /1 or /2 to read identifiers (illumina 1.8+ format)

    Hello,

    I've just started working with Illumina 1.8+ format fastq files, and the read identifiers don't contain the /1 or /2 suffixes for PE reads any more, and this information is contained in column 2.

    I'm not scripting savvy, and i'm just using a very clumsy perl script to add this information:

    Code:
    perl -e ' while(<>) { @cols=split("\t", $_); $cols[0] = "$cols[0]/1"; print "$cols[0]\t$cols[1]\t$cols[2]\t$cols[3]\t$cols[4]\t$cols[5]\t$cols[6]\t$cols[7]\t$cols[8]\t$cols[9]\t$cols[10]\t$cols[11]"; } exit '
    I'm wondering if anyone can share a good sed or awk command or script to do this more efficiently/quickly as I'm working with a few Gb to tens of Gb+ sized files. I've been trying but can't get the syntax right.

    thanks,
  • simonandrews
    Simon Andrews
    • May 2009
    • 870

    #2
    From what I can see the new fastq files are space delimited, not tab. Since only the header line should contain any spaces you could probably get away with something as simple as:

    Code:
    perl -pe 's/ /\/1 /'
    which should be pretty quick.

    Comment

    • pmiguel
      Senior Member
      • Aug 2008
      • 2328

      #3
      But, if you really want a sed solution, the equivalent would be:

      Code:
      sed -e 's% \([0-9]\)%/\1 %'
      or just:

      Code:
      sed -e 's% %/%'
      if you want the exact results that Simon's perl one-liner would give you. But the reads I deal with are nearly always indexed, so they look like:

      @H-148:620D1KACXX:8:1101:1853:1942 2:Y:0:GCCAAT
      So, I don't know what havoc the extra fields will play. My first sed expression results in:

      @H-148:620D1KACXX:8:1101:1853:1942/2 :Y:0:GCCAAT
      whereas the second gives:

      @H-148:620D1KACXX:8:1101:1853:1942/2:Y:0:GCCAAT
      Oh, one other I have to include because it highlights a power that sed has, but perl does not:

      Code:
      sed -e 's% %/%' -e 's/:/ /7'
      it gives the (possibly more desirable)

      @H-148:620D1KACXX:8:1101:1853:1942/2 Y:0:GCCAAT
      result. Get it? The final "7" denotes that sed should do the substitution the seventh time it sees ":" on the line! Not a feature in perl s/// commands! Although, no doubt, someone will be able to dig up a pragma that will confer this ability upon perl.

      --
      Phillip

      Comment

      • Kennels
        Senior Member
        • Feb 2011
        • 149

        #4
        Thanks for the help.

        that sed function is really cool. I really need to sit down and learn these things properly...

        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
          ...
          10-14-2026, 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, Yesterday, 11:13 AM
        0 responses
        19 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 10:48 AM
        0 responses
        18 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-15-2026, 10:52 AM
        0 responses
        36 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-14-2026, 05:39 AM
        0 responses
        42 views
        0 reactions
        Last Post SEQadmin2  
        Working...