Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • NRiddiford
    Junior Member
    • Jul 2012
    • 6

    fastq_quality_trimmer script

    Hi guys,

    I've got a load of RNA-Seq .txt files that I need to trim and filter. The files are very large (>12GB) and I have a lot of different controls etc, and I was wondering if there was a simple script that someone could help me with to perform the same action on multiple files and specify a unique output name.

    I imagine a for loop saying 'for every file ending in .txt run fastq_quality_trimmer and save as a .fastq file' would do this, but I'm not too sure how to go about writing it.

    Any help would be appreciated,

    Thanks a lot,

    Nick
  • cormicp
    Junior Member
    • Jul 2009
    • 5

    #2
    Hi Nick,

    Below is a small perl script that should do what you want. Obviously you can change the parameters selected for fastq_quality_trimmer to the correct ones that you want to use.

    Hope this is what you were looking for.

    open (FILES, "ls *.txt |");
    while (<FILES>) {
    @split = split(/\s+/, $_);
    $file = $split[0];
    print "\n\nParsing $file...";


    system ("fastq_quality_trimmer -t 15 -i $file -o $file.fastq);

    }
    Last edited by cormicp; 07-23-2012, 05:32 AM.

    Comment

    • NRiddiford
      Junior Member
      • Jul 2012
      • 6

      #3
      Awesome - thanks.

      So I just have to replace the $file with the -i/-o locations?

      Would it be possible for you to give me a brief explanation of the script (i.e what each line does?)

      Thanks a lot,

      Nick

      Comment

      • Rocketknight
        Member
        • Sep 2011
        • 86

        #4
        If you're running Linux/OSX, you can also do the whole thing at the command line like this:

        Code:
        $ for i in `ls *.txt`; do fastq_quality_trimmer -i $i -o $i.fastq; done
        This may seem very confusing but it's actually quite simple. Here it is broken down:

        Code:
        for i in `ls *.txt`;
        This bit runs `ls *.txt` and stores a list of the filenames. It then loops once for each file. In each loop, the name of the file is put in the variable $i. Note that `ls.txt` is in backticks (top left corner of your keyboard if you're in the US/UK), not single quotes.

        Code:
        do fastq_quality_trimmer -i $i -o $i.fastq;
        This command will run once every loop, with a different value of $i each time. So if you only have two files, A.txt and B.txt, what will happen is the following commands will run:

        fastq_quality_trimmer -i A.txt -o A.txt.fastq
        fastq_quality_trimmer -i B.txt -o B.txt.fastq

        As you can see, this is a simple but powerful way to run the same command on multiple files at once. If you wish to run fastq_quality_trimmer with other command-line options, just edit the line as required to insert those options.

        Code:
        done
        This indicates that you're not putting any more commands inside the loop. The loop will now run and with any luck you'll get your .txt.fastq output files.

        Word of warning: If you make a mistake while doing this, it's possible to specify both the input and output to be $i, which may cause the output to overwrite the input file, leading to much chaos. Having a backup of your files before you try this for the first time is recommended, but once you're comfortable with it you'll find it's really handy to have.

        Comment

        • NRiddiford
          Junior Member
          • Jul 2012
          • 6

          #5
          Thanks guys, really helpful solutions!

          Cheers,

          Nick

          Comment

          • simonandrews
            Simon Andrews
            • May 2009
            • 870

            #6
            Originally posted by Rocketknight View Post

            Code:
            $ for i in `ls *.txt`;
            Just for the record you don't need the ls part of this command.

            Code:
            $ for i in *.txt; ...
            ..works just fine.

            Comment

            Latest Articles

            Collapse

            • GATTACAT
              Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by GATTACAT
              Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
              07-01-2026, 11:43 AM
            • SEQadmin2
              Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by SEQadmin2


              I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

              Here are nine questions we think about, in roughly the order they matter, before...
              06-18-2026, 07:11 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, 07-02-2026, 11:08 AM
            0 responses
            23 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-30-2026, 05:37 AM
            0 responses
            23 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-26-2026, 11:10 AM
            0 responses
            23 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-17-2026, 06:09 AM
            0 responses
            55 views
            0 reactions
            Last Post SEQadmin2  
            Working...