Skip to content

Commit

Permalink
Merge pull request #222 from biothings/duplicate-edge-attributes
Browse files Browse the repository at this point in the history
do not allow edge attribtues with same type id for trapi
  • Loading branch information
tokebe authored Oct 22, 2024
2 parents eb63a41 + 195c4bd commit 8cce9a6
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 8cce9a6

Please sign in to comment.