3

it's the first time that i use blast inside biopython, and i'm having a problem.

i created a custom blast database from a fasta file which contain 20 sequence using :

os.system('makeblastdb -in newtest.fasta -dbtype nucl -out newtest.db')

and this did generate few files (newtest.db.nhr, newtest.db.nin, newtest.db.nsq) inside the current directory that i'm currently working in : (/home/User/Documents/python/fasta-files)

and now i'm trying to query this database inside biopython using :

blastx_cline = NcbiblastxCommandline(query="queryfile.fas", db="newtest.db", evalue=0.00000001, outfmt=5, out="opuntia.xml")

but i'm getting this error :

> Bio.Application.ApplicationError: Command 'blastx -out opuntia.xml
> -outfmt 5 -query queryfile.fas -db newtest.db -evalue 1e-08' returned non-zero exit status 2, 'BLAST Database error: No alias or
> index file found for protein database [newtest.db] in search path
> [/home/User/Documents/python/fasta-files:/usr/share/ncbi/blastdb:]'

so i tried copying the files generated from the /home/User/Documents/python/fasta-files to /usr/share/ncbi/blastdb but it says that i don't have permission.

*EDIT*

when i use : os.system("blastn -db newtest.db -query "fastafile.fas" + " -out test.txt") it works normally generating an output file. but not the other way around**

so i'm stuck here and i don't know how to solve this.

any help would be appreciated

ifreak
  • 1,726
  • 4
  • 27
  • 45

1 Answers1

6

Pay attention to phrase protein database in the error message while newtest.db is a nucl database.

index file found for protein database [newtest.db] in search path

So blastx is expecting a protein database. Isn't that obvious? :-)

In case you did not do it by purpose, you should specify BLAST program to use by adding "cmd='blastn'". So, this is better:

blastx_cline = NcbiblastxCommandline(cmd='blastn', query="queryfile.fas", db="newtest.db", evalue=0.00000001, outfmt=5, out="opuntia.xml")
biocyberman
  • 5,675
  • 8
  • 38
  • 50
  • thank you, i did not really payed attention to it .. thank you for pointing it out .. – ifreak Dec 03 '12 at 09:29
  • small question, why can't i add the -m option to this command line ?? it's giving me an error .. – ifreak Dec 04 '12 at 13:44
  • That looks like a BLAST legacy option. The blastx_cline you have here is for BLAST+. Is it to set number of threads? Use num_threads instead. – biocyberman Dec 05 '12 at 10:41
  • what i want is to output the all against all alignments .. but i'm only getting the match with the current specie and not all the matches within the specified evalue .. what should i add to get the same results as when using the web tool (all matches) ??? @biocyberman – ifreak Dec 06 '12 at 10:03
  • Not quite understand what you were saying. In general, you should first try running the blast command in Windows CMD, or bash or whatever shell environment you use. When the command gives what you want, you can translate it into biopython command later. This also helps to see the logic behind biopython's BLAST command. Read more on BLAST or BLAST+ manual for explanation of commandline options. – biocyberman Dec 18 '12 at 13:58