Skip to content

Commit

Permalink
added get embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed May 8, 2024
1 parent 63de649 commit 0018abf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bedhost/routers/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def get_bedbase_db_stats():
"""
Returns statistics
"""
return bbagent.get_stats()
return bbagent.get_stats


@router.get(
Expand Down
43 changes: 42 additions & 1 deletion bedhost/routers/bed_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
BedClassification,
BedPEPHub,
BedListSearchResult,
UniverseMetadata,
TokenizedBedResponse,
)
from bbconf.exceptions import BEDFileNotFoundError
from bbconf.exceptions import BEDFileNotFoundError, TokenizeFileNotExistError

from .. import _LOGGER
from ..main import bbagent
Expand Down Expand Up @@ -186,6 +188,22 @@ async def get_bed_pephub(
status_code=404,
)

@router.get(
"/{bed_id}/embedding",
summary="Get embeddings for a single BED record",
response_model=List,
)
def get_bed_embedding(bed_id: str = BedDigest):
"""
Returns embeddings for a single BED record.
"""
try:
return bbagent.bed.get_embedding(bed_id)
except BEDFileNotFoundError as _:
raise HTTPException(
status_code=404,
)


@router.get(
"/{bed_id}/regions/{chr_num}",
Expand Down Expand Up @@ -289,3 +307,26 @@ async def bed_to_bed_search(
region_set, limit=limit, offset=offset
)
return results


@router.get(
"/{bed_id}/tokenized/{universe_id}",
summary="Get tokenized of bed file",
response_model=TokenizedBedResponse,
)
async def get_tokenized(
bed_id: str,
universe_id: str,
):
"""
Return univers of bed file
Example: bed: 0dcdf8986a72a3d85805bbc9493a1302 | universe: 58dee1672b7e581c8e1312bd4ca6b3c7
"""
try:
return bbagent.bed.get_tokenized(bed_id, universe_id)

except TokenizeFileNotExistError as _:
raise HTTPException(
status_code=404,
detail="Tokenized file not found",
)
4 changes: 2 additions & 2 deletions requirements/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# bbconf @ git+https://github.com/databio/bbconf.git@dev#egg=bbconf
bbconf>=0.5.1
bbconf @ git+https://github.com/databio/bbconf.git@dev#egg=bbconf
# bbconf>=0.6.0
fastapi>=0.103.0
logmuse>=0.2.7
markdown
Expand Down

0 comments on commit 0018abf

Please sign in to comment.