Hi, I am new to this website and Biopython. I designed the following program and trying to run it with little success as it takes longer to run the program below. I am trying to find matching sequence with an accession number in qblast and parse the .XML results and storing them in a file and finally trying to perform multiple sequence alignment. I run the code below but it takes way too long to run (It does gives valueerror: I/O on closed file, so I used try and exceptions. Can anyone help?
import Bio from Bio import SearchIO from Bio.Blast import NCBIWWW from Bio.Blast import NCBIXML result_handle = NCBIWWW.qblast("blastp", "nr", ' NP_001090682.1', entrez_query='Xenopus[ORGN]', hitlist_size=5) with open("my_blast5.xml", "w") as out_handle: out_handle.write(result_handle.read()) result_handle.close() blast_qresult = SearchIO.read("my_blast5.xml", "blast-xml") print(blast_qresult) for Hits in blast_qresult: for hit in Hits: print(hit) print() import itertools import xml.etree.ElementTree as ET tree = ET.parse('my_blast5.xml') root = tree.getroot() import sys olp = tree.iter("Hit_accession") mylist = [t.text for t in olp] ptp= tree.iter('Hsp_hseq') mylist1 = [t.text for t in ptp] mylist3 = [ele.replace('-','') for ele in mylist1] with open("test1.txt", "a") as sys.stdout: print('>'+mylist,'\n'+ mylist3) print('>'+mylist,'\n'+ mylist3) print('>'+mylist,'\n'+ mylist3) print('>'+mylist,'\n'+ mylist3) print('>'+mylist,'\n'+ mylist3) print('>'+'Epitope'+ '\n'+'MVKLIESKEAFQEALAAAGDKLVVVDFSATWCGPCK') from Bio.Align.Applications import ClustalwCommandline from Bio import AlignIO try: cline = ClustalwCommandline("clustalw2", infile="test1.txt") clustalw_exe = r"C:\Users\XYZ\Downloads\clustalw2.exe" clustalw_cline = ClustalwCommandline(clustalw_exe, infile="test1.txt") # assert os.path.isfile(clustalw_exe), "Clustal_W executable is missing" stdout, stderr = clustalw_cline() ClustalAlign = AlignIO.read("test1.aln", "clustal") except ValueError: pass