Skip to content

Commit

Permalink
fix distance endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
xuebingjie1990 committed May 19, 2022
1 parent 34b892c commit 1903d75
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bedhost/routers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def get_bedfile_metadata(
"""

res = bbc.bed.select(columns=ids, filter_conditions=[("md5sum", "eq", md5sum)])

print(res[0])
if res:
if ids:
colnames = ids
Expand Down
26 changes: 22 additions & 4 deletions bedhost/routers/private_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,38 @@ async def get_bedfiles_in_distance(
limit: int = Query(None, description="number of rows returned by the query"),
):
term = term.replace(" ", ",").split(",")
print(genome)

if ids:
assert_table_columns_match(bbc=bbc, table_name=BED_TABLE, columns=ids)

res = bbc.select_bedfiles_for_distance(
genome=genome, condition_val=term, bedfile_col=ids, limit=limit
bedfile_cols=ids,
filter_conditions=[
("search_term", "eq", term[0]),
],
)
if res:
colnames = list(res[0].keys())
values = [list(x.values()) for x in res]

for x in res:
values = []
if genome in str(x):
values.append(list(x))

if values:
if ids:
colnames = ids
else:
colnames = list(
serve_schema_for_table(bbc=bbc, table_name=BED_TABLE).keys()
)
colnames.extend(["bed_label", "search_term", "score"])

_LOGGER.info(f"Serving data for columns: {colnames}")
else:
_LOGGER.warning("No records matched the query")
colnames = []
values = [[]]

return {"columns": colnames, "data": values}


Expand Down

0 comments on commit 1903d75

Please sign in to comment.