How to use the gnomad.resources.resource_utils.BaseVersionedResource function in gnomad

To help you get started, we’ve selected a few gnomad examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github macarthur-lab / gnomad_hail / gnomad / resources / resource_utils.py View on Github external
self.default_version = default_version
        self.versions = versions

        super().__init__(
            path=versions[default_version].path,
            import_args=versions[default_version].import_args,
            import_func=versions[default_version].import_func
        )


    def __repr__(self):
        return f'{self.__class__.__name__}(default_version={self.default_version}, default_resource={self.versions[self.default_version]}, versions={list(self.versions.keys())})'


class VersionedTableResource(BaseVersionedResource, TableResource):
    """
    Versioned Table resource

    The attributes (path, import_args and import_func) of the versioned resource are those of the default version of the resource.
    In addition, all versions of the resource are stored in the `versions` attribute.

    :param default_version: The default version of this Table resource (must to be in the `versions` dict)
    :param versions: A dict of version name -> TableResource.
    """
    def __init__(self, default_version: str, versions: Dict[str, TableResource]):
        super().__init__(default_version, versions)


class VersionedMatrixTableResource(BaseVersionedResource, MatrixTableResource):
    """
    Versioned MatrixTable resource
github macarthur-lab / gnomad_hail / gnomad / resources / resource_utils.py View on Github external
class VersionedMatrixTableResource(BaseVersionedResource, MatrixTableResource):
    """
    Versioned MatrixTable resource

    The attributes (path, import_args and import_func) of the versioned resource are those of the default version of the resource.
    In addition, all versions of the resource are stored in the `versions` attribute.

    :param default_version: The default version of this MatrixTable resource (must to be in the `versions` dict)
    :param versions: A dict of version name -> MatrixTableResource.
    """

    def __init__(self, default_version: str, versions: Dict[str, MatrixTableResource]):
        super().__init__(default_version, versions)


class VersionedPedigreeResource(BaseVersionedResource, PedigreeResource):
    """
    Versioned Pedigree resource

    The attributes (path, import_args and import_func) of the versioned resource are those of the default version of the resource.
    In addition, all versions of the resource are stored in the `versions` attribute.

    :param default_version: The default version of this Pedigree resource (must be in the `versions` dict)
    :param versions: A dict of version name -> PedigreeResource.
    """

    def __init__(self, default_version: str, versions: Dict[str, PedigreeResource]):
        super().__init__(default_version, versions)


class VersionedBlockMatrixResource(BaseVersionedResource, BlockMatrixResource):
    """
github macarthur-lab / gnomad_hail / gnomad / resources / import_resources.py View on Github external
import gnomad.resources.grch37 as grch37
        grch37_resources = get_module_importable_resources(grch37, prefix='grch37')
    
    :param module: Input module
    :param prefix: 
    :return: 
    """
    _prefix = f"{prefix}." if prefix else ""
    resources = {}
    for resource_name, resource in getmembers(
        module, lambda x: isinstance(x, BaseResource)
    ):
        if resource.path and resource.import_func:
            arg_name = f"{_prefix}{resource_name}"
            if isinstance(resource, BaseVersionedResource):
                for version in resource.versions:
                    arg_name += f".{version}"
                    resource_name = f"{resource_name} version {version}"
            resources[arg_name] = (resource_name, resource)
    return resources
github macarthur-lab / gnomad_hail / gnomad / resources / resource_utils.py View on Github external
def __init__(self, default_version: str, versions: Dict[str, BaseResource]):
        if type(self) is BaseVersionedResource:
            raise TypeError("Can't instantiate abstract class BaseVersionedResource")

        if default_version not in versions:
            raise KeyError(
                f"default_version {default_version} not found in versions dictionary passed to {self.__class__.__name__}.")

        for version_name, version_resource in versions.items():
            if version_resource.__class__ not in self.__class__.__bases__:
                raise TypeError(f"Cannot create a {self.__class__.__name__} resource with version {version_name} of type {version_resource.__class__.__name__}")

        self.default_version = default_version
        self.versions = versions

        super().__init__(
            path=versions[default_version].path,
            import_args=versions[default_version].import_args,
github macarthur-lab / gnomad_hail / gnomad / resources / resource_utils.py View on Github external
class VersionedPedigreeResource(BaseVersionedResource, PedigreeResource):
    """
    Versioned Pedigree resource

    The attributes (path, import_args and import_func) of the versioned resource are those of the default version of the resource.
    In addition, all versions of the resource are stored in the `versions` attribute.

    :param default_version: The default version of this Pedigree resource (must be in the `versions` dict)
    :param versions: A dict of version name -> PedigreeResource.
    """

    def __init__(self, default_version: str, versions: Dict[str, PedigreeResource]):
        super().__init__(default_version, versions)


class VersionedBlockMatrixResource(BaseVersionedResource, BlockMatrixResource):
    """
    Versioned BlockMatrix resource

    The attributes (path, import_args and import_func) of the versioned resource are those of the default version of the resource.
    In addition, all versions of the resource are stored in the `versions` attribute.

    :param default_version: The default version of this BlockMatrix resource (must to be in the `versions` dict)
    :param versions: A dict of version name -> BlockMatrixResource.
    """

    def __init__(self, default_version: str, versions: Dict[str, BlockMatrixResource]):
        super().__init__(default_version, versions)


class DataException(Exception):
    pass