Skip to content

Commit

Permalink
fix(metacyc): use displayName to match pathways instead of mcId
Browse files Browse the repository at this point in the history
The composite reaction pathways have reaction mcId formats instead of pathway mcId.
  • Loading branch information
y1zhou committed Feb 16, 2022
1 parent 9c99a2a commit b1a71e3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions metabolike/db/metacyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def link_pathway_to_superpathway(self, pathway_id: str, superpathway_id: str):
logger.debug(f"Pathway {pathway_id} has SuperPathway {superpathway_id}")
self.write(
"""
MATCH (pw:Pathway {mcId: $pw_id})
MATCH (pw:Pathway {displayName: $pw_id})
MERGE (spw:Pathway {mcId: $super_pw})
ON CREATE SET spw.displayName = $super_pw
MERGE (spw)-[:hasSubPathway]->(pw)
Expand Down Expand Up @@ -311,7 +311,7 @@ def link_pathway_to_taxa(self, pathway_id: str, tax_id: str, relationship: str):
logger.debug(f"Pathway {pathway_id} {relationship} {tax_id}")
self.write(
f"""
MATCH (pw:Pathway {{mcId: $pw}})
MATCH (pw:Pathway {{displayName: $pw}})
MERGE (s:Taxa {{mcId: $taxa_id}})
MERGE (pw)-[:{relationship}]->(s)
""",
Expand All @@ -323,7 +323,7 @@ def link_pathway_to_rate_limiting_step(self, pathway_id: str, reaction_id: str):
logger.debug(f"Pathway {pathway_id} has rate limiting step {reaction_id}")
self.write(
"""
MATCH (pw:Pathway {mcId: $pw}),
MATCH (pw:Pathway {displayName: $pw}),
(r:Reaction {canonicalId: $rxn})
MERGE (pw)-[l:hasReaction]->(r)
ON MATCH SET l.isRateLimitingStep = true
Expand All @@ -339,7 +339,7 @@ def link_pathway_to_primary_compound(
self.write(
f"""
MATCH (cpd:Compound)-[:is]->(:RDF {{Biocyc: $compound_id}}),
(pw:Pathway {{mcId: $pw}})-[:hasReaction]->(:Reaction)-[:hasLeft|hasRight]->(cpd)
(pw:Pathway {{displayName: $pw}})-[:hasReaction]->(:Reaction)-[:hasLeft|hasRight]->(cpd)
MERGE (pw)-[:hasPrimary{relationship}]->(cpd)
""",
pw=pathway_id,
Expand Down Expand Up @@ -426,8 +426,8 @@ def get_view_of_pathway(self, pathway_id: str):
"""
nodes = self.read(
"""
MATCH (:Pathway {mcId: $pw_id})-[l:hasReaction]->(r:Reaction)
WHERE r.canonical_id = r.displayName
MATCH (:Pathway {displayName: $pw_id})-[l:hasReaction]->(r:Reaction)
WHERE r.canonicalId = r.displayName
WITH r
MATCH (r)-[:is]->(rrdf:RDF),
(r)-[:hasGeneProduct|hasComponent|hasMember*]->(gp:GeneProduct)-[:isEncodedBy]->(grdf:RDF)
Expand All @@ -444,8 +444,8 @@ def get_view_of_pathway(self, pathway_id: str):

edges = self.read(
"""
MATCH (:Pathway {mcId: $pw_id})-[l:hasReaction]->(r:Reaction)
WHERE r.canonical_id = r.displayName
MATCH (:Pathway {displayName: $pw_id})-[l:hasReaction]->(r:Reaction)
WHERE r.canonicalId = r.displayName
WITH COLLECT(r) AS nodes
UNWIND nodes AS r1
UNWIND nodes AS r2
Expand Down

0 comments on commit b1a71e3

Please sign in to comment.