from typing import Dict


def _create_pdb_map(outfile: str) -> Dict[int, str]:
  """Create a mapping from atom numbers to lines to write to pdbqt

  This is a map from rdkit atom number to its line in the pdb
  file. We also add the two additional columns required for
  pdbqt (charge, symbol).

  Note rdkit atoms are 0 indexed and pdb files are 1 indexed

  Parameters
  ----------
  outfile: str
    filename which already has a valid pdb representation of mol

  Returns
  -------
  pdb_map: Dict[int, str]
    Maps rdkit atom numbers to lines to be written to PDBQT file.
  """
  lines = [x.strip() for x in open(outfile).readlines()]
  lines = list(
      filter(lambda x: x.startswith("HETATM") or x.startswith("ATOM"), lines))
  lines = [x[:66] for x in lines]
  pdb_map = {}
  for line in lines:
    my_values = line.split()
    atom_number = int(my_values[1])
    atom_symbol = my_values[2]
    atom_symbol = ''.join([i for i in atom_symbol if not i.isdigit()])
    line = line.replace("HETATM", "ATOM  ")
    line = "%s    +0.000 %s\n" % (line, atom_symbol.ljust(2))
    pdb_map[atom_number - 1] = line
  return pdb_map