Created
July 20, 2015 11:44
-
-
Save joshkh/a563ca7d4f4f73e52c30 to your computer and use it in GitHub Desktop.
Intermine: Modify and run a template query.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://cdn.intermine.org/js/intermine/imjs/3.14.0/im.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> | |
</head> | |
<body> | |
<script> | |
var mousemine = new imjs.Service({root: 'www.mousemine.org/mousemine'}); | |
// How to get all templates: | |
mousemine.fetchTemplates().then(function(templates) { | |
console.log("all templates", templates); | |
}); | |
// How to get a specific template: | |
mousemine.templateQuery("GO_Publications").then(function(query) { | |
console.log("GO_Publications Template's query is", query); | |
console.log("Constraints are", query.constraints); | |
// Find the constraints that are editable and replace their values | |
// with "reproduction" | |
var editableConstraints = query.constraints.filter(function (con) { | |
console.log("next editable constraint", con); | |
con.value = "reproduction" | |
return con.editable == true; | |
}); | |
// There's no need to push the constraint back onto the template | |
// because we manipulated it by reference. | |
console.log("Finished editing constraints", editableConstraints); | |
mousemine.rows(query).then(function(values) { | |
console.log("values", values); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment