[BioPython] parsing blast results for use in clustal
Aaron Zschau
aaron at ocelot-atroxen.dyndns.org
Thu Mar 25 01:14:56 EST 2004
I'm new to biopython and python in general. I am trying to take the
results from a blast search to feed into a clustal multiple alignment.
I followed the cookbook tutorials and can get results from blast but
parsing into a file that clustal can read is giving me some trouble.
(my current code prints all results under the e_value threshold with
index numbers, and I then take user input to take the selected results
and print them into a file) from what I can tell, some of the title
records in my blast results have newline characters in them and are
causing my resulting file to throw up seg faults when it runs in
clustal.
is there an easier way to send selected blast results to a file that
clustal can easily read?
thanks in advance,
Aaron Zschau
from Bio.Blast import NCBIWWW
b_parser = NCBIWWW.BlastParser()
b_record = b_parser.parse(blast_results)
index = 0
E_VALUE_THRESH = 0.01
for alignment in b_record.alignments:
for hsp in alignment.hsps:
if hsp.expect < E_VALUE_THRESH:
print "[" + str(index) + "] " + alignment.title + " " +
hsp.match[0:20] + '...'
index = index + 1
output_file = open('clustal-in', 'w')
while 1:
input = raw_input("\nEnter the index of the next sequence to align or
'a' to align\n")
if input=='a':
break
else:
output_file.write(b_record.alignments[int(input)].title[0:5] + " "
+ b_record.alignments[int(input)].hsps[0].match[0:alignment.length] +
"\n")
output_file.close()
More information about the BioPython
mailing list