How to Write Loop For Trimming Every FastQ File Individually
1
2
Entering edit mode
9 weeks ago
santos48 ▴ 30

I have human Rna-Seq data by reading nanopore. Data has over 1000 .fastq files. I want to trim all fastq files individually. I am using NanoFilt for trimming. All Fastq files are in the directory(not gzip format).

How can I write a loop or command line for trimming all fastq files individually?

I am using Linux Ubuntu 21.04.

Trimming Nanopore Fastq Rna-Seq • 623 views
ADD COMMENT
1
Entering edit mode

I guess this will also work for the same:

find . -name ".fastq" |xargs -n 1 NanoFilt
ADD REPLY
0
Entering edit mode

I wrote loop like

for file in *.fastq do porechop -i ${file} > /Diroctory/${file} > done but how can I specify for when all data is trimmed stop the loop

ADD REPLY
1
Entering edit mode

It should not be necessary to stop the loop since the above command will consider each .fastq file only once.

ADD REPLY
0
Entering edit mode

Thank you for answer. How can I add another do <something>done in the same bash for example I want to use some filtering tools after the trimming.

ADD REPLY
0
Entering edit mode

Please use google to learn shell loops. devarora and Carlo have helped you get started, we cannot feed you the directions for each step.

ADD REPLY
0
Entering edit mode

Just add more lines of code commands between do and done. In my answer bellow, the code does two things for each file: it prints the file name and then it runs the nanofit command.

ADD REPLY
0
Entering edit mode

Can you explain how to run with porechop with all fastq file in the loop ? .

ADD REPLY
1
Entering edit mode

@carlo has explained the basics of a shell loop below. You can try to figure out how to replace porechop in place of nanofilt in the loop below. You should take a look at basename which will allow you to extract just name of sample (here is an example for you to try things out): How to modify my sbatch script to make it be able to be used for other files

Write a loop. Use echo to test things out and ask questions with specific examples.

ADD REPLY
6
Entering edit mode
9 weeks ago

Hello, this is a rather basic question. You could start by googling something like "bash loop files directory" to get plenty of examples on how to write loops in bash. The basic structure of the loop is probably going to be something like this:

for file in $directory; do
    echo $file
    <nanofilt cmd> $file
done

Then if you run into specific issues, feel free to come back and ask for more direction.

ADD COMMENT

Login before adding your answer.

Traffic: 2166 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6