-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from FZJ-INM1-BDA/feat_compoundFt
feat: add gene endpoint
- Loading branch information
Showing
19 changed files
with
385 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import gene |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from api.common import data_decorator | ||
from api.siibra_api_config import ROLE | ||
from api.models.vocabularies.genes import GeneModel | ||
|
||
@data_decorator(ROLE) | ||
def get_genes(find:str=None): | ||
"""Get all genes | ||
Args: | ||
string to find in vocabularies | ||
Returns: | ||
List of the genes.""" | ||
from api.serialization.util.siibra import GENE_NAMES | ||
|
||
if find == None: | ||
return_list = [v for v in GENE_NAMES] | ||
else: | ||
return_list = GENE_NAMES.find(find) | ||
|
||
return [GeneModel( | ||
symbol=v.get("symbol"), | ||
description=v.get("description") | ||
).dict() for v in return_list] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from api.models._commons import ( | ||
ConfigBaseModel, | ||
) | ||
from abc import ABC | ||
|
||
class _VocabBaseModel(ConfigBaseModel, ABC, type="vocabulary"): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .base import _VocabBaseModel | ||
|
||
class GeneModel(_VocabBaseModel, type="gene"): | ||
symbol: str | ||
description: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,6 @@ | |
|
||
from siibra import parcellations, spaces, atlases | ||
|
||
from siibra.vocabularies import GENE_NAMES | ||
|
||
import siibra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from fastapi import APIRouter, HTTPException | ||
from fastapi_pagination import paginate, Page | ||
from fastapi_versioning import version | ||
|
||
from api.server.util import SapiCustomRoute | ||
from api.server import FASTAPI_VERSION | ||
from api.siibra_api_config import ROLE | ||
from api.common import router_decorator | ||
from api.models.vocabularies.genes import GeneModel | ||
from api.common.data_handlers.vocabularies.gene import get_genes | ||
|
||
TAGS= ["vocabularies"] | ||
"""HTTP vocabularies tags""" | ||
|
||
router = APIRouter(route_class=SapiCustomRoute, tags=TAGS) | ||
"""HTTP vocabularies router""" | ||
|
||
@router.get("/genes", response_model=Page[GeneModel]) | ||
@version(*FASTAPI_VERSION) | ||
@router_decorator(ROLE, func=get_genes) | ||
def get_genes(find:str=None, func=None): | ||
"""HTTP get (filtered) genes""" | ||
if func is None: | ||
raise HTTPException(500, "func: None passed") | ||
return paginate(func(find=find)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
feature_types = [ | ||
((), "FunctionalConnectivity",) | ||
((), "ReceptorDensityFingerprint",) | ||
((), "ReceptorDensityProfile",) | ||
((), "MRIVolumeOfInterest",) | ||
((), "BlockfaceVolumeOfInterest",) | ||
((), "RegionalBOLD",) | ||
((), "PLIVolumeOfInterest",) | ||
((), "DTIVolumeOfInterest",) | ||
((), "TracingConnectivity",) | ||
((), "StreamlineLengths",) | ||
((), "StreamlineCounts",) | ||
((), "AnatomoFunctionalConnectivity",) | ||
] | ||
|
||
import os | ||
from subprocess import run | ||
MONITOR_FIRSTLVL_DIR = os.getenv("MONITOR_FIRSTLVL_DIR") | ||
dirs = os.listdir(MONITOR_FIRSTLVL_DIR) | ||
for dir in dirs: | ||
result = run(["du", "-s", f"{MONITOR_FIRSTLVL_DIR}/{dir}"], capture_output=True, text=True) | ||
size_b, *_ = result.stdout.split("\t") | ||
print(size_b) | ||
print("dir", size_b, int(size_b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.