def mk_residue(name, num,  restype='X', chain=None, label=None, mol='',
               color='magenta', style=None):
    """Generate the PyMol code to display a residue."""
    return """
create %(label)s, %(name)s and resi %(num)s %(chain)s and not (name %(bbone)s)
show %(style)s, %(label)s
color %(color)s, %(label)s
util.cnc %(label)s
""" % {
        'label':    label or ("%s%s-%s" % (restype, num, mol)),
        'name':     name,
        'chain':    ('and chain %s' % chain) if chain else '',
        'bbone':    "c,n,o" if restype != 'P' else "c,o",
        'num':      num,
        'color':    color,
        'style':    style or ('sticks' if restype != 'G' else 'spheres'),
        }