Question: Bash Loop For Job Submission
gravatar for MAPK
6.5 years ago by
MAPK1.6k wrote:

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 • 4.7k views
ADD COMMENTlink modified 4.9 years ago • written 6.5 years ago by MAPK1.6k
gravatar for Pierre Lindenbaum
6.5 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum130k wrote:

for a larger/longer process that needs to be parallelized, use GNU parallel:

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

or GNU Make with option -j

ADD COMMENTlink modified 6.5 years ago • written 6.5 years ago by Pierre Lindenbaum130k

Thank you so much, love this!

ADD REPLYlink written 6.5 years ago by MAPK1.6k
gravatar for Devon Ryan
6.5 years ago by
Devon Ryan96k
Freiburg, Germany
Devon Ryan96k wrote:
for f in *.fasta
    cat $f | sixpack >> output

You'll find basic scripting to be invaluable.

ADD COMMENTlink written 6.5 years ago by Devon Ryan96k


      for i in {1..2000}; do sixpack <fasta$i.fasta; done
ADD REPLYlink written 6.5 years ago by 5heikki9.0k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 786 users visited in the last hour