Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: weight edge attribute doesn't throw errors anymore (#127) #129

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 15 additions & 13 deletions dotmotif/executors/NeuPrintExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,19 @@ def motif_to_cypher(
for (u, v), a in motif.list_edge_constraints().items():
for key, constraints in a.items():
key = key.strip('"') # remove quotes if any
attribute, sub_attribute = key.split(".")
if attribute in json_attributes:
for operator, values in constraints.items():
for value in values:
this_edge = """{}_{}["{}"] {} {}""".format(
u, v, key, operator, str(value)
)
that_edge = """(apoc.convert.fromJsonMap({}.roiInfo)["{}"].{} {} {})""".format(
u, attribute, sub_attribute, operator, str(value)
)
cypher = cypher.replace(this_edge, that_edge)
else:
print("Unknown JSON edge constraint: {}".format(key))
if "." in key:
attribute, sub_attribute = key.split(".")
if attribute in json_attributes:
for operator, values in constraints.items():
for value in values:
this_edge = """{}_{}["{}"] {} {}""".format(
u, v, key, operator, str(value)
)
that_edge = """(apoc.convert.fromJsonMap({}.roiInfo)["{}"].{} {} {})""".format(
u, attribute, sub_attribute, operator, str(value)
)
cypher = cypher.replace(this_edge, that_edge)
else:
print("Unknown JSON edge constraint: {}".format(key))

return cypher
2 changes: 1 addition & 1 deletion dotmotif/executors/test_neuprintexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_edge_constraints_notation1(self):
def test_edge_constraints_notation2(self):
motif = Motif().from_motif(
"""
A -> B ["CRE(L).pre" > 10, "CX.post" > 20]
A -> B [weight > 10, "CRE(L).pre" > 10, "CX.post" > 20]
"""
)
E = NeuPrintExecutor(HOST, DATASET, TOKEN)
Expand Down