blast in python
1
0
Entering edit mode
7 weeks ago

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 • 395 views
ADD COMMENT
0
Entering edit mode

That's just the system exit code indicating an error occurred. To capture the output you need to write it to a file and parse it thereafter. See https://www.w3schools.com/python/ref_os_system.asp

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
7 weeks ago

my guess, use

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

Login before adding your answer.

Traffic: 1697 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6