Commit 51e0a1cc authored by Tim Bleimehl's avatar Tim Bleimehl 🤸🏼
Browse files

init

parent 330a9f7a
.DS_Store
*.ipynb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
*/env/*
# billygene-vue-fastapi-edition
`uvicorn main:app --reload`
\ No newline at end of file
from Configs import ConfigBase
class DEFAULT(ConfigBase):
NEO4J = {}
LOG_LEVEL = "INFO"
import os
from typing import Optional, List, Union
from fastapi import FastAPI, Query
from Configs import getConfig
from config import DEFAULT
from py2neo import Graph
import logging
# logging.basicConfig(level=logging.DEBUG)
app = FastAPI()
config: DEFAULT = getConfig(
config_classes_pathes=[os.path.join(os.path.dirname(__file__), "config.py")],
dotenv_files_dir_path=os.path.join(os.path.dirname(__file__), "env/"),
)
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: Union[int, str], q: Optional[str] = None):
return {"item_id": item_id, "q": q}
@app.get("/article/{pmid}")
def articel_by_gene(pmid: Union[int, str]):
if isinstance(pmid, int):
pmid = str(pmid)
g = Graph(**config.NEO4J)
query = "MATCH (p:PubMedArticle) WHERE p.PMID = $pmid RETURN p as article"
res = g.run(query, parameters={"pmid": pmid}).data()
if res:
return res[0]["article"]
else:
return None
###################################################shit
@app.get("/bygenelist")
def articel_by_genes(g: Optional[list[str]] = Query(None)):
graph = Graph(**config.NEO4J)
print("g", g)
query = """
UNWIND $gene_symbols as x
MATCH (g:Gene {sid:x})
-[:REPLACED_BY*0..1]-(gs2:Gene)
-[:MAPS*0..2]-(gs3:Gene)
-[:SYNONYM*0..1]-(gs4:Gene)
<-[:MENTIONS]-(at:AbstractText)
<-[:ABSTRACT_HAS_ABSTRACTTEXT]-(a:Abstract)
<-[:PUBMEDARTICLE_HAS_ABSTRACT]-(p:PubMedArticle)
-[:PUBMEDARTICLE_HAS_MESHHEADINGLIST]->
(mhl:MeshHeadingList)-[*1..2]->
(md:MeshDescriptor)
RETURN DISTINCT g.sid,p.ArticleTitle
"""
res = graph.run(query, gene_symbols=g).data()
return res
fastapi
uvicorn[standard]
py2neo
from Configs import getConfig
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment