import blastparser
fp = open('sample-blast.txt')
for record in blastparser.parse_fp(fp):
for hit in record.hits:
for match in hit.matches:
print record.query_name, hit.subject_name
print match.subject_start, match.query_start
print match.subject_end, match.query_end
print match.expect
print dir(match)
break
break
occulta.ctb3.1 JGI_294397 1 81 1307 4050 1e-300 ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'expect', 'frame1', 'frame2', 'query_end', 'query_sequence', 'query_start', 'subject_end', 'subject_sequence', 'subject_start']
evalues = []
fp = open('sample-blast.txt')
for record in blastparser.parse_fp(fp):
for hit in record.hits:
for match in hit.matches:
evalues.append(match.expect)
hist(evalues, bins=100, normed=True)
show()
fp = open('sample-blast.txt')
n = 0
for record in blastparser.parse_fp(fp):
n += 1
if n > 5: break
for hit in record.hits:
for match in hit.matches:
print record.query_name, hit.subject_name, match.expect
break
break
occulta.ctb3.1 JGI_294397 1e-300 occulta.ctb3.2 ci0100148600 1e-300 occulta.ctb3.3 ENSCINT00000024997 1e-125 occulta.ctb3.4 KH.S404.1.v4.A.ND1-1 4e-57 occulta.ctb3.5 KH.S404.1.v4.A.ND1-1 8e-57
fp = open('sample-blast.txt')
outfp = open('/tmp/blastout.csv', 'w')
for record in blastparser.parse_fp(fp):
for hit in record.hits:
for match in hit.matches:
print >>outfp, record.query_name, hit.subject_name, match.expect
break
break
import csv
fp = open('sample-blast.txt')
outfp = open('/tmp/blastout.csv', 'wb')
w = csv.writer(outfp)
for record in blastparser.parse_fp(fp):
for hit in record.hits:
for match in hit.matches:
w.writerow([record.query_name, hit.subject_name, match.expect])
break
break
outfp.close()