Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • alexd106
    Junior Member
    • Dec 2011
    • 4

    remove suffix from fastq sequence ID

    Dear all,

    I have paired end illumina sequences in two large (20GiB) fastq files, one containing the forward reads, the other the reverse reads. Each file contains sequence IDs with either a /1 or /2 suffix. I would like to remove these suffixes (for some downstream analysis) from all reads and output 2 fastq files.

    i.e.

    change

    @HWI-ST182_0249:5:1101:1093:2017#GTATGACG/1
    NCAGCTGCAGGGAGTTAATTCACAGCAGTTGAGAGCCCTTGCTGTACCAACAAAGGGATGTGTGATCTCCCGGTCCCTCTGCCCCCTCCCCTCCCAGCCGC
    +HWI-ST182_0249:5:1101:1093:2017#GTATGACG/1
    BS\cacccegggehgghhhhh_ghhhhhhhhhhhhghhhhhhhhgghhhhhhhhhhhbghghghhhgeggedd`bb^bbbbbbaaaaaa_abaaabbaaaa

    to

    @HWI-ST182_0249:5:1101:1093:2017#GTATGACG
    NCAGCTGCAGGGAGTTAATTCACAGCAGTTGAGAGCCCTTGCTGTACCAACAAAGGGATGTGTGATCTCCCGGTCCCTCTGCCCCCTCCCCTCCCAGCCGC
    +HWI-ST182_0249:5:1101:1093:2017#GTATGACG
    BS\cacccegggehgghhhhh_ghhhhhhhhhhhhghhhhhhhhgghhhhhhhhhhhbghghghhhgeggedd`bb^bbbbbbaaaaaa_abaaabbaaaa

    I am new to bioinformatics and would appreciate a few pointers on the best way to get this done.
    Thanks a million
    Alex
  • rahularjun86
    Member
    • Jan 2011
    • 58

    #2
    Dear Alex,
    You can use perl scripting, read the files, Split line if it is starting with @HWI or +HWI and print only the first part after splitting. And use else statement for printing rest of the sequence and quality lines as such.
    Or you can use unix 'awk' set FS in the BEGIN and then print $1 part if line is starting with seq Id @HWI or +HWI.
    Best wishes,
    Rahul
    Rahul Sharma,
    Ph.D
    Frankfurt am Main, Germany

    Comment

    • ehlin
      Member
      • Jan 2012
      • 12

      #3
      Originally posted by alexd106 View Post
      Dear all,

      I have paired end illumina sequences in two large (20GiB) fastq files, one containing the forward reads, the other the reverse reads. Each file contains sequence IDs with either a /1 or /2 suffix. I would like to remove these suffixes (for some downstream analysis) from all reads and output 2 fastq files.

      i.e.

      change

      @HWI-ST182_0249:5:1101:1093:2017#GTATGACG/1
      NCAGCTGCAGGGAGTTAATTCACAGCAGTTGAGAGCCCTTGCTGTACCAACAAAGGGATGTGTGATCTCCCGGTCCCTCTGCCCCCTCCCCTCCCAGCCGC
      +HWI-ST182_0249:5:1101:1093:2017#GTATGACG/1
      BS\cacccegggehgghhhhh_ghhhhhhhhhhhhghhhhhhhhgghhhhhhhhhhhbghghghhhgeggedd`bb^bbbbbbaaaaaa_abaaabbaaaa

      to

      @HWI-ST182_0249:5:1101:1093:2017#GTATGACG
      NCAGCTGCAGGGAGTTAATTCACAGCAGTTGAGAGCCCTTGCTGTACCAACAAAGGGATGTGTGATCTCCCGGTCCCTCTGCCCCCTCCCCTCCCAGCCGC
      +HWI-ST182_0249:5:1101:1093:2017#GTATGACG
      BS\cacccegggehgghhhhh_ghhhhhhhhhhhhghhhhhhhhgghhhhhhhhhhhbghghghhhgeggedd`bb^bbbbbbaaaaaa_abaaabbaaaa

      I am new to bioinformatics and would appreciate a few pointers on the best way to get this done.
      Thanks a million
      Alex
      Hi Alex, while perl scripting is a good option, if you are new to bioinformatics there might be easier options for you. For example, FASTX-Toolkit:

      Comment

      • alexd106
        Junior Member
        • Dec 2011
        • 4

        #4
        Hi Rahul,

        Thank you very much for your suggestions. As i mentioned, I am new to bioinformatics and am just trying to teach myself some perl (and have never used awk). Would you mind providing a little more detail of the perl code you would use? No worries if not.

        Cheers
        Alex

        Comment

        • kmcarr
          Senior Member
          • May 2008
          • 1181

          #5
          awk is good but sed might be faster and easier to learn.

          Code:
          sed -i.bak -e '/^[@+]HWI/ s/\/[12]$//' <yourFileName>
          This sed script will look for lines starting with @HWI or +HWI, strip off either a /1 or /2 from the ends of those lines and save the result to the same file name as the original. The original file will be saved as <yourFileName>.bak.

          Comment

          • alexd106
            Junior Member
            • Dec 2011
            • 4

            #6
            Thanks very much for the info.

            All the best
            Alex

            Comment

            • rahularjun86
              Member
              • Jan 2011
              • 58

              #7
              Hi Alex,

              Following is the perl code:
              Code:
                1 use strict;
                2 use warnings;
                3 
                4 my $file_in=$ARGV[0];
                5 my $file_out=$ARGV[1];
                6 
                7 my $num=0;
                8 open I,"<$file_in" or die $!;
                9 open O,">$file_out" or die $!;
               10 
               11 do{
               12 
               13 my $f =<I>;
               14 chomp $f;
               15 
               16 if(($f =~ /^\@HWI/)||($f =~ /^\+HWI/))
               17      { $num++;
               18        my @s=split(/\//, $f);
               19        print O"$s[0]\n";
               20      }
               21 
               22 else
               23      {
               24        print O "$f\n";
               25         }
               26 
               27 }until eof(I);
               28 my $pr=$num/2;
               29 print "\nProcessed reads: $pr\n"
               30 
               31 
              ~                                                                                                                                                                    
              ~
              Usage: perl program_name.pl Input_file.fq Out_file.fq
              Last edited by rahularjun86; 03-13-2012, 07:04 AM.
              Rahul Sharma,
              Ph.D
              Frankfurt am Main, Germany

              Comment

              • alexd106
                Junior Member
                • Dec 2011
                • 4

                #8
                Dear all, thanks for all the really useful suggestions. What a great community this is. I hope I can contribute sometime in the future when i have a little more experience.

                [ehlin] I thought of using FASTX-Toolkit but couldn't see the appropriate tool. I looked at

                $ fastx_renamer -h
                usage: fastx_renamer [-n TYPE] [-h] [-z] [-v] [-i INFILE] [-o OUTFILE]
                Part of FASTX Toolkit 0.0.10 by A. Gordon ([email protected])

                [-n TYPE] = rename type:
                SEQ - use the nucleotides sequence as the name.
                COUNT - use simply counter as the name.

                but it looks like the renaming is restricted to either a sequence or counter.

                The sed and seemed to do the trick and I will look at the perl solution in an attempt the educate myself.
                Cheers again
                Alex

                Comment

                Latest Articles

                Collapse

                • 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
                • SEQadmin2
                  Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                  by SEQadmin2



                  Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                  There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                  07-08-2026, 05:17 AM

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 07-20-2026, 11:10 AM
                0 responses
                14 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-13-2026, 10:26 AM
                0 responses
                31 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-09-2026, 10:04 AM
                0 responses
                42 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-08-2026, 10:08 AM
                0 responses
                28 views
                0 reactions
                Last Post SEQadmin2  
                Working...