forked from opentargets-archive/webapp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gene-ontology-directive.js
58 lines (53 loc) · 1.83 KB
/
gene-ontology-directive.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
angular.module('plugins')
.directive('geneOntology', ['$log', function ($log) {
'use strict';
return {
restrict: 'E',
templateUrl: 'plugins/gene-ontology.html',
scope: {
target: '='
},
link: function (scope, element, attrs) {
var gosByOntology = {
'F' : [],
'C' : [],
'P' : []
};
var gos = _.keys(scope.target.go);
for (var i=0; i<scope.target.go.length; i++) {
var go = scope.target.go[i];
var goid = go.id;
var ontology = go.value.term.substring(0,1);
gosByOntology[ontology].push ({label: go.value.term.substring(2),
goid: goid
});
}
var goArr = [];
if (gosByOntology.F.length) {
goArr.push (
{
"Ontology" : "Molecular Function",
"terms" : gosByOntology.F
}
);
}
if (gosByOntology.P.length) {
goArr.push (
{
"Ontology" : "Biological Process",
"terms" : gosByOntology.P
}
);
}
if (gosByOntology.C.length) {
goArr.push (
{
"Ontology" : "Cellular Component",
"terms" : gosByOntology.C
}
);
}
scope.goterms = goArr;
}
};
}]);