[BioPython] python newbies blast problem
h.j.tipney at stud.man.ac.uk
h.j.tipney at stud.man.ac.uk
Mon Jul 12 10:34:27 EDT 2004
Hi
I'm hoping someone can help me. I'm very new to programming and
even newer to python, so I apologise in advance if this is a simple
problem with an obvious solution but there are no python
programmers near to help me.
Anyway, I inherited the script below and have been using it on and
off as part of a larger workflow. It has been running fine, but I ran it
again last week and it didn't give the output I expected - it returned
the 'your results will be updated in X seconds' page rather than the
actual results. It has been a while since I had used this program and
both blast and biopython had been updated so I've now got the new
biopython release (1.30) but I still get the 'wrong' output.
I'm using python 2.3.3 on solaris, if that helps.
Any help would be greatly appreciated!
Thank you in advance
Hannah Tipney
#!/opt/cs/bin/python
from Bio import Fasta
from Bio.Blast import NCBIWWW
import sys
import getopt
opts, args = getopt.getopt(sys.argv[1:],"",['program=','database=','format=','entrez_query='])
print sys.argv
print opts
if len(args)==0:
print "no file given"
sys.exit(2)
program = "blastn"
database = "nr"
format = "Text"
#"Homo sapiens [ORGN]"
short_query=""
for o,a in opts:
print o,a
if o == "--program":
program = a
if o == "--database":
database = a
if o == "--format":
format = a
if o == "--entrez_query":
short_query = a
if short_query=="human":
query="Homo sapiens [ORGN]"
else:
query=""
print "program = %s , database = %s, query = %s" % (program,database,query)
file_for_blast = open(args[0], 'r')
f_iterator = Fasta.Iterator(file_for_blast)
f_record = f_iterator.next()
file_for_blast.close()
b_results = NCBIWWW.blast(program, database, f_record,format_type=format,
entrez_query=query,timeout=60)
blast_results = b_results.read()
sys.stdout.write(blast_results)
------------------------------------------
Hannah Tipney
Manchester University,
Academic Unit of Medical Genetics,
St Mary's Hospital,
Hathersage Road,
Manchester. M13 0JH.
UK
tel: +44 (0)161 276 6602
fax: +44 (0)161 276 6606
More information about the BioPython
mailing list