code: def _seq1(seq, charmap: Dict[str, str], undef_code="X"):
      # sourcery skip: dict-assign-update-to-union
      """Convert protein sequence from three-letter to one-letter code.
      The single required input argument 'seq' should be a protein sequence
      using three-letter codes, either as a Python string or as a Seq or
      MutableSeq object.
      This function returns the amino acid sequence as a string using the one
      letter amino acid codes. Output follows the IUPAC standard (including
      ambiguous characters "B" for "Asx", "J" for "Xle", "X" for "Xaa", "U" for
      "Sel", and "O" for "Pyl") plus "*" for a terminator given the "Ter" code.
      Any unknown character (including possible gap characters), is changed
      into '-' by default.
      e.g.
      >>> from Bio.SeqUtils import seq1
      >>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAlaArgTer")
      'MAIVMGRWKGAR*'
      The input is case insensitive, e.g.
      >>> from Bio.SeqUtils import seq1
      >>> seq1("METalaIlEValMetGLYArgtRplysGlyAlaARGTer")
      'MAIVMGRWKGAR*'
      You can set a custom translation of the codon termination code using the
      dictionary "custom_map" argument (defaulting to {'Ter': '*'}), e.g.
      >>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAla***", custom_map={"***": "*"})
      'MAIVMGRWKGA*'
      You can also set a custom translation for non-amino acid characters, such
      as '-', using the "undef_code" argument, e.g.
      >>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAla------ArgTer", undef_code='?')
      'MAIVMGRWKGA??R*'
      If not given, "undef_code" defaults to "X", e.g.
      >>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAla------ArgTer")
      'MAIVMGRWKGAXXR*'
      """
      if charmap is None:
          charmap = {"Ter": "*"}
      # reverse map of threecode
      # upper() on all keys to enable caps-insensitive input seq handling
      onecode = {k.upper(): v for k, v in charmap.items()}
      # add the given termination codon code and custom maps
      onecode.update((k.upper(), v) for k, v in charmap.items())
      seqlist = [seq[3 * i : 3 * (i + 1)] for i in range(len(seq) // 3)]
      return "".join(
          onecode.get(aa.upper(), undef_code) for aa in seqlist
      )
  
imports: from __future__ import annotations
  import os
  import copy
  import gzip
  import warnings
  from string import ascii_uppercase
  from typing import Any, Dict, List, Union
  from warnings import warn
  import numpy
  import pandas
  from looseversion import LooseVersion
  from mmtf import MMTFDecoder, MMTFEncoder, fetch, parse, parse_gzip
  from biopandas.constants import protein_letters_3to1_extended
  from ..pdb.engines import amino3to1dict, pdb_df_columns, pdb_records
label_desc: Use image node_id 4 for calling a global function with example usage: _seq1(seq, charmap, undef_code) and returns: str