class QueryGetter: def __init__(self): self.query_handler = QueryHandler() def search(self, query_str, keyed=False, incl='', excl=''): return self.query_handler.search(query_str=query_str, keyed=keyed, incl=incl, excl=excl) def normalize(self, query_str): return self.query_handler.normalize(query_str)
class QueryGetter: def __init__(self): self.query_handler = QueryHandler() def search(self, query_str, incl='hgnc'): resp = self.query_handler.search(query_str, keyed=True, incl=incl) return resp.source_matches[SourceName.HGNC]
class QueryGetter: def __init__(self): self.query_handler = QueryHandler() def search(self, query_str, incl="ensembl"): resp = self.query_handler.search(query_str, keyed=True, incl=incl) return resp.source_matches[SourceName.ENSEMBL.value]
def test_emit_warnings(): """Test that emit_warnings works correctly.""" expected_warnings = [{ "non_breaking_space_characters": "Query contains non-breaking space characters" }] query_handler = QueryHandler() # Test emit no warnings actual_warnings = query_handler.emit_warnings('spry3') assert actual_warnings == [] # Test emit warnings actual_warnings = query_handler.emit_warnings('sp ry3') assert actual_warnings == actual_warnings actual_warnings = query_handler.emit_warnings('sp\u00A0ry3') assert expected_warnings == actual_warnings actual_warnings = query_handler.emit_warnings('sp ry3') assert expected_warnings == actual_warnings actual_warnings = query_handler.emit_warnings('sp\xa0ry3') assert expected_warnings == actual_warnings
def __init__(self): self.query_handler = QueryHandler()
"""Main application for FastAPI""" from fastapi import FastAPI, HTTPException, Query from fastapi.openapi.utils import get_openapi from typing import Optional from gene import __version__ from gene.query import QueryHandler, InvalidParameterException from gene.schemas import SearchService, NormalizeService, \ UnmergedNormalizationService import html query_handler = QueryHandler() app = FastAPI(docs_url="/gene", openapi_url="/gene/openapi.json", swagger_ui_parameters={"tryItOutEnabled": True}) def custom_openapi(): """Generate custom fields for OpenAPI response""" if app.openapi_schema: return app.openapi_schema openapi_schema = get_openapi(title="The VICC Gene Normalizer", version=__version__, openapi_version="3.0.3", description="Normalize gene terms.", routes=app.routes) # openapi_schema['info']['license'] = { # TODO # "name": "name of our license", # "url": "http://www.our-license-tbd.com" # } openapi_schema['info']['contact'] = { "name":