Cutadapt for loop
0
0
Entering edit mode
4.9 years ago

I have two questions.

How to for loop .fastq files which are in a single directory in cutadapt?

For example:

for file in *.fastq; do cutadapt -a AACTGTCGGCACCATCTA -o cell_line_output.fastq cell_line.fastq

This one gives me an error.

And, also, how to change output files names for every loop, for example, cell_line_1_output.fastq, cell_line_2_output.fastq?

Assembly • 2.4k views
ADD COMMENT
0
Entering edit mode

You need to grab the base file name and then use it in the loop so you get proper names that refer to each sample. This can be done using name=$(basename file.fastq .fastq). There are plenty of posts on biostars for help with for loops. Here is one example: C: Bash Script Loop Help This shows sed way of editing file names so you can grab the file basename that way.

ADD REPLY
0
Entering edit mode

...there is no done closing your loop. beyond that please read what genomax linked and be sure to extensively browse the web for tutorials.

ADD REPLY
0
Entering edit mode

What you should do is use a pipeline.

ADD REPLY
0
Entering edit mode

This posting is deleted and is started as a new post

ADD REPLY
0
Entering edit mode

You should probably start a new thread with your question. The problem is that you are looping through all the fastq.gz files, you should pair them up. There are several solutions, the best one is using a pipeline management system as I suggested above. See here for instance: https://www.nextflow.io/docs/latest/channel.html#fromfilepairs

ADD REPLY
0
Entering edit mode

I just saw your answer after I added my comment. Will go back and check your link. Although it will be great to have a pipeline, my effort is to learn to script well and hence the clarification. I appreciate your guidance and will check it out and implement and update on my results. In the meantime if you have thoughts on my added comment that will be greatly appreciated too!

ADD REPLY
0
Entering edit mode

You should probably start a new thread with your question.

Please do not simply ignore that. Open a new question. This here is unrelated to the original question. by the way, in your code snipped below you are still looping through the same files because it must be for i in *R1.fastq.gz not *.fastq.gz. Try to implement that and if it doesn't work open anew question. Do not keep adding comments here or we will consider deleting them.

ADD REPLY
0
Entering edit mode

sorry did not see this. Will do.

ADD REPLY
0
Entering edit mode

Hi Asaf or ATpoint I am trying to delete but can't find the obvious delete button. I don't frequent much on biostars. Please can you help. Thanks for your patience!

ADD REPLY
0
Entering edit mode

Click on moderate link in post you are trying to delete. In edit window that opens, there should be a delete option (last option at bottom of list). This will only work for your own comments/posts.

ADD REPLY

Login before adding your answer.

Traffic: 1568 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