def atom_to_atom_line(a, lines):
    """Converts an :py:class:`.Atom` to an ATOM or HETATM record. ANISOU lines
    will also be added where appropriate.

    :param Atom a: The Atom to pack.
    :param list lines: the string lines to update."""

    line = "{:6}{:5} {:4} {:3} {:1}{:4}{:1}   "
    line += "{:>8}{:>8}{:>8}  1.00{:6}          {:>2}{:2}"
    id_, residue_name, chain_id, residue_id, insert_code = "", "", "", "", ""
    if a.het:
        id_, residue_name = a.het.id, a.het._name
        chain_id = a.chain.id if a.chain is not None else ""
        residue_id = int("".join([c for c in id_ if c.isdigit() or c == "-"]))
        insert_code = id_[-1] if id_ and id_[-1].isalpha() else ""
    atom_name = a._name or ""
    atom_name = " " + atom_name if len(atom_name) < 4 else atom_name
    occupancy = "  1.00"
    line = line.format(
     "HETATM" if isinstance(a.het, Ligand) or a._is_hetatm else "ATOM",
     a.id, atom_name, residue_name, chain_id, residue_id, insert_code,
     "{:.3f}".format(a.location[0]) if a.location[0] is not None else "",
     "{:.3f}".format(a.location[1]) if a.location[1] is not None else "",
     "{:.3f}".format(a.location[2]) if a.location[2] is not None else "",
     a.bvalue if a.bvalue is not None else "", a.element or "",
     str(int(a.charge))[::-1] if a.charge else "",
    )
    lines.append(line)
    if a.anisotropy != [0, 0, 0, 0, 0, 0]:
        lines.append(atom_to_anisou_line(a, atom_name,
         residue_name, chain_id, residue_id, insert_code))