Bash Loop For Job Submission
2
2
Entering edit mode
10.6 years ago
MAPK ★ 2.1k

Hi guys, I have thousands of fasta files each with one sequence only. I need to run a command in my linux/unix system to perform certain job and loop that command through each file and get the output in a single file. Is there a way to do that? I was suggested to use bash loop. For example, if I need to translate a DNA sequence in a fasta file and if the program (sixpack in this case) translates only one sequence at a time, how do I do this for multiple submission of files? I want to avoid doing this individually:

sixpack <fasta1.fasta
sixpack <fasta2.fasta
sixpack <fasta3.fasta

Instead, I want the bash(or perl/python script) to follow the same command looping through each fasta file. Thank you for your help!

bash perl • 6.4k views
ADD COMMENT
8
Entering edit mode
10.6 years ago

for a larger/longer process that needs to be parallelized, use GNU parallel: http://www.gnu.org/software/parallel/

parallel sixpack '<'  {} ::: *.fasta

or GNU Make with option -j

ADD COMMENT
0
Entering edit mode

Thank you so much, love this!

ADD REPLY
4
Entering edit mode
10.6 years ago
for f in *.fasta
do
    cat $f | sixpack >> output
done

You'll find basic scripting to be invaluable.

ADD COMMENT
0
Entering edit mode

Or:

      for i in {1..2000}; do sixpack <fasta$i.fasta; done
ADD REPLY

Login before adding your answer.

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