generated from kevinxin90/typescript_template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
entity_object.ts
33 lines (28 loc) · 1.02 KB
/
entity_object.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { BioLinkClass, BioLinkEntityObject } from '../types/types';
import { pascalCase } from 'pascal-case';
import BaseObject from './base_object';
export default class Entity extends BaseObject implements BioLinkEntityObject {
private _id_prefixes: string[];
constructor(name: string, info: BioLinkClass) {
super(name, info);
this.id_prefixes = info.id_prefixes;
this._parent = typeof info.is_a === 'undefined' ? info.is_a : pascalCase(info.is_a);
}
get id_prefixes(): string[] {
return this._id_prefixes;
}
set id_prefixes(idPrefixes: string[]) {
if (this._name === 'Gene') {
this._id_prefixes = [...['SYMBOL', 'OMIM', 'UMLS'], ...idPrefixes];
} else if (this._name === 'ChemicalSubstance') {
this._id_prefixes = [...['UMLS'], ...idPrefixes];
} else if (this._name === 'Disease') {
this._id_prefixes = [...['GARD'], ...idPrefixes];
} else {
this._id_prefixes = idPrefixes;
}
}
addChild(child: string): void {
this._children.push(pascalCase(child));
}
}