How to run pal2nal on many files?
1
0
Entering edit mode
11 days ago
cats123 • 0

I am trying to automate pal2nal but I am struggling to understand.

I have many nucleotide and protein alignment files with the same names and different extensions. For example:

file1.fa file1.msa

I can run pal2nal by:

pal2nal.pl file1.msa file1.fa -output paml > file1.cds

I need to create a for loop to do this to hundreds of files. How do I do this when the extension changes for the 2 input files and for the output file?

script forloop pal2nal perl commandline • 103 views
0
Entering edit mode
11 days ago
GenoMax 117k

If your files are named just the way you show them then something like following will work

for i in ls -1 *.fa; do name=$(basename${i} .fa); echo ${name}; pal2nal.pl${name}.msa ${name}.fa -output paml >${name}.cds; done