5532506f80e32d334d9898c6e7d23a054c7df5b1 kate Wed Jun 27 21:12:18 2012 -0700 Add special-casing to separate out Small RNA as a separate data type diff --git src/hg/js/encodeProject.js src/hg/js/encodeProject.js index e6141cc..c34f627 100644 --- src/hg/js/encodeProject.js +++ src/hg/js/encodeProject.js @@ -8,30 +8,41 @@ /*global $ */ var encodeProject = (function () { // Configurable variables - change with setup function below var server = "genome.ucsc.edu", assembly = "hg19", cgi = "/cgi-bin/hgEncodeApi?"; var accessionPrefix = 'wgEncodeE?'; var dataTypeLabelHash = {}, dataTypeTermHash = {}; var cellTypeTermHash = {}; var antibodyHash = {}, antibodyTargetHash = {}; + // special handling for small RNA (next gen CV will have dataType for this) + var smallRnaDataType = { + "term": "SmallRnaSeq", + "label": "Small RNA-seq", + "dataGroup": "RNA Profiling", + "description": "Small RNAs (<200 nt)" + }; + var smallRnaMatch = /rnaExtract=short/; + var smallRnaSearchType = "RnaSeq"; + var longRnaSearchType = "RnaSeq"; + // Functions return { // Configuration setup: function (settings) { // Change defaults if (settings.server) { server = settings.server; } if (settings.assembly) { assembly = settings.assembly; } }, @@ -110,56 +121,95 @@ if (dataTypeTermHash !== undefined) { return dataTypeTermHash[term]; } return undefined; }, getDataTypeByLabel: function (label) { // Return dataType object using label // Needs loader function (using getDataGroups below for now) if (dataTypeLabelHash !== undefined) { return dataTypeLabelHash[label]; } return undefined; }, + adjustExperiment: function (experiment) { + // Modify experiment as needed for display purposes + if (experiment.expVars.match(smallRnaMatch)) { + experiment.dataType = smallRnaDataType.term; + } + return experiment; + }, + + adjustMdbSearch: function (args) { + // Modify mdb search object list as needed for display purposes + // At this time, special handling of RNA to distinguish longs from shorts + var i; + for (i = 0; i < args.length; i += 1) { + if (args[i].mdbVal === smallRnaDataType.term) { + args[i].mdbVal = smallRnaSearchType; + args.push({ + "mdbVar": "rnaExtract", + "mdbVal": "shortTotal" + }); + break; + } else if (args[i].mdbVal === longRnaSearchType) { + args.push({ + "mdbVar": "rnaExtract", + "mdbVal": ["total", "longPolyA", "longNonPolyA", "polyA"] + }); + } + } + return args; + }, + getDataGroups: function (dataTypes) { // Unpack JSON list of dataTypes // Return sorted array of dataGroup objects each having a .label, // .dataTypes, // and an array of dataTypes, alphasorted, with 'Other' last // Also populates hashes for lookup by term or label (for now) var dataGroupHash = {}, dataGroups = [], otherGroup, group; + $.each(dataTypes, function (i, dataType) { group = dataType.dataGroup; if (!group) { return true; } // stash hashes for lookup by utility functions dataTypeTermHash[dataType.term] = dataType; dataTypeLabelHash[dataType.label] = dataType; if (!dataGroupHash[group]) { dataGroupHash[group] = { label: group, dataTypes: [] }; } dataGroupHash[group].dataTypes.push(dataType.label); }); + + // add Small RNA dataType (currently only distinguished by expVars), but + // should really be highlighted as separate from standard RNA-seq + dataTypeTermHash[smallRnaDataType.term] = smallRnaDataType; + dataTypeLabelHash[smallRnaDataType.label] = smallRnaDataType; + dataGroupHash[smallRnaDataType.dataGroup].dataTypes.push(smallRnaDataType.label); + + // handle catchall 'Other' group at the end $.each(dataGroupHash, function (key, item) { if (key === "Other") { otherGroup = item; } else { dataGroups.push(item); } }); dataGroups.sort(encodeProject.cmpCV); dataGroups.push(otherGroup); $.each(dataGroups, function (i, group) { if (!dataGroups[i]) { // for some reason there's __ element here (not my property) return true; } dataGroups[i].dataTypes.sort(encodeProject.cmpNoCase);