Commit 61451efa authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Using the new API

parent 306b0436
...@@ -2,16 +2,18 @@ ...@@ -2,16 +2,18 @@
// dataset identifiers's validity for instance. // dataset identifiers's validity for instance.
var request = require("request"); var request = require("request");
var url = "http://arraymap.org/api/?db=arraymap&api_out=icdmlist&api_out=icdmlist&api_doctype=json&icdm_m=8,9"; var url = "http://arraymap.org/qsubsets/?db=arraymap&collection=subsets&subsettype=ICDMORPHOLOGYCODE&querytext=8|9";
// var url = "http://arraymap.org/api/?db=arraymap&api_out=icdmlist&api_out=icdmlist&api_doctype=json&icdm_m=8010/2";
module.exports = { module.exports = {
getDatasetsFromArrayMap: function(callback) { getDatasetsFromArrayMap: function(callback) {
var object; var object;
request(url, function (error, response, body) { request(url, function (error, response, body) {
if (!error && response.statusCode == 200) { if (!error && response.statusCode == 200) {
// Incorrect json returned.
// Remove flanking parenthesis
body = body.replace(/^\(/, "");
body = body.replace(/\}\);/, "}");
object = getDatasets(JSON.parse(body)); object = getDatasets(JSON.parse(body));
console.log(object)
callback(object); callback(object);
} }
else { else {
...@@ -41,14 +43,17 @@ function getDatasets(json) { ...@@ -41,14 +43,17 @@ function getDatasets(json) {
infoinfo.email = "SIB-Technology@isb-sib.ch"; infoinfo.email = "SIB-Technology@isb-sib.ch";
var datasets = []; var datasets = [];
var array = json.data; var array = json.subsetdata;
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
var element = array[i]; var element = array[i];
var dataset = {}; var dataset = {};
dataset.id = element.ICDMORPHOLOGYCODE; // "UID":"80003","SUBSETCODE":"8000/3","SAMPLENO":7,"SUBSETTEXT":"8000/3: Neoplasm, malignant"
dataset.description = element.ICDMORPHOLOGY;
dataset.id = element.SUBSETCODE;
dataset.description = element.SUBSETTEXT;
dataset.reference = "reference genome"; dataset.reference = "reference genome";
var size = {}; var size = {};
......
...@@ -22,7 +22,8 @@ arrayMap.factory('BeaconService', ['$http', '$q', function ($http, $q) { ...@@ -22,7 +22,8 @@ arrayMap.factory('BeaconService', ['$http', '$q', function ($http, $q) {
function getDatasets() { function getDatasets() {
var defer = $q.defer(); var defer = $q.defer();
var url = "http://arraymap.org/api/?db=arraymap&api_out=icdmlist&api_out=icdmlist&api_doctype=json&icdm_m=8,9"; // var url = "http://arraymap.org/api/?db=arraymap&api_out=icdmlist&api_out=icdmlist&api_doctype=json&icdm_m=8,9";
var url = "http://arraymap.org/qsubsets/?db=arraymap&collection=subsets&subsettype=ICDMORPHOLOGYCODE&querytext=8|9";
var req = { var req = {
method: 'GET', method: 'GET',
...@@ -100,7 +101,7 @@ arrayMap.controller('BeaconController', ['$scope', '$location', 'BeaconService', ...@@ -100,7 +101,7 @@ arrayMap.controller('BeaconController', ['$scope', '$location', 'BeaconService',
BeaconService.getDatasets() BeaconService.getDatasets()
.then(function (datasets) { .then(function (datasets) {
$scope.datasets = datasets $scope.datasets = datasets;
}, },
function(datasets){ function(datasets){
console.log("Error getting datasets"); console.log("Error getting datasets");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment