Skip to content

Commit

Permalink
server: intercell - single query option for topology and causality
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed May 27, 2020
1 parent fd17477 commit 5f9a12a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pypath/__version__
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.12
0.11.13
55 changes: 55 additions & 0 deletions src/pypath/omnipath/server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,21 @@ class TableServer(BaseServer):
'sec': {'1', '0', 'no', 'yes'},
'pmp': {'1', '0', 'no', 'yes'},
'pmtm': {'1', '0', 'no', 'yes'},
'causality': {
'transmitter',
'trans',
'receiver',
'rec',
'both'
},
'topology': {
'secreted',
'sec',
'plasma_membrane_peripheral',
'pmp',
'plasma_membrane_transmembrane',
'pmtm',
},
},
'intercell_summary': {
'header': None,
Expand Down Expand Up @@ -1965,6 +1980,46 @@ def intercell(self, req):

tbl = tbl[getattr(tbl, _long) == this_arg]

if b'causality' in req.args:

causality = self._args_set(req, 'causality')

trans = causality & {'transmitter', 'trans', 'both'}
rec = causality & {'receiver', 'rec', 'both'}
tbl = (
tbl[tbl.transmitter | tbl.receiver]
if trans and rec else
tbl[tbl.transmitter]
if trans else
tbl[tbl.receiver]
if rec else
tbl
)

if b'topology' in req.args:

topology = self._args_set(req, 'topology')
query = ' or '.join(
colname
for enabled, colname in
(
(topology & {'secreted', 'sec'}, 'secreted'),
(
topology & {'plasma_membrane_peripheral', 'pmp'},
'plasma_membrane_peripheral'
),
(
topology & {'plasma_membrane_transmembrane', 'pmtm'},
'plasma_membrane_transmembrane'
)
)
if enabled
)

if query:

tbl = tbl.query(query)

# filtering for categories
if b'categories' in req.args:

Expand Down

0 comments on commit 5f9a12a

Please sign in to comment.