Skip to content

Commit

Permalink
fixed some bugs with biolink submodule and internal chp reasining.
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHydeDartmouth committed May 10, 2021
1 parent 52e4c56 commit a254c12
Show file tree
Hide file tree
Showing 3 changed files with 5,905 additions and 45 deletions.
2 changes: 1 addition & 1 deletion chp_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Object creation kwargs common to all clients
COMMON_KWARGS = {
"_default_url": 'http://chp.thayer.dartmouth.edu',
"_default_url": 'http://chp-dev.thayer.dartmouth.edu',
"_query_endpoint": '/query/',
"_query_all_endpoint": '/queryall/',
"_predicates_endpoint": '/predicates/',
Expand Down
23 changes: 10 additions & 13 deletions chp_client/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
BIOLINK_GENE: {
BIOLINK_DRUG: BIOLINK_INTERACTS_WITH,
BIOLINK_DISEASE: BIOLINK_GENE_ASSOCIATED_WITH_CONDITION,
}
},
BIOLINK_DRUG: {
BIOLINK_GENE: BIOLINK_INTERACTS_WITH,
BIOLINK_DISEASE: BIOLINK_TREATS,
Expand All @@ -37,9 +37,6 @@ def build_standard_query(
batch_diseases=None,
):

if genes is None and drugs is None:
if batch_genes is None and batch_drugs is None:
raise QueryBuildError("Both genes and drugs can't be None.")
if outcome is None:
raise QueryBuildError('You must specify an outcome CURIE.')
if outcome_op is None:
Expand Down Expand Up @@ -143,7 +140,7 @@ def build_wildcard_query(
batch_diseases=batch_diseases,
)
q = query.message.query_graph
disease_node = q.find_nodes(categories=BIOLINK_DISEASE)[0]
disease_node = q.find_nodes(categories=BIOLINK_DISEASE_ENTITY)[0]

wildcard_node = q.add_node(None, wildcard_category)
# Add wildcard to query
Expand All @@ -156,10 +153,10 @@ def build_wildcard_query(
return query

def build_onehop_query(
q_subjects,
q_subject_categories,
q_objects,
q_object_categories,
q_object_category,
q_subject_category,
q_subject=None,
q_object=None,
genes=None,
drugs=None,
outcome=None,
Expand All @@ -175,14 +172,14 @@ def build_onehop_query(
q = message.query_graph

# Add nodes
subject_node = q.add_node(q_subjects, q_subject_categories)
object_node = q.add_node(q_objects, q_object_categories)
subject_node = q.add_node(q_subject, q_subject_category)
object_node = q.add_node(q_object, q_object_category)

# Add edge
try:
edge_predicate = OBJECT_TO_SUBJECT_PREDICATE_MAP[(q_object_categories[0], q_subject_categories[0])]
edge_predicate = OBJECT_TO_SUBJECT_PREDICATE_MAP[q_object_category][q_subject_category]
except KeyError:
raise QueryBuildError('Edge from {} to {} is not supported.'.format(q_subject_categories[0], q_object_categories[0]))
raise QueryBuildError('Edge from {} to {} is not supported.'.format(q_subject_category, q_object_category))

edge_id = q.add_edge(subject_node, object_node, edge_predicate)

Expand Down
Loading

0 comments on commit a254c12

Please sign in to comment.