Question: Biopython NCBIcommandline from PHP
gravatar for belden
5.9 years ago by
United States
belden0 wrote:

Hi, this is my first post.  I am writing a web program in PHP and I want it to perform a python script that performs a local blast (of a fasta file) on my laboratory's server and then return information using json_decode for further processing. The local blast (using Biopython NCBIblastnCommandline) works fine and writes the expected xml file when run in Idle and my PHP program can retrieve the results when run separately.  But for some reason it will not execute NcbiblastnCommandline and return the results.  I'm developing it on a Windows 7 machine using WAMP but will eventually move it to a server with Ubuntu.

The PHP code is.


$command= "C:/Python27/python C:/path_to_file/";
$result = json_decode(exec($command), true);


The Python script is below and I have tried many permutation on it using stdout, sterr, below is my last attempt (probably should have sought help sooner).


import sys
import os
from Bio import SeqIO
from Bio.Blast.Applications import NcbiblastnCommandline
from Bio.Blast import NCBIStandalone

data_base = "C:/path_to_file/db"
input_handle=open("C:/path_to_file/DNA.fa", "rU")
blastn_cline = NcbiblastnCommandline(query="C:/path_to_file/DNA.fa", db=data_base, out="C:/path_to_file/out_file.xml", outfmt=5, task="blastn-short")
#sys.stdout, sys.stderr=blastn_cline()

# The program then counts the number of alignments and passes the information with json.dumps but left out the code because it runs fine.

print json.dumps(D)

If anyone can help I'd really appreciate it.



php biopython blast • 1.8k views
ADD COMMENTlink modified 5.9 years ago by Biostar ♦♦ 20 • written 5.9 years ago by belden0

is flagged as "executable" ? can you only see/read from PHP ? 

ADD REPLYlink modified 5.9 years ago • written 5.9 years ago by Pierre Lindenbaum133k

It can read and execute other python scripts when set up the exact same way.  It just won't execute the NCBIBlastnCommandline.  The stdout, stderr are commented out because that was causing a problem.

ADD REPLYlink written 5.9 years ago by belden0

Do you get any error message? e.g. via stderr? Are you sure blastn.exe is on the $PATH? If not, you would have to call NcbiblastnCommandline giving the full path to the exe as the first argument.

ADD REPLYlink written 5.8 years ago by Peter5.9k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 950 users visited in the last hour