Blast With Biopython
1
0
Entering edit mode
5.7 years ago
neilgupte7 • 0

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?

EXAMPLE:
 AGTC
 ||||
 AGTC

OUTPUT BECOMES-
--AGTC
--||--
TCAG--

 AGTC
 ||||
 TCAG

Help will be appreciated, THANK YOU

blast biopython pairwise alignment • 3.9k views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Don’t type entirely in capitals please.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Standalone blast or online?

ADD REPLY
0
Entering edit mode

standalone BLAST connecting it with a python sript

ADD REPLY
3
Entering edit mode
5.7 years ago
gb ★ 2.2k

Something like this:

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

Or:

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 = NCBIXML.read(result_handle)
for alignment in blast_record.alignments:
 for hsp in alignment.hsps:
     print("****Alignment****")
     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:

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

I got this code from here:

http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc98

ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY

Login before adding your answer.

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