Entering edit mode
2.3 years 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.hmmand inmnt/c/Users/username/Desktop/FASTA.No I'm not in the root directory, I just added the missing
/in theos.listdircommand ("/mnt/c/Users/username/Desktop/FASTA") and that solved the issue withFilenamenot getting extracted correctly! However when I tried adding/to the__OUTPUTfile 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 thehmmsearchline, saying that$__OUTPUTis an invalid syntax?By using
Filenameeverywhere you are simply using the entire list as input. You would want to useitemto select those names that have.fain the name? You will also need to do some additional work to remove.fafrom name before using the basename.Hmm, after reading your comment I tried using this for the
__INPUTinstead, 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/*.fastaThis is a horrible implementation but should give you an idea. I am simply reusing your code. You will need to adjust as necessary.