-
Notifications
You must be signed in to change notification settings - Fork 0
/
constraint-add.html
92 lines (81 loc) · 2.61 KB
/
constraint-add.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!doctype html>
<html>
<head>
<meta name="description" content="Adding constraints to a table">
<script src="https://cdn.rawgit.com/intermine/CDN/feb5bb77/js/intermine/imjs/3.15.0/im.min.js"></script>
<script src="https://cdn.rawgit.com/intermine/CDN/feb5bb77/js/intermine/im-tables/2.0.2/imtables.min.js"></script>
<link href="https://cdn.rawgit.com/intermine/CDN/feb5bb77/js/intermine/im-tables/2.0.2/main.css" rel="stylesheet">
<link href="styles/main.css" rel="stylesheet" />
<title>Adding a query dynamically after the table is initialised</title>
</head>
<body>
<nav>
<a href="index.html">Back</a>
<a href="https://github.com/yochannah/im-tables-examples/blob/master/constraint-add.html">View source on GitHub</a>
</nav>
<h1>Adding a constraint dynamically after the table is initialised</h1>
<script>
var selector = '#some-elem';
var service = {
root: 'https://yeastmine.yeastgenome.org/yeastmine'
};
var query = {
"name": "Gene_GO",
"title": "Gene --> GO terms",
"comment": "06.06.07 updated to work from gene class - Philip",
"description": "Search for GO annotations for a particular gene.",
"from": "Gene",
"select": [
"secondaryIdentifier",
"goAnnotation.ontologyTerm.identifier",
"goAnnotation.ontologyTerm.name",
"goAnnotation.evidence.code.code",
"goAnnotation.ontologyTerm.namespace",
"goAnnotation.qualifier"
],
"orderBy": [{
"path": "secondaryIdentifier",
"direction": "ASC"
}],
"where": [{
"path": "Gene",
"op": "LOOKUP",
"value": "YGL207W",
"extraValue": "S. cerevisiae",
"code": "A",
"editable": true,
"switched": "LOCKED",
"switchable": false
}]
};
imtables.loadTable(
selector, // Can also be an element, or a jQuery object.
{
"start": 0,
"size": 25
}, // May be null
{
service: service,
query: query
} // May be an imjs.Query
)
//if you omit this next code block we get many results,
// but with the added constraint you get only 1.
.then(
function(table) {
console.log('Table loaded', table);
//to add a constraint:
table.query.addConstraint({
"path": "goAnnotation.ontologyTerm.name",
"op": "==",
"value": "protein binding"
});
},
function(error) {
console.error('Could not load table', error);
}
);
</script>
<div id="some-elem"></div>
</body>
</html>