Skip to content

Commit

Permalink
Merge pull request #280 from RobokopU24/update/remove-predicate-filte…
Browse files Browse the repository at this point in the history
…ring

remove predicate filtering by sub/obj domain/range
  • Loading branch information
Woozl authored May 17, 2024
2 parents dd536a7 + 9c44188 commit 36bc954
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ export default function PredicateSelector({ id }) {
return null;
}

return biolink.predicates.filter(
(p) => subjectNodeCategoryHierarchy.includes(p.domain) &&
objectNodeCategoryHierarchy.includes(p.range),
).map((p) => p.predicate);
return biolink.predicates.map(({ predicate }) => predicate);
}

const filteredPredicateList = useMemo(
Expand Down
23 changes: 18 additions & 5 deletions src/stores/useBiolinkModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,29 @@ export default function useBiolinkModel() {
const [ancestorsMap, setAncestorsMap] = useState([]);
const colorMap = useCallback(getNodeCategoryColorMap(hierarchies), [hierarchies]);

function checkIfDescendantOfRelatedTo([name, slot]) {
let currentName = name;
let current = slot;
while (current.is_a) {
currentName = current.is_a;
current = biolinkModel.slots[current.is_a];
}
return currentName === 'related to';
}

/**
* Get a list of all predicates in the biolink model
* @returns {object[]} list of predicate objects
*/
function getEdgePredicates() {
const newPredicates = Object.entries(biolinkModel.slots).map(([identifier, predicate]) => ({
predicate: strings.edgeFromBiolink(identifier),
domain: strings.nodeFromBiolink(predicate.domain),
range: strings.nodeFromBiolink(predicate.range),
}));
const newPredicates =
Object.entries(biolinkModel.slots)
.filter(checkIfDescendantOfRelatedTo)
.map(([identifier, predicate]) => ({
predicate: strings.edgeFromBiolink(identifier),
domain: strings.nodeFromBiolink(predicate.domain),
range: strings.nodeFromBiolink(predicate.range),
}));
return newPredicates;
}

Expand Down

0 comments on commit 36bc954

Please sign in to comment.