The resource you are trying to access is not available at this URL. Please carefully check your address bar and try again, or return to the app.
18 |If problems persist, please contact us at <%=EMAIL_ADDRESS_INFO%>.
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/views/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |An error occurred and the requested resource could not be sent to you. We have been notified of the issue and are working to resolve it.
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/biopax/biopax.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import { expect } from 'chai'; 4 | import nock from 'nock'; 5 | import _ from 'lodash'; 6 | 7 | import { GROUNDING_SEARCH_BASE_URL } from '../../src/config'; 8 | import { mapToUniprotIds } from '../../src/server/routes/api/document'; 9 | 10 | describe('mapToUniprotIds', function(){ 11 | before( () => { 12 | const rawBiopaxTemplate = fs.readFileSync(path.resolve( __dirname, 'sampleTemplate.json' ), 'utf8'); 13 | this.biopaxTemplate = JSON.parse(rawBiopaxTemplate); 14 | 15 | const dbXref = this.dbXref = { 16 | id: '_testid', 17 | db: 'uniprot' 18 | }; 19 | 20 | const mockRes = [ 21 | { 22 | dbXrefs: [ 23 | dbXref 24 | ] 25 | } 26 | ]; 27 | 28 | nock(GROUNDING_SEARCH_BASE_URL) 29 | .post('/map') 30 | .times(Infinity) 31 | .reply(200, mockRes); 32 | }); 33 | 34 | after( () => { 35 | nock.cleanAll(); 36 | } ); 37 | 38 | it( 'updated uniprot ids', () => { 39 | const entityPaths = ['interactions.0.controller', 'interactions.0.source', 'interactions.0.participants.0', 'interactions.0.participants.1']; 40 | entityPaths.forEach( entityPath => { 41 | entityPaths.push(entityPath + '.components.0'); 42 | entityPaths.push(entityPath + '.components.1'); 43 | } ); 44 | 45 | return mapToUniprotIds(this.biopaxTemplate) 46 | .then( updatedTemplate => { 47 | entityPaths.forEach( entityPath => { 48 | const xrefPath = entityPath + '.xref'; 49 | const xref = _.get(updatedTemplate, xrefPath); 50 | if ( !_.isNil( xref ) ) { 51 | expect(xref.id).to.equal(this.dbXref.id); 52 | expect(xref.db).to.equal(this.dbXref.db); 53 | } 54 | } ); 55 | } ); 56 | } ); 57 | }); 58 | -------------------------------------------------------------------------------- /test/biopax/sampleTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "interactions":[ 3 | { 4 | "type":"Other Interaction", 5 | "participants":[ 6 | { 7 | "type":"protein", 8 | "name":"Ataxin 3", 9 | "xref":{ 10 | "id":"110616", 11 | "db":"NCBI Gene", 12 | "dbPrefix":"ncbigene" 13 | }, 14 | "organism":{ 15 | "id":"10090", 16 | "db":"taxonomy" 17 | } 18 | }, 19 | { 20 | "type":"complex", 21 | "name":"Complex (Rheb:ubiquitin)", 22 | "xref":null, 23 | "organism":null, 24 | "components":[ 25 | { 26 | "type":"protein", 27 | "name":"Rheb", 28 | "xref":{ 29 | "id":"19744", 30 | "db":"NCBI Gene", 31 | "dbPrefix":"ncbigene" 32 | }, 33 | "organism":{ 34 | "id":"10090", 35 | "db":"taxonomy" 36 | } 37 | },{ 38 | "type":"protein", 39 | "name":"ubiquitin", 40 | "xref":{ 41 | "id":"216818", 42 | "db":"NCBI Gene", 43 | "dbPrefix":"ncbigene" 44 | }, 45 | "organism":{ 46 | "id":"10090", 47 | "db":"taxonomy" 48 | } 49 | } 50 | ] 51 | } 52 | ] 53 | } 54 | ], 55 | "pathwayName":"Tributyrin ester-impregnated pH strips for confirming neonatal feeding tube placement: a diagnostic test accuracy study.", 56 | "pathwayId":"e22e6084-6505-4725-8792-7727484fec9b", 57 | "publication":{ 58 | "id":"36175118", 59 | "db":"pubmed" 60 | } 61 | } -------------------------------------------------------------------------------- /test/mock/cache.js: -------------------------------------------------------------------------------- 1 | import ElementCache from '../../src/model/element-cache'; 2 | import _ from 'lodash'; 3 | 4 | let factoryErr = function(){ 5 | throw new Error('Missing factory for cache'); 6 | }; 7 | 8 | let sourceErr = function(){ 9 | throw new Error('Missing source for cache'); 10 | }; 11 | 12 | let sourceNop = function(){ 13 | console.warn('Using nop source for mock cache'); 14 | }; 15 | 16 | class MockCache extends ElementCache { 17 | constructor( opts = {} ){ 18 | super( _.assign( { 19 | secret: 'secret', // used in almost all tests 20 | factory: { // needs to be specified manually 21 | make: factoryErr, 22 | load: factoryErr 23 | } 24 | }, opts ) ); 25 | 26 | this.source = { 27 | elements: new Map(), 28 | has: function( id ){ 29 | return this.elements.has( id ); 30 | }, 31 | get: function( id ){ 32 | return this.elements.get( id ); 33 | }, 34 | add: function( ele ){ 35 | this.elements.set( ele.id(), ele ); 36 | 37 | return Promise.resolve('MockCache source.add() promise'); 38 | }, 39 | remove: function( ele ){ 40 | this.elements.delete( _.isString( ele ) ? ele : ele.id() ); 41 | 42 | return Promise.resolve('MockCache source.remove() promise'); 43 | } 44 | }; 45 | } 46 | 47 | has( id ){ return this.source.has(id); } 48 | 49 | get( id ){ return this.source.get(id); } 50 | 51 | add( ele ){ return this.source.add(ele); } 52 | 53 | remove( ele ){ return this.source.remove(ele); } 54 | } 55 | 56 | export default MockCache; 57 | -------------------------------------------------------------------------------- /test/mock/socket.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash'; 2 | 3 | let defaults = { 4 | 5 | }; 6 | 7 | class Socket { 8 | constructor( opts ){ 9 | opts = Object.assign( {}, defaults, opts ); 10 | 11 | this.syncher = opts.syncher; 12 | } 13 | 14 | on(){ 15 | return this; 16 | } 17 | 18 | emit( type /* data..., onServer */ ){ 19 | let onServer = arguments[ arguments.length - 1 ]; 20 | 21 | if( !_.isFunction( onServer ) ){ 22 | onServer = _.noop; 23 | } 24 | 25 | if( type === 'load' ){ 26 | let err = null; 27 | 28 | onServer( err, _.omit( this.syncher.get(), this.syncher.privateFields() ) ); 29 | } else { 30 | onServer(); 31 | } 32 | 33 | return this; 34 | } 35 | 36 | } 37 | 38 | export default Socket; 39 | -------------------------------------------------------------------------------- /test/neo4j-test/connect-neo4j.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import neo4j from 'neo4j-driver'; 3 | 4 | import { closeDriver, getDriver, initDriver } from '../../src/neo4j/neo4j-driver.js'; 5 | 6 | describe('Neo4j Initiate Driver', () => { 7 | it('initDriver Should initialize and return a driver', () => { 8 | const driver = initDriver(); 9 | expect(driver).an.instanceof(neo4j.Driver); 10 | }); 11 | 12 | it('getDriver should return the driver', () => { 13 | initDriver(); 14 | const driver = getDriver(); 15 | expect(driver).an.instanceof(neo4j.Driver); 16 | }); 17 | 18 | it('closeDriver should remove driver instance', async () => { 19 | const driver = await closeDriver(); 20 | expect(driver).to.be.undefined; 21 | }); 22 | }); -------------------------------------------------------------------------------- /test/util/conf.js: -------------------------------------------------------------------------------- 1 | import Promise from 'bluebird'; 2 | 3 | Promise.config({ 4 | warnings: true, 5 | longStackTraces: true 6 | }); 7 | 8 | export const defaultTimeout = 5000; 9 | -------------------------------------------------------------------------------- /test/util/socket-io.js: -------------------------------------------------------------------------------- 1 | let serverIo; 2 | import clientIo from 'socket.io-client'; 3 | let clientSockets = []; 4 | 5 | let client = (function( ns ){ 6 | let socket = clientIo('http://localhost:54321/' + ns, { 7 | // unused sockets shouldn't try to reconnect, potentially interfering with other tests 8 | reconnection: false 9 | }); 10 | 11 | clientSockets.push( socket ); 12 | 13 | return socket; 14 | }); 15 | 16 | let server = (function( ns ){ 17 | return serverIo.of('/' + ns); 18 | }); 19 | 20 | let stop = function(){ 21 | clientSockets.forEach( socket => socket.close() ); 22 | 23 | clientSockets = []; 24 | 25 | serverIo.close(); 26 | }; 27 | 28 | let start = function(){ 29 | serverIo = require('socket.io')(54321); 30 | 31 | return serverIo; 32 | }; 33 | 34 | export { client, server, start, stop }; 35 | -------------------------------------------------------------------------------- /test/util/table.js: -------------------------------------------------------------------------------- 1 | import rdb from 'rethinkdb'; 2 | 3 | const DB_NAME = 'factoid_test'; 4 | 5 | class TableUtil { 6 | 7 | constructor( name ){ 8 | this.name = name; 9 | } 10 | 11 | get rethink(){ 12 | return rdb; 13 | } 14 | 15 | connect( done ){ 16 | if( this.conn ){ 17 | done(); 18 | 19 | return; 20 | } 21 | 22 | rdb.connect({ host: 'localhost', port: 28015 }, ( err, connection ) => { 23 | if( err ){ throw err; } 24 | 25 | this.conn = connection; 26 | 27 | done(); 28 | }); 29 | } 30 | 31 | get table(){ 32 | return rdb.db( DB_NAME ).table( this.name ); 33 | } 34 | 35 | clean( done ){ 36 | this.connect( () => { 37 | rdb.dbDrop( DB_NAME ).run( this.conn, ( err, res ) => { 38 | done(); 39 | } ).catch( () => {} ); 40 | } ); 41 | } 42 | 43 | drop( done ){ 44 | rdb.dbDrop( DB_NAME ).run( this.conn, ( err, res ) => { 45 | if( err ){ throw err; } 46 | 47 | this.conn.close(( err ) => { 48 | if( err ){ throw err; } 49 | 50 | done(); 51 | }); 52 | } ); 53 | } 54 | 55 | create( done ){ 56 | let createDb = ( next ) => { 57 | rdb.dbCreate( DB_NAME ).run( this.conn, ( err, res ) => { 58 | if( err ){ throw err; } 59 | 60 | next(); 61 | } ); 62 | }; 63 | 64 | let checkDbExists = fn => { 65 | rdb.db( DB_NAME ).tableList().run( this.conn, ( err, res ) => { 66 | if( err ){ 67 | fn( false ); 68 | } else { 69 | fn( true ); 70 | } 71 | } ); 72 | }; 73 | 74 | let createTable = next => { 75 | rdb.db( DB_NAME ).tableCreate( this.name ).run( this.conn, ( err, res ) => { 76 | if( err ){ throw err; } 77 | 78 | next(); 79 | } ); 80 | }; 81 | 82 | this.connect(() => { 83 | checkDbExists( ( exists ) => { 84 | if( exists ){ 85 | createTable( done ); 86 | } else { 87 | createDb( () => createTable( done ) ); 88 | } 89 | } ); 90 | }); 91 | } 92 | 93 | deleteEntry( id, done ){ 94 | rdb.db( DB_NAME ).table( this.name ).get( id ).delete().run( this.conn, ( err, res ) => { 95 | if( err ){ throw err; } 96 | 97 | done(); 98 | } ); 99 | } 100 | 101 | 102 | } 103 | 104 | export default TableUtil; 105 | -------------------------------------------------------------------------------- /test/util/when.js: -------------------------------------------------------------------------------- 1 | let when = ( emitter, evt ) => new Promise( resolve => emitter.on(evt, resolve) ); 2 | 3 | let whenN = ( emitter, evt, n = 1 ) => new Promise( resolve => { 4 | let i = 0; 5 | 6 | emitter.on( evt, () => { 7 | i++; 8 | 9 | if( i === n ){ 10 | resolve(); 11 | } else if( i > n ){ 12 | console.error(`Expected ${evt} event ${n}x but got ${i}x`); 13 | } 14 | } ); 15 | } ); 16 | 17 | let delay = duration => new Promise( resolve => setTimeout( resolve, duration ) ); 18 | 19 | let whenAllN = ( emitters, evt, n = 1 ) => Promise.all( emitters.map( s => whenN(s, evt, n) ) ); 20 | 21 | export { 22 | whenN as when, 23 | whenAllN as whenAll, 24 | delay 25 | }; 26 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const { env } = require('process'); 3 | const isProd = env.NODE_ENV === 'production'; 4 | const isProfile = env.PROFILE == 'true'; 5 | const isNonNil = x => x != null; 6 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; 7 | const path = require('path'); 8 | 9 | const envVars = require('./src/client-env-vars.json'); 10 | 11 | // dependencies that we need to babelify ourselves 12 | const unbabelifiedDependencies = [ 13 | 'p-cancelable' 14 | ]; 15 | 16 | let conf = { 17 | entry: { 18 | bundle: './src/client/index.js', 19 | polyfills: './src/client/polyfills.js' 20 | }, 21 | 22 | output: { 23 | filename: './build/[name].js' 24 | }, 25 | 26 | devtool: 'inline-source-map', 27 | 28 | module: { 29 | rules: [ 30 | { 31 | loader: 'babel-loader', 32 | test: /\.js$/, 33 | include: [ 34 | path.resolve(__dirname, 'src'), 35 | ].concat( unbabelifiedDependencies.map( pkg => path.resolve(__dirname, 'node_modules', pkg) ) ), 36 | options: { 37 | cacheDirectory: true 38 | } 39 | } 40 | ] 41 | }, 42 | 43 | plugins: [ 44 | isProfile ? new BundleAnalyzerPlugin() : null, 45 | 46 | new webpack.DefinePlugin({ 47 | 'process.env': (() => { 48 | const obj = {}; 49 | 50 | envVars.forEach(key => { 51 | obj[key] = JSON.stringify(process.env[key]); 52 | }); 53 | 54 | return obj; 55 | })() 56 | }), 57 | 58 | new webpack.optimize.CommonsChunkPlugin({ 59 | name: 'deps', 60 | filename: './build/deps.js', 61 | minChunks( module ){ 62 | let context = module.context || ''; 63 | 64 | return context.indexOf('node_modules') >= 0 && !module.chunks.some(chunk => chunk.name === 'polyfills'); 65 | } 66 | }), 67 | 68 | new webpack.optimize.CommonsChunkPlugin({ 69 | name: 'webpackjsonp', 70 | chunks: ['deps'], 71 | minChunks: function(){ 72 | return false; 73 | } 74 | }), 75 | 76 | isProd ? new webpack.optimize.UglifyJsPlugin() : null 77 | ].filter( isNonNil ) 78 | }; 79 | 80 | module.exports = conf; 81 | --------------------------------------------------------------------------------