Skip to content

Commit

Permalink
server: filter by dorothea levels or methods only records that are …
Browse files Browse the repository at this point in the history
…included in the result solely based on dorothea evidences
  • Loading branch information
deeenes committed Jun 23, 2023
1 parent 52841ef commit d732a52
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions pypath/omnipath/server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2120,23 +2120,32 @@ def interactions(
return self._serve_dataframe(tbl, req)


@staticmethod
def _dorothea_dataset_filter(tbl, args):
@classmethod
def _dataset_included(cls, dataset: str, args: dict) -> bool:

return (
dataset in args['datasets'] |
(
not args['datasets'] and
cls.dataset2type.get(dataset, None) in args['types']
)
)


@classmethod
def _dorothea_dataset_filter(cls, tbl: pd.DataFrame, args: dict):

return (
np.logical_not(tbl.dorothea) |
(
# if the tf_target dataset is requested
# we need to serve it including the parts which
# don't fit the filters below
(
('tf_target' in args['datasets']) |
(
(not args['datasets']) &
('transcriptional' in args['types'])
)
) &
cls._dataset_included('tf_target', args) &
tbl.tf_target
) |
(
cls._dataset_included('collectri', args) &
tbl.collectri
)
)

Expand Down

0 comments on commit d732a52

Please sign in to comment.