0

I'm running the bioinformatics tool hmmer and I would like to run it for over 7000 test sequence queries. After it runs each one, I would like it to save the output in a text file, which it does quite easily.

I am trying to create a for loop in bash that would run hmmer on each test sequence in the folder and writes the output to its own text file.

How does one write a statement inside the for loop so that it writes to a different text file each time the loop is performed?

Currently my code is as such

for i in First10/*; do

binaries/jackhmmer --tblout test[i].txt -E1 --noali $i largedatabase.fasta

done
1
for i in First10/*; do
     binaries/jackhmmer --tblout test$(basename $i).txt -E1 --noali $i largedatabase.fasta
done

I am not sure about the command you are running in the loop. But I think my answer can fulfill your requirement.

It will create new output file in every loop. **i.e: If you have two files called database1.db and database2.db in First10 directory, in the first loop it will create output testdatabase1.db.txt and testdatabase2.db.txt in second loop.

0
 #!/bin/bash
 cd First10 
  for filename in *; do

        ../binaries/jackhmmer --tblout "${filename}.log" -E1 --noali "$filename" largedatabase.fasta 

  done
 cd $OLDPWD

So you will have the processed file name on the log file name dot log, changing its name for each iteration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.