Question: Blast With Biopython
gravatar for neilgupte7
10 weeks ago by
neilgupte70 wrote:

i wanted to blast two sequences ,but i need the query to be searched with the complement of my subject strand .and how to display such alignment inside biopython using blast?




Help will be appreciated, THANK YOU

ADD COMMENTlink modified 9 weeks ago by gb440 • written 10 weeks ago by neilgupte70

What is the actual question here?

Do you want to know how to 'render' the alignment visually, or how to do the BLAST, or how to reverse complement? All 3?

ADD REPLYlink written 10 weeks ago by jrj.healey7.7k

rendering part might also help basically i wanted to know,can we do Blast complementary strands inside biopython and visaulise the particular output.?

ADD REPLYlink modified 10 weeks ago • written 10 weeks ago by neilgupte70

Don’t type entirely in capitals please.

ADD REPLYlink written 10 weeks ago by jrj.healey7.7k

sorry ,my bad !did not pay attention towards the case

ADD REPLYlink written 10 weeks ago by neilgupte70

Standalone blast or online?

ADD REPLYlink written 10 weeks ago by gb440

standalone BLAST connecting it with a python sript

ADD REPLYlink written 9 weeks ago by neilgupte70
gravatar for gb
9 weeks ago by
gb440 wrote:

Something like this:

cline = NcbiblastnCommandline(query="m_cold.fasta", db="nt", strand="plus",evalue=0.001, out="m_cold.xml", outfmt=5)


cline = NcbiblastnCommandline(query="m_cold.fasta", db="nt", strand="minus",evalue=0.001, out="m_cold.xml", outfmt=5)

With the strand parameter you can change which orientation you want. Probably in your case you need to set it on plus but reverse complement all your input sequences.

For displaying the alignment you can do something like this:

from Bio.Blast import NCBIXML
blast_record =
for alignment in blast_record.alignments:
 for hsp in alignment.hsps:
     print("sequence:", alignment.title)
     print("length:", alignment.length)
     print("e value:", hsp.expect)
     print(hsp.query[0:75] + "...")
     print(hsp.match[0:75] + "...")
     print(hsp.sbjct[0:75] + "...")

Output will be:

sequence: >gb|AF283004.1|AF283004 Arabidopsis thaliana cold acclimation protein WCOR413-like protein
 alpha form mRNA, complete cds
length: 783
e value: 0.034
||||||||| | ||||||||||| || ||||  || || |||||||| |||||| |  | |||||||| ||| ||...

I got this code from here:

ADD COMMENTlink written 9 weeks ago by gb440

I am using Anaconda Spyder to run Biopython but i dont get the output when using NcbiblastnCommandline but when i use NcbiblastpCommandline i get the output ....But the output is in following format

*Alignment* sequence: seq2 seq2 <unknown description=""> length: 149 e value: 0.0138168 CTAGCTCGATCGATCGATGCTAAGCTTACGTAGCT... CTAGCT GATCG C TACGTAGCT... CTAGCT-GATCGTAC-----------TACGTAGCT..

what should i do to get the output as follows

tacttgttgatattggatcgaacaaactggagaaccaacatgctcacgtcacttttagtcccttacatattcctc... ||||||||| | ||||||||||| || |||| || || |||||||| |||||| | | |||||||| ||| ||... tacttgttggtgttggatcgaaccaattggaagacgaatatgctcacatcacttctcattccttacatcttcttc...

ADD REPLYlink written 8 weeks ago by neilgupte70

Please use the code formatting button (it has101010 written on it in the bar above) to improve your posts readability.

ADD REPLYlink modified 8 weeks ago • written 8 weeks ago by jrj.healey7.7k

Not sure if I understand because you comment is hard to read. But when you do a blastp you do a protein alignment. So you have matches and positives. You need to check what's going wrong with blastn, blastn is for nucleotide alignments.

ADD REPLYlink written 8 weeks ago by gb440
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: 754 users visited in the last hour