This is a test version of Biostars. For the public version, visit https://www.biostars.org.
blast in python

Hey guys, i want make a blast with two fasta sequences in python i am using this code:

import os
blastcommand = 'blastp -query a.fasta -subject b.fasta'
os.system(blastcommand)

the output is always "1"

how can i fix that?

blast python

I cover sending BLAST output to parseable files & parsing them with Python & Pandas in a series of Jupyter Notebooks available here. I even bring up alternatives like awk for parsing the output. I have a script that I use there that converts the output to a Pandas dataframe that is useful for sorting through data in a Python context. In the context of Jupyter, you can even skip the file output intermediates for the results. You can work through this without installing anything all by going there and clicking 'launch binder' badge near the top or click here to launch a session directly. Everything is installed and loaded in the temporary Jupyter session served via the MyBInder service to work through the examples in the available notebooks that come up listed when the session starts. I suggest working through the available notebooks in the order they are listed there. You'll probably primarily be interested in the earlier ones in the series for now.

1 answer

my guess, use

blastcommand = '/full/path/to/blastp -query /path/to/a.fasta -subject /path/to/b.fasta'

Log in to answer this question.