From a69ba6fc7744c384c963f605c8ad6ff4100e72b3 Mon Sep 17 00:00:00 2001
From: Susanna Kiwala <susanna.kiwala@wustl.edu>
Date: Fri, 4 Oct 2024 12:09:16 -0500
Subject: [PATCH 1/3] Update queries and query parsing to work with new variant
 coordinate schema

---
 civicpy/civic.py | 54 ++++++++++++++++++------------------------------
 1 file changed, 20 insertions(+), 34 deletions(-)

diff --git a/civicpy/civic.py b/civicpy/civic.py
index 3d6d1db..6562352 100644
--- a/civicpy/civic.py
+++ b/civicpy/civic.py
@@ -1241,24 +1241,20 @@ def _postprocess_response_element(e, element):
         if e['__typename'] != 'GeneVariant':
             raise Exception("Variant type {} not supported yet".format(e['__typename']))
         e['entrez_id'] = e['gene']['featureInstance']['entrezId']
-        build = e['referenceBuild']
+        build = e['coordinates']['referenceBuild']
         if build == 'GRCH37':
             build = 'GRCh37'
         elif build == 'GRCH38':
             build = 'GRCh38'
         e['coordinates'] = {
-            'ensembl_version': e['ensemblVersion'],
+            'ensembl_version': e['coordinates']['ensemblVersion'],
             'reference_build': build,
-            'reference_bases': e['referenceBases'],
-            'variant_bases': e['variantBases'],
-            'representative_transcript': None if e['primaryCoordinates'] is None else e['primaryCoordinates']['representativeTranscript'],
-            'chromosome': None if e['primaryCoordinates'] is None else e['primaryCoordinates']['chromosome'],
-            'start': None if e['primaryCoordinates'] is None else e['primaryCoordinates']['start'],
-            'stop': None if e['primaryCoordinates'] is None else e['primaryCoordinates']['stop'],
-            'representative_transcript2': None if e['secondaryCoordinates'] is None else e['secondaryCoordinates']['representativeTranscript'],
-            'chromosome2': None if e['secondaryCoordinates'] is None else e['secondaryCoordinates']['chromosome'],
-            'start2': None if e['secondaryCoordinates'] is None else e['secondaryCoordinates']['start'],
-            'stop2': None if e['secondaryCoordinates'] is None else e['secondaryCoordinates']['stop'],
+            'reference_bases': e['coordinates']['referenceBases'],
+            'variant_bases': e['coordinates']['variantBases'],
+            'representative_transcript': e['coordinates']['representativeTranscript'],
+            'chromosome': e['coordinates']['chromosome'],
+            'start': e['coordinates']['start'],
+            'stop': e['coordinates']['stop'],
         }
     elif element == 'variant_group':
         e['variant_ids'] = [v['id'] for v in e['variants']['nodes']]
@@ -1535,22 +1531,17 @@ def _construct_get_variant_payload():
                     allele_registry_id: alleleRegistryId
                     clinvar_entries: clinvarIds
                     hgvs_expressions: hgvsDescriptions
-                    variantBases
-                    referenceBases
-                    referenceBuild
-                    primaryCoordinates {
-                        chromosome
-                        representativeTranscript
-                        start
-                        stop
-                    }
-                    secondaryCoordinates {
+                    coordinates {
+                        referenceBuild
+                        ensemblVersion
                         chromosome
                         representativeTranscript
                         start
                         stop
+                        referenceBases
+                        variantBases
+                        coordinateType
                     }
-                    ensemblVersion
                 }
                 gene: feature {
                     id
@@ -1591,22 +1582,17 @@ def _construct_get_all_variants_payload():
                         allele_registry_id: alleleRegistryId
                         clinvar_entries: clinvarIds
                         hgvs_expressions: hgvsDescriptions
-                        variantBases
-                        referenceBases
-                        referenceBuild
-                        primaryCoordinates {
+                        coordinates {
+                            referenceBuild
+                            ensemblVersion
                             chromosome
                             representativeTranscript
                             start
                             stop
+                            referenceBases
+                            variantBases
+                            coordinateType
                         }
-                        secondaryCoordinates {
-                            chromosome
-                            representativeTranscript
-                            start
-                            stop
-                        }
-                        ensemblVersion
                     }
                     gene: feature {
                         id

From 157444d89fba784eedbc5a279cb77bba2e34fe10 Mon Sep 17 00:00:00 2001
From: Susanna Kiwala <susanna.kiwala@wustl.edu>
Date: Tue, 8 Oct 2024 08:46:08 -0500
Subject: [PATCH 2/3] Update version

---
 civicpy/__version__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/civicpy/__version__.py b/civicpy/__version__.py
index 1cf4c3f..6b5bec6 100644
--- a/civicpy/__version__.py
+++ b/civicpy/__version__.py
@@ -3,7 +3,7 @@
 __url__ = 'http://civicpy.org'
 __major__ = '3'
 __minor__ = '1'
-__patch__ = '0'
+__patch__ = '1'
 __meta_label__ = ''
 __short_version__ = "{}.{}".format(__major__, __minor__)
 __version__ = "{}.{}".format(__short_version__, __patch__)

From b39a829cf2d43e4229e7f1352939e466350d7114 Mon Sep 17 00:00:00 2001
From: Susanna Kiwala <susanna.kiwala@wustl.edu>
Date: Tue, 8 Oct 2024 08:50:48 -0500
Subject: [PATCH 3/3] Document CACHE_TIMEOUT_DAYS env variable

---
 docs/install.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/install.rst b/docs/install.rst
index 1c0358b..a848a66 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -16,11 +16,11 @@ That's it!
 Configuring Cache Save
 ----------------------
 
-A local copy of the CIViCpy cache is kept by default at your $HOME/.civicpy/cache.pkl directory.
-You may configure an environment variable CIVICPY_CACHE_FILE to adjust this destination path for
+A local copy of the CIViCpy cache is kept by default at your ``$HOME/.civicpy/cache.pkl`` directory.
+You may configure an environment variable ``CIVICPY_CACHE_FILE`` to adjust this destination path for
 storing the cache. For example::
 
    >> .bashrc << echo "export CIVICPY_CACHE_FILE=$HOME/.civicpy/cache.pkl"
 
 When loading a cache, it will be updated automatically by CIViCpy if stale (default: after 7 days).
-Cache stale time is configurable when calling `civic.update_cache()`.
+Cache stale time is configurable when calling `civic.update_cache()` or by setting the CACHE_TIMEOUT_DAYS environment variable.