from functools import reduce


def get_residue_strings(resname_list, resid_list):
    """
    Give a list of residue names and list of residue PDB sequence identifiers,
    return string represnetation of the lists to put in SVG for use e.g
    in hovertext on interactive SVG.

    Parameters:
       resname_list - list of 3-letter residue names
       resid_list - list of residue PDB sequence numbers

    Return value:
       tuple (residue_names, residue_list) where
       residue_names is string with all residue names space-separated
       residue_list is string with all sequene numbers space-separarated
    """
    # can have empty residue name and id lists for eg connectors
    # that are between a terminus and an SSE node, and no coil region
    # between terminus and that SSE
    if len(resname_list) > 1:
        residue_names = reduce(lambda a,b : a + ' ' + b, resname_list)
        residue_ids = reduce(lambda a,b : str(a) + ' ' + str(b), resid_list)
    elif len(resname_list) == 1:
        residue_names = str(resname_list[0])
        residue_ids = str(resid_list[0])
    else:
        residue_names = ""
        residue_ids = ""
    return (residue_names, residue_ids)