I have tried to incorporate blast in my application using biopython.i could extract the blast results but now i want to extract the structure file corresponding matches. My code is :

from Bio.SeqIO import parse 
from Bio.SeqRecord import SeqRecord 
from Bio.Seq import Seq 

file = open("prats.fasta") 

records = parse(file,"fasta") 
for record in records:   
    print("Id: %s" % record.id) 
    print("Name: %s" % record.name) 
    print("Description: %s" % record.description) 
    print("Annotations: %s" % record.annotations) 
    print("Sequence Data: %s" % record.seq) 
    print("Sequence Alphabet: %s" % record.seq.alphabet)

from Bio.Blast import NCBIWWW
sequence_data = open("prats.fasta").read() 

result_handle = NCBIWWW.qblast("blastn", "nt", sequence_data) 

with open('results.xml', 'w') as save_file:
    blast_results = result_handle.read()

from Bio.Blast import NCBIXML
for record in NCBIXML.parse(open("results.xml")): 
    if record.alignments: 
        print("query: %s" % record.query[:100]) 
        for align in record.alignments: 
            for hsp in align.hsps: 
                if hsp.expect < E_VALUE_THRESH: 
                    print("match: %s " % align.title[:100])

from here i want to generate the xml files and then fetch structure of each nucleotides results


If you the DNA/RNA crystal structure:

Simply change the nt in NCBIWWW.qblast("blastn", "nt", sequence_data) to pdbnt to get the nucleotide sequence in a chain. The PDB code will be the accession ID with an underscore plus chain letter. Do note that the PDB structure may be offset.

If you want the crystal structures of the encoded protein:

blastx (translation) on the pdbaa database. As above the PDB code will be as above.

If you want a model of the encoded protein:

Check Swissmodel for a pre-existing close threaded model, else check out I-Tasser (best), Phyre (fast).

If you want a model of the DNA/RNA:

You are running blast without special settings —its not a short motif—, so these things may be long, so do be weary of any result. There are a few RNA folding prediction tools online (e.g. RNAFold).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.