Skip to content

Commit 0999790

Browse files
committed
foo
1 parent bacbfed commit 0999790

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

cellengine/Gates/gate_util.py

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from .. import _helpers
66

77

8-
def common_gate_create(experiment_id, body, tailored_per_file, fcs_file_id,
9-
fcs_file, create_population):
8+
def common_gate_create(
9+
experiment_id, body, tailored_per_file, fcs_file_id, fcs_file, create_population
10+
):
1011
"""
1112
<Description>
1213
@@ -46,36 +47,39 @@ def common_gate_create(experiment_id, body, tailored_per_file, fcs_file_id,
4647
Example:
4748
<Example>
4849
"""
49-
body = parse_fcs_file_args(experiment_id, body, tailored_per_file,
50-
fcs_file_id, fcs_file)
51-
52-
body = _helpers.convert_dict(body, 'snake_to_camel')
53-
res = _helpers.base_create(gate.Gate,
54-
url="experiments/{0}/gates".format(experiment_id),
55-
expected_status=201,
56-
json=body, params={'createPopulation':
57-
create_population}
58-
)
50+
body = parse_fcs_file_args(
51+
experiment_id, body, tailored_per_file, fcs_file_id, fcs_file
52+
)
53+
54+
body = _helpers.convert_dict(body, "snake_to_camel")
55+
res = _helpers.base_create(
56+
gate.Gate,
57+
url="experiments/{0}/gates".format(experiment_id),
58+
expected_status=201,
59+
json=body,
60+
params={"createPopulation": create_population},
61+
)
5962
return res
6063

6164

62-
def parse_fcs_file_args(experiment_id, body, tailored_per_file, fcs_file_id,
63-
fcs_file):
65+
def parse_fcs_file_args(experiment_id, body, tailored_per_file, fcs_file_id, fcs_file):
6466
"""Find the fcs file ID if 'tailored_per_file' and either 'fcs_file' or
6567
'fcs_file_id' are specified."""
6668
if fcs_file is not None and fcs_file_id is not None:
6769
raise ValueError("Please specify only 'fcs_file' or 'fcs_file_id'.")
6870
if fcs_file is not None and tailored_per_file is True: # lookup by name
6971
_file = get_fcsfile(experiment_id, name=fcs_file)
7072
fcs_file_id = _file._id
71-
body['tailoredPerFile'] = tailored_per_file
72-
body['fcsFileId'] = fcs_file_id
73+
body["tailoredPerFile"] = tailored_per_file
74+
body["fcsFileId"] = fcs_file_id
7375
return body
7476

7577

7678
def get_fcsfile(experiment_id, _id=None, name=None):
7779
if _id:
78-
content = _helpers.base_get("experiments/{0}/fcsfiles/{1}".format(experiment_id, _id))
80+
content = _helpers.base_get(
81+
"experiments/{0}/fcsfiles/{1}".format(experiment_id, _id)
82+
)
7983
content = FcsFile(properties=content)
8084
else:
8185
content = _helpers.load_fcsfile_by_name(experiment_id, name)
@@ -119,23 +123,25 @@ def create_gates(experiment_id=None, gates=None, create_all_populations=True):
119123
"""
120124
prepared_gates = []
121125
for g in gates:
122-
g.update({'_id': _helpers.generate_id()})
123-
if 'gid' not in g.keys():
124-
g.update({'gid': _helpers.generate_id()})
126+
g.update({"_id": _helpers.generate_id()})
127+
if "gid" not in g.keys():
128+
g.update({"gid": _helpers.generate_id()})
125129
prepared_gates.append(g)
126130

127131
new_gates = []
128132
for each_gate in prepared_gates:
129133
if create_all_populations is False:
130-
create_populations = each_gate.get('create_population', False)
134+
create_populations = each_gate.get("create_population", False)
131135
else:
132136
create_populations = create_all_populations
133-
new_gate = common_gate_create(experiment_id=each_gate.get('experiment_id', experiment_id),
134-
body=each_gate,
135-
tailored_per_file=each_gate.get('tailored_per_file', False),
136-
fcs_file_id=each_gate.get('fcs_file_id', None),
137-
fcs_file=each_gate.get('fcs_file', None),
138-
create_population=create_populations)
137+
new_gate = common_gate_create(
138+
experiment_id=each_gate.get("experiment_id", experiment_id),
139+
body=each_gate,
140+
tailored_per_file=each_gate.get("tailored_per_file", False),
141+
fcs_file_id=each_gate.get("fcs_file_id", None),
142+
fcs_file=each_gate.get("fcs_file", None),
143+
create_population=create_populations,
144+
)
139145
new_gates.append(new_gate)
140146

141147
return new_gates
@@ -175,12 +181,14 @@ def delete_gates(experiment_id, _id=None, gid=None, exclude=None):
175181

176182

177183
def gate_style(prnt_doc, child_doc):
178-
desc = child_doc[:child_doc.index('Args')].strip()
179-
args = child_doc[child_doc.index('Args')+5:child_doc.index('Returns')].strip()
180-
args = re.sub('\n', '\n ', args)
181-
returns = child_doc[child_doc.index('Returns')+10:child_doc.index('Example')].strip()
182-
example = child_doc[child_doc.index('Example')+10:].strip()
183-
keys = ['<Description>', '<Gate Args>', '<Returns>', '<Example>']
184+
desc = child_doc[: child_doc.index("Args")].strip()
185+
args = child_doc[child_doc.index("Args") + 5 : child_doc.index("Returns")].strip()
186+
args = re.sub("\n", "\n ", args)
187+
returns = child_doc[
188+
child_doc.index("Returns") + 10 : child_doc.index("Example")
189+
].strip()
190+
example = child_doc[child_doc.index("Example") + 10 :].strip()
191+
keys = ["<Description>", "<Gate Args>", "<Returns>", "<Example>"]
184192
sections = [desc, args, returns, example]
185193
docs = prnt_doc
186194
for key, section in zip(keys, sections):

0 commit comments

Comments
 (0)