-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy paths1b_get_protein.py
executable file
·32 lines (23 loc) · 1.18 KB
/
s1b_get_protein.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
"""Retrieving a protein based on its identifier."""
# https://reactome.org/dev/graph-database/extract-participating-molecules#retrieving-objects
from __future__ import print_function
__copyright__ = "Copyright (C) 2018-present, DV Klopfenstein. All rights reserved."
__author__ = "DV Klopfenstein"
import sys
from neo4j import GraphDatabase
def main(password):
"""Retrieving a protein based on its identifier."""
# EntityWithAccessionedSequence (EWAS) which corresponds to a protein in Reactome.
# For this example we use one form of PTEN in the cytosol with identifier R-HSA-199420
qry = 'MATCH (ewas:EntityWithAccessionedSequence{stId:"R-HSA-199420"}) RETURN ewas'
gdbdr = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', password))
print(qry)
with gdbdr.session() as session:
for dct in session.run(qry).data():
for key, val in dct['ewas'].items():
print(" {KEY:15} {VAL}".format(KEY=key, VAL=val))
if __name__ == '__main__':
assert len(sys.argv) != 1, 'First arg must be your Neo4j database password'
main(sys.argv[1])
# Copyright (C) 2018-present, DV Klopfenstein. All rights reserved.