Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lisann_5
    Junior Member
    • Jan 2012
    • 6

    #1

    manipulate sequences in Fastq files

    Dear All,

    I have 20x illumina sequences data in large fastq files. Each file contains a sequence length of 21 nucleotides. I would like to remove the first 4 nucleotides from all reads in the files.

    i.e.

    @D5N3XBQ1:129:C0T9LACXX:1:1101:1227:2122 1:N:0:
    CATGATTTGATATTTAGGGCTT
    +
    HIFHIEGHIIFHGIIGHIIIDH
    @D5N3XBQ1:129:C0T9LACXX:1:1101:1150:2163 1:N:0:
    CATGATGACATAGAAATAATTT
    +
    IIFIIIIIIIIIIIFIFIIIFI
    @D5N3XBQ1:129:C0T9LACXX:1:1101:1155:2248 1:N:0:
    CATGAAGACAAAGCCTCTATGA

    to

    @D5N3XBQ1:129:C0T9LACXX:1:1101:1227:2122 1:N:0:
    ATTTGATATTTAGGGCTT
    +
    HIFHIEGHIIFHGIIGHIIIDH
    @D5N3XBQ1:129:C0T9LACXX:1:1101:1150:2163 1:N:0:
    ATGACATAGAAATAATTT
    +
    IIFIIIIIIIIIIIFIFIIIFI
    @D5N3XBQ1:129:C0T9LACXX:1:1101:1155:2248 1:N:0:
    AAGACAAAGCCTCTATGA

    I am new to bioinformatics and would appreciate a few pointers on the best way to get this done with the command line in Linux. Thanks, Lisanne
  • TiborNagy
    Senior Member
    • Mar 2010
    • 329

    #2
    awk '{if(NR%4==2){print substr($0,5,length($0))}else{print}}' file.fastq

    Comment

    • maasha
      Senior Member
      • Apr 2009
      • 153

      #3
      Using Biopieces:

      Code:
      read_fastq -i in.fq | extract_seq -b 4 | write_fastq -o out.fq -x

      Comment

      • maubp
        Peter (Biopython etc)
        • Jul 2009
        • 1544

        #4
        You should probably learn to program - e.g. Perl, Python, Ruby - whatever your local gurus use would be sensible as you'd have someone nearby to help.

        Here's a high-level Biopython solution:

        Code:
        from Bio import SeqIO
        records = (rec[4:] for rec in SeqIO.parse("input.fastq", "fastq"))
        count = SeqIO.write(records, "output.fastq", "fastq")
        print "Trimmed %i FASTQ records" % count
        That uses lots of objects and would be a bit slow on large files, but it is quite simple and could be used on many other supported file formats. See http://news.open-bio.org/news/2009/0...on-fast-fastq/ which would suggest something like this using Python strings (much faster but FASTQ specific):

        Code:
        from Bio.SeqIO.QualityIO import FastqGeneralIterator
        handle = open("output.fastq", "w")
        for title, seq, qual in FastqGeneralIterator(open("input.fastq")) :
            handle.write("@%s\n%s\n+\n%s\n" % (title, seq[4:], qual[4:]))
        handle.close()
        Similarly if you want to learn Perl or Ruby or Java, there are FASTQ modules in BioPerl, BioRuby and BioJava. See http://dx.doi.org/10.1093/nar/gkp1137
        Last edited by maubp; 10-25-2012, 02:30 AM. Reason: typo

        Comment

        • lisann_5
          Junior Member
          • Jan 2012
          • 6

          #5
          Thanks!

          Thank you all for the replay. I found my solution for this problem by maasha!

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
            by SEQadmin2



            CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

            Despite this, “CRISPR helped turn genome editing from a specialized technique into
            ...
            07-31-2026, 11:01 AM
          • SEQadmin2
            Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
            by SEQadmin2


            Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

            The systematic characterization of the human proteome has
            ...
            07-20-2026, 11:48 AM
          • 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

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, Yesterday, 07:41 AM
          0 responses
          9 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 08-03-2026, 10:13 AM
          0 responses
          25 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-31-2026, 02:55 AM
          0 responses
          38 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-24-2026, 12:17 PM
          0 responses
          25 views
          0 reactions
          Last Post SEQadmin2  
          Working...