Skip to content
Permalink
Browse files

- Update license

- Refactor querying code to allow specifying database
  • Loading branch information...
abradle
abradle committed Sep 5, 2018
1 parent fa3e590 commit 830b3f567cae92c89a61652fa1f50b4e5aa9ef64
Showing with 11 additions and 17 deletions.
  1. +1 −1 LICENSE
  2. +7 −13 frag/network/query.py
  3. +2 −2 frag/utils/network_utils.py
  4. +1 −1 setup.py
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2018 Diamond Light Source

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ def add_follow_ups(tx, input_str):

def find_proximal(tx, input_str):
return tx.run(
"match p = (n:F2{smiles:$smiles})-[nm]-(m:EM) "
"match p = (n:F2{smiles:$smiles})-[nm]-(m:EM)"
"where abs(n.hac-m.hac) <= 3 and abs(n.chac-m.chac) <= 1 "
"return n, nm, m "
"order by split(nm.label, '|')[4];",
@@ -70,19 +70,13 @@ def get_type(r_group_form, sub_one, sub_two):


def define_double_edge_type(record):
"""
Define the type returned for proximal systems
:param record:
:return:
"""
mol_one = record["sta"]
first_label = str(record["nm"]["label"].split("|")[4])
label = str(record["ne"]["label"].split("|")[4])
mol_two = record["mid"]
mol_three = record["end"]
diff_one = mol_one["hac"] - mol_two["hac"]
diff_two = mol_two["hac"] - mol_three["hac"]

ret_obj = ReturnObject(mol_one["smiles"], mol_three["smiles"], label, 2)
if "." in label:
ret_obj.frag_type = "LINKER"
@@ -139,9 +133,9 @@ def organise(records, num_picks):
return out_d


def get_picks(smiles, num_picks):
def get_picks(smiles, num_picks, graph_url="neo4j"):
smiles = canon_input(smiles)
driver = get_driver()
driver = get_driver(graph_url)
with driver.session() as session:
records = []
for record in session.read_transaction(find_proximal, smiles):
@@ -161,9 +155,9 @@ def get_picks(smiles, num_picks):
print("Nothing found for input: " + smiles)


def get_full_graph(smiles):
def get_full_graph(smiles, graph_url="neo4j"):
smiles = canon_input(smiles)
driver = get_driver()
driver = get_driver(graph_url)
with driver.session() as session:
records = []
for record in session.read_transaction(find_proximal, smiles):
@@ -183,8 +177,8 @@ def get_full_graph(smiles):
print("Nothing found for input: " + smiles)


def custom_query(query):
driver = get_driver()
def custom_query(query, graph_url="neo4j"):
driver = get_driver(graph_url)
records = []
with driver.session() as session:
for record in session.read_transaction(find_custom, query):
@@ -286,15 +286,15 @@ def get_type(smiles):
return "FG"


def get_driver():
def get_driver(url="neo4j"):
"""
Get the driver to the network connection
:return: the driver for the graphdabase
"""
# No auth on the database
from neo4j.v1 import GraphDatabase

driver = GraphDatabase.driver("bolt://neo4j:7687")
driver = GraphDatabase.driver("bolt://" + url + ":7687")
return driver


@@ -40,7 +40,7 @@
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
# Pick your license as you wish (should match "license" above)
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
"Programming Language :: Python :: 2",

0 comments on commit 830b3f5

Please sign in to comment.
You can’t perform that action at this time.