Hi,
I'm trying to use biopython to blast a list of sequences and retrieve the best hit. This works fine. Now I'd like to filter the results, as I would on the NCBI BLAST web interface, so that metagenomes and uncultered organisms are NOT included in the search. I tried using the filter argument of qblast, but then I don't get an youtput. Removing the filter keywork works fine, but then I only get uncultered organisms.
I've pasted the relevant code snippet below
for record in SeqIO.parse(handle, 'fasta'):
print "Blasting seq "+strrecord.id)
blast_handle = NCBIWWW.qblast('blastn', 'nt', record.seq, filter='all [filter] NOT(environmental samples[organism] OR metagenomes[orgn])')
blast_records = NCBIXML.parse(blast_handle)
for blast_record in blast_records:
if blast_record.alignments:
match = blast_record.alignments[0]
hsps = match.hsps[0]
%% writing various outputs
f.write(str(hsps.gaps)+';')
break
If anyone can tell me where to look, that would be much appreciated.
1 answer
OK, I managed to answer the question by myself.
As it is, the search filters should not go in filter but in entrez_query. So changing the blast_handle = ... line did the job.
edit: Any chance I can make this the accepted answer, as it solved the problem?
Log in to answer this question.