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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 2× 1× 1× 2× 2× 2× 2× 2× 15× 2× 1× 1× 3× 24× 3× 1× 1× 2× 2× 10× 1× 3× 3× 2× 2× 1× | /*jslint node: true */ /*jshint laxbreak: true */ "use strict"; var _ = require('underscore'); var Config = require('./config.json'); var visualizationTypes = { basic: 'basic', variant: 'variant' }; var uniprotSource = 'uniprot'; var uniprotSources = [ { url: 'https://www.ebi.ac.uk/proteins/api/features/', source: uniprotSource, category: 'FEATURES' }, { url: 'https://www.ebi.ac.uk/proteins/api/proteomics/', source: uniprotSource, category: 'PROTEOMICS' }, { url: 'https://www.ebi.ac.uk/proteins/api/variation/', source: uniprotSource, category: 'VARIATION' }, { url: 'https://www.ebi.ac.uk/proteins/api/antigen/', source: uniprotSource, category: 'ANTIGEN' } ]; var allSources = uniprotSources.slice(0); var externalSource; var allCategories = Config.categories; var allTrackNames = Config.trackNames; var downloadFormats = [{text: 'JSON', type: 'json', all: true}, {text: 'XML', type: 'xml', all: false}, {text: 'GFF', type: 'gff', all: false}]; var consequenceTypes = []; var Constants = function() { return { getBlastURL: function() { return 'http://www.uniprot.org/blast/?about='; }, getNoBlastTypes: function() { return ['helix', 'strand', 'turn', 'disulfid', 'crosslnk', 'variant']; }, getVisualizationTypes: function() { return visualizationTypes; }, getDownloadFormats: function() { return downloadFormats; }, getDataSources: function() { return allSources; }, getUniProtDataSources: function() { return uniprotSources; }, getExternalDataSource: function() { return externalSource; }, getUniProtSource: function() { return uniprotSource; }, addSource: function(source) { allSources.push(source); externalSource = source; }, addConsequenceType: function(consequence) { consequenceTypes.push(consequence); }, getConsequenceTypes: function() { return _.uniq(consequenceTypes); }, clearDataSources: function() { allSources = []; }, getCategoryNamesInOrder: function() { return allCategories; }, setCategoryNamesInOrder: function(categories) { allCategories = categories; }, setOrderForCategoryNames: function(categoryNames) { var orderedCategories = []; _.each(categoryNames, function(name) { var position = 0; var category = _.find(allCategories, function(cat, index) { position = index; return cat.name.toUpperCase() === name.toUpperCase(); }); if (category) { orderedCategories.push(category); allCategories.splice(position, 1); } }); allCategories = orderedCategories.concat(allCategories); }, convertNameToLabel: function(name) { var label = name.replace(/_/g, ' '); label = label.charAt(0).toUpperCase() + label.slice(1).toLowerCase(); return label; }, getCategoryInfo: function(categoryName) { var exist = _.find(allCategories, function(cat) { return cat.name === categoryName; }); return exist ? exist : {name: categoryName, label: Constants.convertNameToLabel(categoryName), visualizationType: Constants.getVisualizationTypes().basic}; }, addCategories: function(categories) { var index = 0; _.each(categories, function (newCat) { var exist = _.find(allCategories, function(cat) { return cat.name === newCat.name; }); if (exist) { exist.label = newCat.label; exist.visualizationType = newCat.visualizationType; } else { allCategories.splice(index, 0, newCat); index++; } }); }, getTrackNames: function() { return allTrackNames; }, setTrackNames: function(trackNames) { allTrackNames = trackNames; }, addTrackTypes: function(tracksToAdd) { _.each(tracksToAdd, function(elem, key) { key = key.toLowerCase(); allTrackNames[key] = elem; }); }, getTrackInfo: function(trackName) { var name = trackName.toLowerCase(); return this.getTrackNames()[name] ? this.getTrackNames()[name] : {label: Constants.convertNameToLabel(name), tooltip:''}; } }; }(); module.exports = Constants; |