Skip to content

Commit

Permalink
feat: handling for non-array values
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Apr 12, 2024
1 parent 46e8298 commit ac88bfc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/graph/knowledge_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { APIDefinition } from '@biothings-explorer/types';

const debug = Debug('bte:biothings-explorer-trapi:KnowledgeGraph');

const NON_ARRAY_ATTRIBUTES = ['biolink:knowledge_level', 'biolink:agent_type'];

export default class KnowledgeGraph {
nodes: {
[nodePrimaryID: string]: TrapiKGNode;
Expand Down Expand Up @@ -114,11 +116,14 @@ export default class KnowledgeGraph {
}

Object.entries(kgEdge.attributes).forEach(([key, value]) => {
if (key == 'edge-attributes') return;
if (key === 'edge-attributes') return;
// if (key == 'edge-attributes') return;
attributes.push({
attribute_type_id: key,
value: Array.from(value as Set<string>),
value: // technically works for numbers as well
NON_ARRAY_ATTRIBUTES.includes(key)
? [...(value as Set<string>)].reduce((acc, val) => acc + val)
: Array.from(value as Set<string>),
//value_type_id: 'bts:' + key,
});
});
Expand Down

0 comments on commit ac88bfc

Please sign in to comment.