ppktstore.registry package
- ppktstore.registry.configure_phenopacket_registry(store_dir: str | ~pathlib.Path | None = None, release_service: ~ppktstore.registry._api.PhenopacketStoreReleaseService = <ppktstore.registry._github.GitHubPhenopacketStoreReleaseService object>, remote_phenopacket_store_service: ~ppktstore.registry._api.RemotePhenopacketStoreService = <ppktstore.registry._github.GitHubRemotePhenopacketStoreService object>) PhenopacketStoreRegistry [source]
A function for getting default
PhenopacketStoreRegistry
.- Parameters:
store_dir – path to the directory for storing the registry data (
$HOME/.phenopacket-store
if None is provided).release_service – the service for getting release tags. By default, the tags are fetched from GitHub REST API.
remote_phenopacket_store_service – a service for getting Phenopacket Store ZIP release data. By default, the data is obtained from GitHub REST API.
- class ppktstore.registry.PhenopacketStoreRegistry(data_dir: Path, release_service: PhenopacketStoreReleaseService, remote_phenopacket_store_service: RemotePhenopacketStoreService)[source]
Bases:
object
PhenopacketStoreRegistry manages Phenopacket Store releases on a local system.
The registry fetches a ZIP archive with a specific version of Phenopacket Store (or the latest version) from GitHub and stores it in a data directory. Any subsequent openings of Phenopacket Store will use the local ZIP file.
- open_phenopacket_store(release: str | None = None) PhenopacketStoreZipAdaptor [source]
Open Phenopacket Store.
Provides an adaptor object that should be used as a context manager to ensure proper resource cleanup.
Example
Let’s load all phenopackets of the SUOX cohort from the 0.1.18 release of Phenopacket Store:
>>> from ppktstore.registry import configure_phenopacket_registry >>> registry = configure_phenopacket_registry() >>> with registry.open_phenopacket_store(release="0.1.18") as ps: ... phenopackets = list(ps.iter_cohort_phenopackets("SUOX")) >>> len(phenopackets) 35
- Parameters:
release – a str with Phenopacket Store release tag (e.g. 0.1.18) or None if the latest release should be loaded.
- resolve_registry_path(release: str | None = None) Path [source]
Resolve the path of a specific Phenopacket Store release within the registry.
Note, the path points to the location of the release ZIP in the local filesystem. The path may point to a non-existing file, if the load function has not been run yet.
Example
>>> from ppktstore.registry import configure_phenopacket_registry >>> registry = configure_phenopacket_registry() >>> registry.resolve_registry_path(release='0.1.18') pathlib.Path('/home/user/.phenopacket-store/0.1.18.zip')
- Parameters:
release – an optional str with the desired PS release (if None, the latest release will be provided).
- Returns:
a path to the PS release file.
- class ppktstore.registry.PhenopacketStoreReleaseService[source]
Bases:
object
PhenopacketStoreReleaseService knows how to fetch the Phenopacket Store release tags (e.g. 0.1.18).
- class ppktstore.registry.RemotePhenopacketStoreService[source]
Bases:
object
RemotePhenopacketStoreService knows how to open a
typing.BinaryIO
for reading content of a particular Phenopacket Store release.- abstractmethod fetch_resource(release: str) BufferedIOBase [source]
Open a connection for reading bytes of the remote resource.
- Parameters:
release – a str with the desired Phenopacket Store release.
- Returns:
a binary IO for reading the Phenopacket Store data.