code: def read_blast_xml(filename, **kwargs):
      
      # Read file.
      with open(filename, 'r') as f:
          blast_record = NCBIXML.read(f)
  
      # Prepare DataFrame fields.
      data = {'accession': [],
              'hit_def': [],
              'hit_id': [],
              'title': [],
              'length': [],
              'e_value': [],
              'sequence': []}
  
      # Get alignments from blast result.
      for i, s in enumerate(blast_record.alignments):
          data['accession'] = s.accession
          data['hit_def'] = s.hit_def
          data['hit_id'] = s.hit_id
          data['title'] = s.title
          data['length'] = s.length
          data['e_value'] = s.hsps[0].expect
          data['sequence'] = s.hsps[0].sbjct
  
      # Port to DataFrame.
      return pd.DataFrame(data)
docs: Read BLAST XML format.