Exemplo n.º 1
0
def wrapNewResource(path):
    # filter out non-resource file types:
    for ext in FILE_INDICES.keys():
        if path.endswith(ext):
            log.debug('Index file {f} given as regular file, will be treated '
                      ' as an index file instead'.format(f=path))
            return
    extRes = ExternalResource()
    path = resolveLocation(path)
    extRes.resourceId = path
    index_files = [
        path + ext for ext in FILE_INDICES.keys() if os.path.exists(path + ext)
    ]
    if index_files:
        extRes.addIndices(index_files)

    # Check for sub resources:
    for ext in SUB_RESOURCES:
        filen = '.'.join(path.split('.')[:-2]) + ext
        # don't want to add e.g. scraps to scraps:
        if os.path.exists(filen) and path.endswith('subreads.bam'):
            log.debug("Adding {} as a subresource".format(filen))
            subres = wrapNewResource(filen)
            setattr(extRes, ext.split('.')[1], subres)
    return extRes
Exemplo n.º 2
0
def wrapNewResource(path):
    possible_indices = [".fai", ".pbi", ".bai", ".metadata.xml"]
    for ext in possible_indices:
        if path.endswith(ext):
            log.debug(
                "Index file {f} given as regular file, will be treated " " as an index file instead".format(f=path)
            )
            return
    extRes = ExternalResource()
    path = resolveLocation(path)
    extRes.resourceId = path
    index_files = [path + ext for ext in possible_indices if os.path.exists(path + ext)]
    if index_files:
        extRes.addIndices(index_files)
    return extRes
Exemplo n.º 3
0
def wrapNewResource(path):
    possible_indices = ['.fai', '.pbi', '.bai', '.metadata.xml']
    for ext in possible_indices:
        if path.endswith(ext):
            log.debug('Index file {f} given as regular file, will be treated '
                      ' as an index file instead'.format(f=path))
            return
    extRes = ExternalResource()
    path = resolveLocation(path)
    extRes.resourceId = path
    index_files = [
        path + ext for ext in possible_indices if os.path.exists(path + ext)
    ]
    if index_files:
        extRes.addIndices(index_files)
    return extRes
Exemplo n.º 4
0
def wrapNewResource(path):
    # filter out non-resource file types:
    for ext in FILE_INDICES:
        if path.endswith(ext):
            log.debug('Index file {f} given as regular file, will be treated '
                      ' as an index file instead'.format(f=path))
            return
    extRes = ExternalResource()
    path = resolveLocation(path)
    extRes.resourceId = path
    index_files = [path + ext for ext in FILE_INDICES if
                   os.path.exists(path + ext)]
    if index_files:
        extRes.addIndices(index_files)

    # Check for sub resources:
    for ext in SUB_RESOURCES:
        filen = '.'.join(path.split('.')[:-2]) + ext
        # don't want to add e.g. scraps to scraps:
        if os.path.exists(filen) and path.endswith('subreads.bam'):
            subres = wrapNewResource(filen)
            setattr(extRes, ext.split('.')[1], subres)
    return extRes