Rename and move Spades assemblies in batch
1
0
Entering edit mode
3.7 years ago
jellila • 0

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

batch bash spades • 1.4k views
ADD COMMENT
1
Entering edit mode
3.7 years ago
Asaf 10k

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 COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

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