Skip to content

Commit

Permalink
adapt esummary response handling to new data format
Browse files Browse the repository at this point in the history
  • Loading branch information
bence42 committed Apr 6, 2024
1 parent 3530bc3 commit bcf08fe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion genie.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def find_specific_variation(variation_id: str | int) -> ClinVarVariation:
var.id = int(variation_id)
try:
var.title = data['title']
var.clinical_significance = data['clinical_significance']['description']
var.clinical_significance = data['germline_classification']['description']
var.accession = data['accession']
var.obj_type = data['obj_type']
var.cdna_change = data['variation_set'][0]['cdna_change']
Expand Down Expand Up @@ -254,6 +254,7 @@ def esummary_request(variation_id: int):
logging.debug(
f'esummary request took: {(time.time() - start_time) * 1000:.0f}ms')
response = json.loads(esummary_response.read())
ClinVarAPI.check_esummary_version(response)
return response
except Exception as e:
logging.debug(
Expand All @@ -263,6 +264,14 @@ def esummary_request(variation_id: int):
logging.error(f'esummary request failed 10 times.')
sys.exit(1)

@staticmethod
def check_esummary_version(response):
version = response['header']['version']
if version != '0.3':
logging.error(
'unsupported esummary version {version}. Please contact the Genie maintainer for an update.')
sys.exit(1)

@staticmethod
def get_variation_accession_version(variation_id: str | int) -> ClinVarVariation:
# e.g: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=clinvar&rettype=vcv&is_variationid&id=125889
Expand Down

0 comments on commit bcf08fe

Please sign in to comment.