Skip to content

Commit

Permalink
Merge pull request #75 from cancervariants/issue-74
Browse files Browse the repository at this point in the history
Use vrstaile-pydantic, fix one off error in seq loc
  • Loading branch information
korikuzma authored Aug 31, 2021
2 parents 6dd633c + 6c0f277 commit 300f7fa
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 673 deletions.
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ gffutils = "*"
requests = "*"
"biocommons.seqrepo" = "*"
seqrepo = "*"
"ga4gh.vrs" = "==0.6.3rc0"
"ga4gh.vrs" = {version = "==0.7.0rc3", extras = ["extras"]}
uvloop = "*"
websockets = "*"
httptools = "*"
typing-extensions = "*"
"ga4gh.vrsatile.pydantic" = "*"

[dev-packages]
gene = {editable = true, path = "."}
Expand Down
17 changes: 10 additions & 7 deletions gene/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from gene import NAMESPACE_LOOKUP, PREFIX_LOOKUP, ITEM_TYPES
from gene.database import Database
from gene.schemas import Gene, SourceMeta, MatchType, SourceName, \
ServiceMeta, GeneDescriptor, GeneValueObject, Extension, SourcePriority, \
NormalizeService, SearchService
ServiceMeta, SourcePriority, NormalizeService, SearchService
from ga4gh.vrsatile.pydantic.vrs_model import Gene as GeneValueObject
from ga4gh.vrsatile.pydantic.vrsatile_model import GeneDescriptor, Extension
from botocore.exceptions import ClientError
from boto3.dynamodb.conditions import Key
from datetime import datetime
Expand Down Expand Up @@ -93,9 +94,11 @@ def add_record(self,
# DynamoDB Numbers get converted to Decimal
if 'locations' in item:
for loc in item['locations']:
if loc['interval']['type'] == "SimpleInterval":
loc['interval']['start'] = int(loc['interval']['start'])
loc['interval']['end'] = int(loc['interval']['end'])
if loc['interval']['type'] == "SequenceInterval":
loc['interval']['start']['value'] = \
int(loc['interval']['start']['value'])
loc['interval']['end']['value'] = \
int(loc['interval']['end']['value'])
gene = Gene(**item)
src_name = item['src_name']

Expand Down Expand Up @@ -373,7 +376,7 @@ def _add_merged_meta(self, response: Dict) -> Dict:
"""
sources_meta = {}
gene_descr = response['gene_descriptor']
ids = [gene_descr['value']['id']] + gene_descr.get('xrefs', [])
ids = [gene_descr['gene']['gene_id']] + gene_descr.get('xrefs', [])
for concept_id in ids:
prefix = concept_id.split(':')[0]
src_name = PREFIX_LOOKUP[prefix.lower()]
Expand All @@ -396,7 +399,7 @@ def add_gene_descriptor(self, response, record, match_type,
params = {
"id": f"normalize.gene:{quote(response['query'])}",
"label": record["symbol"],
"value": GeneValueObject(id=record["concept_id"])
"gene": GeneValueObject(gene_id=record["concept_id"])
}

# xrefs
Expand Down
Loading

0 comments on commit 300f7fa

Please sign in to comment.