Question: Rename and move Spades assemblies in batch
0
gravatar for jellila
8 weeks ago by
jellila0
jellila0 wrote:

Hi.

I have a folder called "spades" with many subdirectories generated by Spades (each with the name of the sequenced strain). I would like to rename the "contigs.fasta" file with the name of the folder (for ex. DI21.fasta that is in the "DI21" folder) and move the renamed fasta file to a different directory where I want to collect all the fasta files of the different strains. How can i do it in batch? I am working in bash on a mac.

Thank you.

Laura

bash spades batch • 118 views
ADD COMMENTlink modified 8 weeks ago by Asaf8.4k • written 8 weeks ago by jellila0
1
gravatar for Asaf
8 weeks ago by
Asaf8.4k
Israel
Asaf8.4k wrote:

I guess you can use a bash script to do that. Something like:

for f in */contigs.fasta; do cp $f /destination/dir/${f%/contigs.fasta}.fasta; done

The % removes the following text from the variable so the contigs.fasta will be changed to the folder name.

(I didn't test it but it should work)

ADD COMMENTlink written 8 weeks ago by Asaf8.4k

This worked perfectly, thank you very much Asaf!! :)

ADD REPLYlink written 8 weeks ago by jellila0
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: 1958 users visited in the last hour