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
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
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
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