cutadapt and vsearch script to process a set of files
1
0
Entering edit mode
7.1 years ago
ieie ▴ 10

Hi all,I have already looked up for similar questions but I did not find what I am looking for. I have two questions:

1.I want to trim the primers for 12 fastq files and I am using this loop

for i in $(ls):; do cutadapt -a TCCTCCGCTTATTGATAGC -o ${i}trimmed.fastq ${i}; done

but the outfile name that I get is e.g C1P1.fastqtrimmed.fastq, how do I write the script in the way that I get C1P1_trimmed.fastq as the output file name?

  1. I would like to do the same thing with vsearch, so process a number of files in one time. I use

    for i in *$(ls):; do vsearch --rereplicate ${i} --relabel ${i}seq --output ${i}.fasta; done

but I would like to use these comands just for some fasta files in the directory not all the files of the directory. thanks a lot in advance.

next-gen • 3.3k views
ADD COMMENT
0
Entering edit mode
7.1 years ago
GenoMax 147k

just for some fasta files

Are you able to selectively list the files with ls? If so that command could be substituted in place of ls in the loop above.

Change -o ${i}trimmed.fastq to -o ${i}\_trimmed.fastq to get C1P1_trimmed.fastq type names.

ADD COMMENT
0
Entering edit mode

thanks a lot for your answer! no, I am not able, I tried few things but I did not get it right.. Could you tell me how is it done? thank you so much for your help!

ADD REPLY
0
Entering edit mode

Without knowing your file names/what exactly you want to select it would be difficult. Look at this page to see if you are able to identify a pattern that works for you with ls.

ADD REPLY
0
Entering edit mode

Thanks, i will look at it!

ADD REPLY
0
Entering edit mode

I changed the -o ${i}_trimmed.fastq but I still get C1P1.fastq_trimmed.fastq instead of C1P1_trimmed.fastq...

ADD REPLY
1
Entering edit mode

Ah I see. Replace ls with ls | sed 's/.fastq//'. Your command would become

for i in $(ls | sed 's/.fastq//'); do cutadapt -a TCCTCCGCTTATTGATAGC -o ${i}\_trimmed.fastq ${i}.fastq; done
ADD REPLY
0
Entering edit mode

it worked! great, thanks a lot!

ADD REPLY

Login before adding your answer.

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