Question: Cutadapt for loop
0
gravatar for linas.kapocius
10 months ago by
linas.kapocius0 wrote:

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 • 509 views
ADD COMMENTlink modified 7 months ago by geneart$$40 • written 10 months ago by linas.kapocius0

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 REPLYlink modified 10 months ago • written 10 months ago by genomax92k

...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 REPLYlink written 10 months ago by ATpoint42k

What you should do is use a pipeline.

ADD REPLYlink written 10 months ago by Asaf8.5k

This posting is deleted and is started as a new post

ADD REPLYlink modified 7 months ago • written 7 months ago by geneart$$40

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 REPLYlink written 7 months ago by Asaf8.5k

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 REPLYlink written 7 months ago by geneart$$40

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 REPLYlink modified 7 months ago • written 7 months ago by ATpoint42k

sorry did not see this. Will do.

ADD REPLYlink written 7 months ago by geneart$$40

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 REPLYlink modified 7 months ago • written 7 months ago by geneart$$40

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 REPLYlink modified 7 months ago • written 7 months ago by genomax92k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1519 users visited in the last hour