def rename_NRPS_domains(synthase):
    """Replace domain types in Hybrid and NRPS Synthases.

    The acyl carrier protein (ACP) domain in PKSs is homologous to the thioester
    domain of the peptide carrier protein (PCP) domain in NRPSs, and as such, both
    PKS and NRPS will report the same conserved domain hit. In NRPS, it is
    convention to name these T, i.e.::

        A-ACP-C --> A-T-C

    In hybrid PKS-NRPS, this replacement is made in the NRPS module of the synthase.
    Thus, this function looks for a condensation (C) domain that typically signals
    the beginning of such a module, and replaces any ACP with T after that domain.

    An example PKS-NRPS domain architecture may resemble::

        KS-AT-DH-ER-KR-ACP-C-A-T-R

    Thioester reductase (TR) domains are generally written as R in NRPS, thus the
    replacement here.

    Parameters
    ----------
    synthase : models.Synthase
        An NRPS or Hybrid Synthase object.

    Raises
    ------
    ValueError
        If `type` is not 'Hybrid' or 'NRPS'.
    """
    if synthase.type not in ('Hybrid', 'NRPS'):
        raise ValueError("Expected 'Hybrid' or 'NRPS'")
    start, replace = 0, {'ACP': 'T', 'TR': 'R'}
    if synthase.type == 'Hybrid':
        for start, domain in enumerate(synthase.domains):
            if domain.type in ('C', 'E'):
                break
    for domain in synthase.domains[start:]:
        if domain.type in replace:
            domain.type = replace[domain.type]
