import fnmatch


def lookup_files(label,labels, PDB_files, traj='All'):
    """
    returns all files that are assigned to a given label   
    You can use traj to specify that you only care about files in a given trajectory
    The defalt is 'All' (all trajectories are considered )
    """
    files=[f for n,f in enumerate(PDB_files) if labels[n]==label ]
    if traj!='All':
         files = [f for f in files if fnmatch.fnmatch( f, '*_{}*'.format(traj))]
    return files