Entering edit mode
4.9 years ago
linas.kapocius
▴
10
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?
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 showssed
way of editing file names so you can grab the file basename that way....there is no
done
closing your loop. beyond that please read what genomax linked and be sure to extensively browse the web for tutorials.What you should do is use a pipeline.
This posting is deleted and is started as a new post
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
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!
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.sorry did not see this. Will do.
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!
Click on
moderate
link in post you are trying to delete. In edit window that opens, there should be adelete
option (last option at bottom of list). This will only work for your own comments/posts.