Skip to content

Commit

Permalink
do not allow edge attribtues with same type id for trapi
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed Oct 21, 2024
1 parent eb63a41 commit 195c4bd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/graph/knowledge_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default class KnowledgeGraph {

//handle TRAPI APIs (Situation A of https://github.com/biothings/BioThings_Explorer_TRAPI/issues/208) and APIs that define 'edge-atributes' in x-bte
const seenPmids = new Set();
const seenAttrs = new Set();
kgEdge.attributes['edge-attributes']?.forEach((attribute) => {
// Do not add multiple SemmedDB sentences/other "supporting study results" from the same publication
if (attribute.attribute_type_id === "biolink:has_supporting_study_result" && attribute?.attributes?.find((attr) => attr.attribute_type_id === "biolink:publications")) {
Expand All @@ -186,7 +187,11 @@ export default class KnowledgeGraph {
}
seenPmids.add(publication);
}

// Do not add duplicate attributes for TRAPi
else if (seenAttrs.has(attribute.attribute_type_id)) {
return;
}
seenAttrs.add(attribute.attribute_type_id);
attributes.push(attribute);
});

Expand Down

0 comments on commit 195c4bd

Please sign in to comment.