From db6964bd12be9c956b8b6d7501e79e0cb6ce77c7 Mon Sep 17 00:00:00 2001 From: Eugene Clark Date: Tue, 16 Jan 2024 12:54:03 -0500 Subject: [PATCH] Improve performance of AnyVar.put_object() by eliminating unnecessary digest computation (#73) * Return digest from vrs_enref instead of recomputing * Removed unused import * Bump ga4gh.vrs dependency version to 2.0.0a2 * Change unused var name to "_" Co-authored-by: Kori Kuzma --------- Co-authored-by: Kori Kuzma --- src/anyvar/anyvar.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/anyvar/anyvar.py b/src/anyvar/anyvar.py index 347b465..f7fbf02 100644 --- a/src/anyvar/anyvar.py +++ b/src/anyvar/anyvar.py @@ -9,7 +9,6 @@ from typing import Optional from urllib.parse import urlparse -from ga4gh.core import ga4gh_identify from ga4gh.vrs import vrs_deref, vrs_enref from anyvar.storage import DEFAULT_STORAGE_URI, _Storage @@ -83,10 +82,10 @@ def put_object(self, variation_object: VrsObject) -> Optional[str]: :return: Object digest if successful, None otherwise """ try: - v = vrs_enref(variation_object, self.object_store) + id, _ = vrs_enref(variation_object, self.object_store, True) except ValueError: return None - return ga4gh_identify(v) + return id def get_object(self, object_id: str, deref: bool = False) -> Optional[VrsObject]: """Retrieve registered variation.