def mk_struct(name, label, resn=None, chain=None,
              color='white', style='cartoon',
              transparency=None):
    """Generate the PyMol code to display a structure."""
    return """
create %(label)s, %(name)s %(chain)s %(resn)s
show %(style)s, %(label)s
color %(color)s, %(label)s 
%(transparency)s
""" % {
        'label':    label,  # ENH: make optional
        'name':     name,
        'resn':     ("and resn %s" % resn) if resn else '',
        'chain':    ("and chain %s" % chain) if chain else '',
        'color':    color,
        'style':    style,
        'transparency': ("set %s_transparency=%s, %s\n" %
                    (style.rstrip('s'), transparency, label) 
                    if transparency is not None else ''),
        }