GraphGists

Metabolic pathways are naturally modeled as graphs. We can use Neo4j to do some analysis of them. This gist uses the citric acid cycle as an example.

The model is very simple:

svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJncmFwaGRpYWdyYW0iIHZpZXdCb3g9Ii0xMTMxLjk3NDI0MzE2NDA2MjUgLTExMDYuOTQyOTk5MTIxNDAyNiAyNTYwIDEyOTgiPjxnIGNsYXNzPSJsYXllciByZWxhdGlvbnNoaXBzIj48ZyBjbGFzcz0icmVsYXRlZC1wYWlyIj48ZyBjbGFzcz0icmVsYXRpb25zaGlwIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtNDM5LjkyLC0xNzAuNTYpIHJvdGF0ZSgwKSI+PHBhdGggY2xhc3M9InJlbGF0aW9uc2hpcCIgZD0iTSAxMjkuMzM2MjQ3MDQxNzIwNyA0IEwgNDM2LjE2NTUxOTY2NDg5MzQ1IDQgTCA0MzYuMTY1NTE5NjY0ODkzNDUgMTYgTCA0NjguMTY1NTE5NjY0ODkzNDUgMCBMIDQzNi4xNjU1MTk2NjQ4OTM0NSAtMTYgTCA0MzYuMTY1NTE5NjY0ODkzNDUgLTQgTCAxMjkuMzM2MjQ3MDQxNzIwNyAtNCBaIiBmaWxsPSJyZ2IoMCwgMCwgMCkiIHN0cm9rZT0icmdiKDUxLCA1MSwgNTEpIiBzdHJva2Utd2lkdGg9IjBweCI+PC9wYXRoPjx0ZXh0IGNsYXNzPSJ0eXBlIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBiYXNlbGluZS1zaGlmdD0iMzAlIiBhbGlnbm1lbnQtYmFzZWxpbmU9ImFscGhhYmV0aWMiIHg9IjI4Mi43NTA4ODMzNTMzMDcxIiB5PSIwIiBmb250LXNpemU9IjUwcHgiIGZvbnQtZmFtaWx5PSInR2lsbCBTYW5zJywgJ0dpbGwgU2FucyBNVCcsIENhbGlicmksIHNhbnMtc2VyaWYiPlNVQlNU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DQzNCAtMTYgTCA0MTkuOTQ1MTY4OTczOTA0MzQgLTQgTCAxMjYuNDQ0NTc3OTkxMzU2NTIgLTQgWiI+PC9wYXRoPjxwYXRoIGNsYXNzPSJyZWxhdGlvbnNoaXAgb3ZlcmxheSIgZmlsbD0icmdiYSgyNTUsIDI1NSwgMjU1LCAwKSIgc3Ryb2tlPSJyZ2JhKDI1NSwgMjU1LCAyNTUsIDApIiBzdHJva2Utd2lkdGg9IjEwcHgiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDE1NC42OTAwOTc2NTYyNSwtNzU4Ljc1Mzc1OTc2NTYyNSkgcm90YXRlKDkwKSIgZD0iTSAxMTUuOTA4NDg1NTE4OTAwOSA0IEwgNDI5Ljc0OTE4MTc3NDI2ODUgNCBMIDQyOS43NDkxODE3NzQyNjg1IDE2IEwgNDYxLjc0OTE4MTc3NDI2ODUgMCBMIDQyOS43NDkxODE3NzQyNjg1IC0xNiBMIDQyOS43NDkxODE3NzQyNjg1IC00IEwgMTE1LjkwODQ4NTUxODkwMDkgLTQgWiI+PC9wYXRoPjwvZz48L3N2Zz4=

The complete graph for the citric acid cycle is too complex to see clearly here:

But here is a visualization from the new Neo4j browser which I laid out by hand:

citric acid cycle

Calculations on the graph

Most of the reactions in the cycle cancel each other out, but some molecules are produced and consumed. We can use Cypher to calculate the overall effect of one turn of the cycle.

This query shows the species that are consumed by the citric acid cycle:

MATCH (m:Molecule)
OPTIONAL MATCH p=(m)<-[:PRODUCES]-()
OPTIONAL MATCH s=(m)-[:SUBSTRATE]->()
WITH m, count(p) AS produced, count(s) AS consumed
WHERE produced < consumed
RETURN DISTINCT m.name AS species, produced - consumed AS net ORDER BY net ASC

This query shows the species that are produced by the citric acid cycle:

MATCH (m:Molecule)
OPTIONAL MATCH p=(m)<-[:PRODUCES]-()
OPTIONAL MATCH s=(m)-[:SUBSTRATE]->()
WITH m, count(p) AS produced, count(s) AS consumed
WHERE produced > consumed
RETURN DISTINCT m.name AS species, produced - consumed AS net ORDER BY net DESC

One of the important products of the citric acid cycle is NADH. These are all the enzymes which catalyse its production.

MATCH (e)-[:CATALYSES]->()-[:PRODUCES]->(m) WHERE m.name='NADH' RETURN e.name