diff --git a/src/edge_manager.ts b/src/edge_manager.ts index 543a6ea5..dabacb86 100644 --- a/src/edge_manager.ts +++ b/src/edge_manager.ts @@ -207,11 +207,8 @@ export default class QueryEdgeManager { const objectIDs = [record.object.original, record.object.curie, ...record.object.equivalentCuries]; // there must be at least a minimal intersection - const subjectMatch = - subjectIDs.some((curie) => execSubjectCuries.includes(curie)) || execSubjectCuries.length === 0; - const objectMatch = objectIDs.some((curie) => execObjectCuries.includes(curie)) || execObjectCuries.length === 0; - - //if both ends match then keep record + const subjectMatch = subjectIDs.some((curie) => execSubjectCuries.includes(curie)); + const objectMatch = objectIDs.some((curie) => execObjectCuries.includes(curie)); // Don't keep self-edges const selfEdge = [...subjectIDs].some((curie) => objectIDs.includes(curie)); diff --git a/src/inferred_mode/inferred_mode.ts b/src/inferred_mode/inferred_mode.ts index dbc538dc..7694b66f 100644 --- a/src/inferred_mode/inferred_mode.ts +++ b/src/inferred_mode/inferred_mode.ts @@ -337,21 +337,21 @@ export default class InferredQueryHandler { const specialHandling = [ Object.keys(result.node_bindings).length === 2, // Direct edge // Predicate matches or is descendant - qEdge.predicates.some( + qEdge.predicates?.some( (predicate) => predicate === boundEdge.predicate || biolink.getDescendantPredicates(predicate).includes(boundEdge.predicate), - ), + ) ?? false, // All query qualifiers (if any) are accounted for (more is fine) - qEdge.qualifier_constraints.some(({ qualifier_set }) => { + qEdge.qualifier_constraints?.some(({ qualifier_set }) => { return qualifier_set.every((queryQualifier) => - boundEdge.qualifiers.some( + boundEdge.qualifiers?.some( (qualifier) => queryQualifier.qualifier_type_id === qualifier.qualifier_type_id && queryQualifier.qualifier_value === qualifier.qualifier_value, - ), + ) ?? false, ); - }), + }) ?? false, ].every((test) => test); if (specialHandling) { translatedResult.analyses[0].edge_bindings = { [qEdgeID]: [{ id: boundEdgeID, attributes: [] }] };