def files_in_DS(s, DS, regex=False):
    """ Returns a list of all files from a given dataset
            that will be used in at least one job in this submission
            If regex==True, the list is converted to a regex string
        """
    assert DS in s.input_datasets(
        ), 'ERROR: dataset %s was not requested in the xml file' % DS
    files = []
    for j in s.jobs:
        if DS in j.infiles.keys():
            files += j.infiles[DS]
    if regex:
        return '|'.join(sorted(list(set(files))))
    else:
        return sorted(list(set(files)))
