No output in local blast using biopython
1
0
Entering edit mode
8.4 years ago

Hi everybody,

I know a similar question has been put here before but it did not answer my problem. I divide it in two parts:

1)

I want to run a local blast on a multifasta file. I have blast installed as well as the nucleotide database. Being in my database directory, I run:

blastn -db nt -query rep.fna -out plop1.xml -outfmt 5

for this everything works well, I get an plop1.xml file out (with something in it). However I tried to run the same thing in python (still being in the same directory):

>>> from Bio.Blast.Applications import NcbiblastnCommandline
>>> cline = NcbiblastnCommandline(query= "rep.fna", db = "nt", out= "plop.xml", outfmt = 5)
>>> cline
NcbiblastnCommandline(cmd='blastn', out='plop.xml', outfmt=5, query='rep.fna', db='nt')
>>> print cline
blastn -out plop.xml -outfmt 5 -query rep.fna -db nt
>>> stdout, stderr = cline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NcbiblastnCommandline' object is not iterable

In this case I do not get anything out, no plop.xml is created. What is wrong? Can also somebody explain me what are the stdout and stderr? I do not understand.

2)

Originally, I wanted it to be part of a whole python script where I process my sequences. So, from another directory than the database (I created also a .ncbirc file in my home directory):

dictionary_matches = {}
from Bio.Blast.Applications import NcbiblastnCommandline
blastn_cline = NcbiblastnCommandline(query = "rep.fna", db = "nt", outfmt = 5, out = "my_blast.xml")
stdout, stderr = blastn_cline()
blast_records = NCBIXML.parse(open("my_blast.xml"))    
for record in blast_records:
    for index, alignment in enumerate(record.alignments):
        if index == 0:
            print alignment.title
            dictionary_matches[str(record.query)] = str(alignment.title)

Result is:

Traceback (most recent call last):
  File "blast_oturep.py", line 27, in <module>
    stdout, stderr = blastn_cline()
  File "/Library/Python/2.7/site-packages/Bio/Application/__init__.py", line 444, in __call__
    stdout_str, stderr_str)
Bio.Application.ApplicationError: Command 'blastn -out my_blast.xml -outfmt 5 -query rep.fna -db nt' returned non-zero exit status 255, 'Critical: (110.6) CNcbiRegistry: Syntax error in system-wide configuration file: NCBI C++ Exception:'

And no output is created.

If I would try the same thing and remove the stdout, stderr line, I would get an empty xml file as an output, and then of course the iteration does not work.

For this last part, it seems that my .ncbirc file is the problem, cause after making it, I cannot run anymore a simple local blast outside of python like in 1), I then get something like that:

Critical: (110.6) CNcbiRegistry: Syntax error in system-wide configuration file: NCBI C++ Exception:
    T0 "/Users/coremake/release_build/build/PrepareRelease_IntelMAC_JSID_01_80346_130.14.18.6_9008__PrepareRelease_IntelMAC_1433256305/c++/compilers/unix/../../src/corelib/ncbireg.cpp", line 675: Error: ncbi::IRWRegistry::x_Read() - Invalid registry entry format: '{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570' (m_Pos = 1)

Error: NCBI C++ Exception:
    T0 "/Users/coremake/release_build/build/PrepareRelease_IntelMAC_JSID_01_80346_130.14.18.6_9008__PrepareRelease_IntelMAC_1433256305/c++/compilers/unix/../../src/corelib/ncbireg.cpp", line 675: Error: ncbi::IRWRegistry::x_Read() - Invalid registry entry format: '{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570' (m_Pos = 1)

However, I do not undersatnd what is wrong with my file, I followed the online instructions:

; Where the databases are: BLASTDB=/Users/svenlemoinebauer/Documents/blast_database ; end of the file

I am really lost. Any idea?

Thanks a lot. :)

python biopython blast • 4.0k views
ADD COMMENT
0
Entering edit mode

You've got two main questions here, perhaps remove the .ncbirc bit and make that into a separate question?

ADD REPLY
2
Entering edit mode
8.4 years ago
Peter 6.0k

You did this:

>>> stdout, stderr = cline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NcbiblastnCommandline' object is not iterable

You need to do this with the empty brackets indicating using it as a function without any explicit arguments:

>>> stdout, stderr = cline()
ADD COMMENT

Login before adding your answer.

Traffic: 1516 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