# how to generate structure file from blast results of an input sequence

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

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

with open('results.xml', 'w') as save_file:
print(blast_results)
save_file.write(blast_results)

from Bio.Blast import NCBIXML
E_VALUE_THRESH = 1e-20
for record in NCBIXML.parse(open("results.xml")):
if record.alignments:
print("\n")
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).