1 var ConfigAdaptor; if( !ConfigAdaptor ) ConfigAdaptor = {}; 2 3 /** 4 * Configuration adaptor for JBrowse JSON version 0 5 * <code>trackInfo.js</code> files. 6 * @class 7 * @extends ConfigAdaptor.JB_json_v1 8 */ 9 ConfigAdaptor.JB_json_v0 = function() { 10 }; 11 ConfigAdaptor.JB_json_v0.prototype = new ConfigAdaptor.JB_json_v1(); 12 13 /** 14 * Munge the v0 configuration to conform to v1. 15 * 16 * @param {Object} o the object containing the configuration, which it 17 * modifies in-place 18 * @param {Object} load_args the arguments that were passed to <code>load()</code> 19 * @returns {Object} v1-compliant configuration 20 */ 21 ConfigAdaptor.JB_json_v0.prototype.regularize_conf = function( o, load_args ) { 22 23 // transform Ye Olde Confige to conform to format version 1 24 o = { tracks: o }; 25 dojo.forEach( o.tracks, function( trackdef ) { 26 if( 'url' in trackdef ) { 27 trackdef.urlTemplate = trackdef.url; 28 //trackdef.urlTemplate = trackdef.url.replace(/\{refseq\}\/([^/]+)/, "$1/{refseq}"); 29 delete trackdef.url; 30 31 // TODO: this backendVersion thing is a stopgap until we 32 // refactor far enough to have real pluggable datasources 33 trackdef.backendVersion = 0; 34 } 35 }); 36 37 return ConfigAdaptor.JB_json_v1.prototype.regularize_conf.call( this, o, load_args ); 38 }; 39 40 /** 41 * Parse the trackInfo.js configuration text into JSON. 42 * 43 * @param {String} conf_text the text in the conf file 44 * @returns {Object} parsed JSON 45 */ 46 ConfigAdaptor.JB_json_v0.prototype.parse_conf = function( conf_text ) { 47 conf_text.replace( /^[^\{]+/, '' ); 48 var conf; 49 return eval( 'conf = ' + conf_text ); 50 }; 51 52 53