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
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by SEQadmin2




          NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
          10-30-2026, 06:46 AM
        • 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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        42 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-28-2026, 09:51 AM
        0 responses
        25 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 11:13 AM
        0 responses
        74 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 10:48 AM
        0 responses
        48 views
        0 reactions
        Last Post SEQadmin2  
        Working...