code: def protein_map_from_twg(twg):
      protein_map = {}
      unmatched = 0
      matched = 0
      logger.info('Building grounding map for human proteins')
      for agent_text, grounding_list, _ in twg:
          if 'UP' not in [entry[0] for entry in grounding_list]:
              continue
          uniprot_ids = [entry[1] for entry in grounding_list
                         if entry[0] == 'UP']
          for uniprot_id in uniprot_ids:
              mnemonic = uniprot_client.get_mnemonic(uniprot_id)
              if mnemonic is None or not mnemonic.endswith('_HUMAN'):
                  continue
              gene_name = uniprot_client.get_gene_name(uniprot_id)
              if gene_name is None:
                  unmatched += 1
                  continue
              if agent_text.upper() == gene_name.upper():
                  matched += 1
                  protein_map[agent_text] = {'TEXT': agent_text,
                                             'UP': uniprot_id}
              else:
                  unmatched += 1
      logger.info('Exact matches for %d proteins' % matched)
      logger.info('No match (or no gene name) for %d proteins' % unmatched)
      return protein_map