Entering edit mode
16 months ago
garfield320
▴
20
I'm trying to run hmmsearch
against a set of fasta files stored in a directory and save the results individually. I came up with the following python script:
# extract fasta file names for input/output files
Filename = []
for item in os.listdir("mnt/c/Users/username/Desktop/FASTA"):
if ".fasta" in item:
Filename.append(item)
__INPUT = Filename
__OUTPUT = mnt/c/Users/username/Desktop/hmmsearch/Filename.hmm
hmmsearch -o $__OUTPUT -T 50 hmmfile.hmm $__INPUT
However I can't even seem to get the Filename
parameter out because I'm getting the no such file or directory
error. I did manage to run hmmsearch
for individual fasta file using the line below though , so I know that the file path does exist.
hmmsearch -o /mnt/c/Users/username/Desktop/hmmsearch/hmmoutput.txt -T 50 hmmfile.hmm /mnt/c/Users/username/Desktop/FASTA/file1.fasta
How can I get around this problem?
Are you running this from the root (/) directory, which is where I would expect
/mnt/....
to be present. Otherwise you appear to be missing a leading/
beforemnt/c/Users/username/Desktop/hmmsearch/Filename.hmm
and inmnt/c/Users/username/Desktop/FASTA
.No I'm not in the root directory, I just added the missing
/
in theos.listdir
command ("/mnt/c/Users/username/Desktop/FASTA"
) and that solved the issue withFilename
not getting extracted correctly! However when I tried adding/
to the__OUTPUT
file it gives a syntax error (invalid syntax), so I removed that again and left it as is. Now when I run the file, I get a syntax error with thehmmsearch
line, saying that$__OUTPUT
is an invalid syntax?By using
Filename
everywhere you are simply using the entire list as input. You would want to useitem
to select those names that have.fa
in the name? You will also need to do some additional work to remove.fa
from name before using the basename.Hmm, after reading your comment I tried using this for the
__INPUT
instead, and I'm getting a syntax error at*.fasta
. I thought*
was supposed to read any characters or numbers though?__INPUT = mnt/c/Users/username/Desktop/FASTA/*.fasta
This is a horrible implementation but should give you an idea. I am simply reusing your code. You will need to adjust as necessary.