Hi, I'm new in bioinformatics and need some help.
I have multiple fasta files in the same directory. And I need to trim the sequences inside the files using TrimAL. Since there are 200 files I though it would be easier to do a for loop so I could run all at once. But all examples I found to use for loops did not work.
The files are named as EOG091503G5_aligned.fasta, EOG091506R4_aligned.fasta, EOG0915095X_aligned.fasta, EOG0915054S_aligned.fasta, for example.
I have tried something like this and some variants of this script, but nothing worked:
#!/bin/bash
for file in aligned_trim/*_aligned.fasta;
do
trimal -in $file -out $file_trim.fasta -htmlout $file_trim.html -automated1;
done
I used bash scripts because was the ones that I found people explaining, but if a Python script is the better option for me it's ok too.
See C: How to assign keys and values in a directory by using python (don't go on the name of the thread, @RamRS's comment is for help with bash loops) for assistance with this. Tip: You need to remove the file extension (.fasta) when capturing the file name in a variable, otherwise you are going to get output filenames that will have .fasta repeated in name.
Alternatively you could do something like
for file in `ls -1 aligned_trim/*_aligned.fasta | sed 's/.fasta//'`
See C: How to assign keys and values in a directory by using python (don't go on the name of the thread, @RamRS's comment is for help with bash loops) for assistance with this. Tip: You need to remove the file extension (
.fasta
) when capturing the file name in a variable, otherwise you are going to get output filenames that will have.fasta
repeated in name.Alternatively you could do something like
to remove that extension.
I'm going to have a look at it! Thank you very much for the help!!