#!/bin/python3

from Bio import SearchIO
import os

# fetch files in current working directory
files = [f for f in os.listdir('.') if os.path.isfile(f)]



i = 0
for f in files:
	if f.endswith('.xml'):
	#	print("FILE: ", f, "\n")
		blast_qparse = SearchIO.parse(f, 'blast-xml')
#		print(blast_qparse)
		for result in blast_qparse:
			for hit in result.hits:
#				print(hit.description, '\t', hit.id, '\t', hit.query_id)
#				print(hit.query_id, '\t', hit.id, '\t', hit.description) 
#				i=i+1
				for fragment in hit:
#					print(fragment.hit_description)	
#					print(fragment)
#					print(getattr(fragment,'evalue'), )
					print(fragment.query.id + '\t' + 
						fragment.hit_id + '\t"' + 
						fragment.hit_description + '"\t',
						getattr(fragment, 'evalue'),  '\t' ,
						fragment.query_start)
					i=i+1


#print(i)
