Skip to content

Commit

Permalink
Merge pull request #107 from cancervariants/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
korikuzma authored Mar 24, 2022
2 parents 4559e96 + b0bfbd7 commit b17a54d
Show file tree
Hide file tree
Showing 16 changed files with 242 additions and 187 deletions.
3 changes: 3 additions & 0 deletions .ebextensions/01app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
commands:
01_install_postgresql_devel:
command: "yum install -y python-devel postgresql-devel"
5 changes: 2 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ beautifulsoup4 = "*"
gffutils = "*"
requests = "*"
"biocommons.seqrepo" = "*"
"ga4gh.vrs" = {version = ">=0.7.2", extras = ["extras"]}
"ga4gh.vrs" = {version = ">=0.7.5.dev1", extras = ["extras"]}
uvloop = "*"
websockets = "*"
httptools = "*"
typing-extensions = "*"
"ga4gh.vrsatile.pydantic" = ">=0.0.5"
jsonschema = ">=2.3, <4.0"
"ga4gh.vrsatile.pydantic" = ">=0.0.10"

[dev-packages]
gene = {editable = true, path = "."}
Expand Down
7 changes: 7 additions & 0 deletions gene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
logger.setLevel(logging.DEBUG)
logger.handlers = []

logging.getLogger("boto3").setLevel(logging.INFO)
logging.getLogger("botocore").setLevel(logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)
logging.getLogger("python_jsonschema_objects").setLevel(logging.INFO)
logging.getLogger("biocommons.seqrepo.seqaliasdb.seqaliasdb").setLevel(logging.INFO) # noqa: E501
logging.getLogger("biocommons.seqrepo.fastadir.fastadir").setLevel(logging.INFO) # noqa: E501

if 'GENE_NORM_EB_PROD' in environ:
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
Expand Down
6 changes: 5 additions & 1 deletion gene/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@


query_handler = QueryHandler()
app = FastAPI(docs_url='/gene', openapi_url='/gene/openapi.json')
app = FastAPI(
docs_url="/gene",
openapi_url="/gene/openapi.json",
swagger_ui_parameters={"tryItOutEnabled": True}
)


def custom_openapi():
Expand Down
4 changes: 2 additions & 2 deletions gene/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
from typing import List, Dict, Set
from urllib.parse import quote
from uvicorn.config import logger
from .version import __version__
from gene import NAMESPACE_LOOKUP, PREFIX_LOOKUP, ITEM_TYPES
from gene.database import Database
Expand All @@ -12,6 +11,7 @@
from botocore.exceptions import ClientError
from boto3.dynamodb.conditions import Key
from datetime import datetime
from gene import logger


class InvalidParameterException(Exception):
Expand Down Expand Up @@ -241,7 +241,7 @@ def _get_service_meta() -> ServiceMeta:
"""
return ServiceMeta(
version=__version__,
response_datetime=datetime.now()
response_datetime=str(datetime.now())
)

def search(self, query_str: str, keyed: bool = False,
Expand Down
23 changes: 18 additions & 5 deletions gene/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from ga4gh.vrsatile.pydantic.vrs_models import SequenceLocation, \
ChromosomeLocation, CURIE
from ga4gh.vrsatile.pydantic.vrsatile_models import GeneDescriptor
from datetime import datetime
from pydantic.types import StrictStr


Expand Down Expand Up @@ -82,6 +81,8 @@ class Gene(BaseModel):
class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['Gene']) -> None:
Expand Down Expand Up @@ -201,6 +202,8 @@ class SourceMeta(BaseModel):
class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['SourceMeta']) -> None:
Expand Down Expand Up @@ -235,6 +238,8 @@ class MatchesKeyed(BaseModel):
class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['MatchesKeyed']) -> None:
Expand Down Expand Up @@ -276,6 +281,8 @@ class MatchesListed(BaseModel):
class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['MatchesListed']) -> None:
Expand Down Expand Up @@ -309,12 +316,14 @@ class ServiceMeta(BaseModel):

name = 'gene-normalizer'
version: StrictStr
response_datetime: datetime
response_datetime: StrictStr
url = 'https://github.com/cancervariants/gene-normalization'

class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['ServiceMeta']) -> None:
Expand All @@ -326,7 +335,7 @@ def schema_extra(schema: Dict[str, Any],
schema['example'] = {
'name': 'gene-normalizer',
'version': '0.1.0',
'response_datetime': '2021-04-05T16:44:15.367831',
'response_datetime': '2022-03-23 15:57:14.180908',
'url': 'https://github.com/cancervariants/gene-normalization'
}

Expand All @@ -342,6 +351,8 @@ class SearchService(BaseModel):
class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['SearchService']) -> None:
Expand Down Expand Up @@ -388,7 +399,7 @@ def schema_extra(schema: Dict[str, Any],
"service_meta_": {
'name': 'gene-normalizer',
'version': '0.1.0',
'response_datetime': '2021-04-05T16:44:15.367831',
'response_datetime': '2022-03-23 15:57:14.180908',
'url': 'https://github.com/cancervariants/gene-normalization' # noqa: E501
}
}
Expand All @@ -407,6 +418,8 @@ class NormalizeService(BaseModel):
class Config:
"""Configure model example"""

use_enum_values = True

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['NormalizeService']) -> None:
Expand Down Expand Up @@ -533,7 +546,7 @@ def schema_extra(schema: Dict[str, Any],
"service_meta_": {
'name': 'gene-normalizer',
'version': '0.1.19',
'response_datetime': '2021-09-06T10:52:20.334720',
'response_datetime': '2022-03-23 15:57:14.180908',
'url': 'https://github.com/cancervariants/gene-normalization' # noqa: E501
}
}
2 changes: 1 addition & 1 deletion gene/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Gene normalizer version"""
__version__ = "0.1.24"
__version__ = "0.1.25"
6 changes: 4 additions & 2 deletions gene/vrs_locations/chromosome_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ def add_location(self, location):
chr=location['chr'],
interval=models.CytobandInterval(
start=location['start'],
end=location['end']
)
end=location['end'],
type="CytobandInterval"
),
type="ChromosomeLocation"
)
chr_location._id = ga4gh_identify(chr_location)
return chr_location.as_dict()
Expand Down
9 changes: 6 additions & 3 deletions gene/vrs_locations/sequence_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ def add_location(self, seqid, gene, params, sr):
seq_location = models.SequenceLocation(
sequence_id=sequence_id,
interval=models.SequenceInterval(
start=models.Number(value=gene.start - 1),
end=models.Number(value=gene.end)
)
start=models.Number(value=gene.start - 1,
type="Number"),
end=models.Number(value=gene.end, type="Number"),
type="SequenceInterval"
),
type="SequenceLocation"
)
seq_location._id = ga4gh_identify(seq_location)
location = seq_location.as_dict()
Expand Down
Loading

0 comments on commit b17a54d

Please sign in to comment.