UNPKG

ucsc-xena-client

Version:

UCSC Xena Client. Functional genomics visualizations.

87 lines (79 loc) 2.05 kB
'use strict'; var Rx = require('./rx'); var docs = function docs(samples) { return Rx.Observable.ajax({ url: '/api/ties/documents/list', headers: { 'Content-Type': 'text/plain' }, body: JSON.stringify({ patientIds: samples }), responseType: 'text', method: 'POST' }).map(function (_ref) { var response = _ref.response; return JSON.parse(response).results; }); }; var doc = function doc(id) { return Rx.Observable.ajax({ url: '/api/ties/documents/' + id, headers: { 'Content-Type': 'text/plain' }, responseType: 'text', method: 'GET' }).map(function (result) { return JSON.parse(result.response); }); }; // XXX Currently, no way to limit by sample id? var conceptMatches = function conceptMatches(patients, concept) { return Rx.Observable.ajax({ url: '/api/ties/query/', body: { concept: concept, limit: 1000 * 1000 // try to defeat limit }, responseType: 'text', method: 'POST' }).map(function (result) { return JSON.parse(result.response).results; }); }; var textMatches = function textMatches(patients, text) { return Rx.Observable.ajax({ url: '/api/ties/query/', body: { text: text, limit: 1000 * 1000 // try to defeat limit }, responseType: 'text', method: 'POST' }).map(function (result) { return JSON.parse(result.response).results; }); }; var concepts = function concepts(term) { return Rx.Observable.ajax({ url: '/api/ties/search/?term=' + encodeURIComponent(term), responseType: 'text', method: 'GET' }).map(function (result) { return JSON.parse(result.response); }); }; var goodConcepts = function goodConcepts() { return Rx.Observable.create(function (observer) { require.ensure(['./tiesConcepts.json'], function () { var concepts = require('./tiesConcepts.json'); // defer to avoid reducer re-entry setTimeout(function () { return observer.next(concepts); }, 0); }); }); }; module.exports = { docs: docs, doc: doc, textMatches: textMatches, conceptMatches: conceptMatches, concepts: concepts, goodConcepts: goodConcepts };