Skip to content

Commit

Permalink
handle extended modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
bhofmei committed Sep 26, 2017
1 parent 53fea85 commit 3d0f672
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 76 deletions.
14 changes: 12 additions & 2 deletions js/EncodeDecodeUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ define('ScreenShotPlugin/EncodeDecodeUtil', [
var thisB = this;
for (param in params) {
var data = params[param];
if (param === 'methylation')
output += eLabels[param] + this._encodeBoolean(data.CG) + this._encodeBoolean(data.CHG) + this._encodeBoolean(data.CHH);
if (param === 'methylation'){
var types = ['CG', 'CHG', 'CHH', '4mC', '5hmC', '6mA'];
output += eLabels[param];
array.forEach(types, function (t) {
output += thisB._encodeBoolean(data[t])
});
}
else if (param === 'smallrna') {
output += eLabels[param];
var types = ['21', '22', '23', '24', 'pi', 'Others'];
Expand Down Expand Up @@ -250,6 +255,11 @@ define('ScreenShotPlugin/EncodeDecodeUtil', [
outProp.methylation['CG'] = this._decodeBoolen(resultM[1].substring(0, 1));
outProp.methylation['CHG'] = this._decodeBoolen(resultM[1].substring(1, 2));
outProp.methylation['CHH'] = this._decodeBoolen(resultM[1].substring(2, 3));
if(resultM[1].length > 3){
outProp.methylation['4mC'] = this._decodeBoolen(resultM[1].substring(3, 4));
outProp.methylation['5hmC'] = this._decodeBoolen(resultM[1].substring(4, 5));
outProp.methylation['6mA'] = this._decodeBoolen(resultM[1].substring(5, 6));
}
}
var resultS = /s([0-9]+)/gi.exec(input);
if (resultS != null) {
Expand Down
5 changes: 4 additions & 1 deletion js/ParametersUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ define('ScreenShotPlugin/ParametersUtil', [
methylation: {
CG: true,
CHG: true,
CHH: true
CHH: true,
'4mC': true,
'5hmC': true,
'6mA': true
},
output: {
format: format,
Expand Down
68 changes: 41 additions & 27 deletions js/View/Dialog/ScreenShotDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
this.setCallback = args.setCallback || function () {};
this.cancelCallback = args.cancelCallback || function () {};
this.vTracks = this.browser.view.visibleTracks();
this.configs = args.config || {};
this.pluginConfig = args.config || {};
this.trackParameters = this._getTrackParameters();
},

Expand All @@ -88,7 +88,7 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
var jsParams = this.parameters.output;
// get the url
var url = this._getPhantomJSUrl(scParams, jsParams);
if (this.configs.debug)
if (this.pluginConfig.debug)
console.log(url);
else
window.open(url);
Expand Down Expand Up @@ -217,7 +217,7 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
}
} // end for param
//
if (thisB.configs.smrnaPlugin || thisB.configs.methylPlugin) {
if (thisB.pluginConfig.smrnaPlugin || thisB.pluginConfig.methylPlugin) {
thisB._methylation_smrna_table(obj);
}
},
Expand All @@ -229,7 +229,7 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
}, obj);
var row, row2, tdata, box, cdata;
// methylation
if (thisB.configs.methylPlugin) {
if (thisB.pluginConfig.methylPlugin) {
var cdata = thisB.browser.plugins.MethylationPlugin.config;
row = dom.create('tr', {
id: 'screenshot-dialog-row-methyl'
Expand All @@ -243,33 +243,28 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
'id': 'screenshot-dialog-row-methyl-boxes'
}, table);
// methylation types - animal vs plants
var mTypes = (cdata.isAnimal ? {
/*var mTypes = (cdata.isAnimal ? {
CG: true,
CH: true
} : thisB.parameters.methylation);
var m;
for (m in mTypes) {
var tdata = dom.create('td', {
align: 'right'
}, row2);
var box = new dijitCheckBox({
id: 'screenshot-dialog-methyl-' + m,
//'class':m+'-checkbox',
style: 'background-image:url(' + cdata.baseUrl.slice(1) + '/img/checkmark-' + m + '.png' + ');',
'_prop': m,
checked: (m === 'CH' ? (thisB.parameters.methylation.CHG && thisB.parameters.methylation.CHH) : thisB.parameters.methylation[m])
});
box.onClick = lang.hitch(thisB, '_setMethylation', box);
dom.create('span', {
innerHTML: m,
className: 'screenshot-dialog-opt-span'
}, tdata);
tdata.appendChild(box.domNode);
} : thisB.parameters.methylation);*/
var mTypes1 = (cdata.isAnimal ? ['CG', 'CH'] : ['CG', 'CHG', 'CHH']);
array.forEach(mTypes1, function (m) {
thisB._createMethylCheckbox(row2, m, cdata, '_setMethylation', thisB);
}); // end mtypes1
// extended modifications
if (cdata.extendedMods) {
row2 = dom.create('tr', {
'id': 'screenshot-dialog-row-methyl-boxes-2'
}, table);
var mTypes2 = ['4mC', '5hmC', '6mA'];
array.forEach(mTypes2, function (m) {
thisB._createMethylCheckbox(row2, m, cdata, '_setMethylation', thisB);
}); // end mtypes2
}
} // end methylation

// small rna
if (thisB.configs.smrnaPlugin) {
if (thisB.pluginConfig.smrnaPlugin) {
cdata = thisB.browser.plugins.SmallRNAPlugin.config;
row = dom.create('tr', {
id: 'screenshot-dialog-row-smrna'
Expand Down Expand Up @@ -496,6 +491,25 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
}
},

_createMethylCheckbox: function (tableRow, param, data, callbackStr, objScope) {
var tdata = dom.create('td', {
align: 'right'
}, tableRow);
var box = new dijitCheckBox({
id: 'screenshot-dialog-methyl-' + param,
//'class':m+'-checkbox',
style: 'background-image:url(' + data.baseUrl.slice(1) + '/img/checkmark-' + param.toLowerCase() + '.png' + ');',
'_prop': param,
checked: (param === 'CH' ? (objScope.parameters.methylation.CHG && objScope.parameters.methylation.CHH) : objScope.parameters.methylation[param])
});
box.onClick = lang.hitch(objScope, callbackStr, box);
dom.create('span', {
innerHTML: param,
className: 'screenshot-dialog-opt-span'
}, tdata);
tdata.appendChild(box.domNode);
},

_createSpinner: function (inTable, data, param, callbackStr, objScope) {
var row = dom.create('tr', {
'id': 'screenshot-dialog-row-' + param
Expand Down Expand Up @@ -799,7 +813,7 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
return
} else {
if (this.trackParameters[tLabel].hasOwnProperty(prop)) {
if(input.type === 'checkbox')
if (input.type === 'checkbox')
this.trackParameters[tLabel][prop].value = input.checked;
else
this.trackParameters[tLabel][prop].value = input.value;
Expand All @@ -812,7 +826,7 @@ define("ScreenShotPlugin/View/Dialog/ScreenShotDialog", [
},

_getTrackParameters: function () {
return Parameters.getTrackParameters(this.vTracks, this.configs);
return Parameters.getTrackParameters(this.vTracks, this.pluginConfig);
},

_getPhantomJSUrl: function (scParams, jsParams) {
Expand Down
55 changes: 9 additions & 46 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ define([
var baseUrl = this._defaultConfig().baseUrl;
var browser = this.browser;
this.isScreenshot = false;
this.config.version = '1.6.9';
this.config.version = '1.6.10';
console.log('ScreenShotPlugin starting - v', this.config.version);

// PhantomJS Username
Expand Down Expand Up @@ -1968,6 +1968,14 @@ define([
},

_applyMethSmRNAConfig: function (mParams, sParams) {
// filter mParams by extended modifications if necessary
if(!this.browser.plugins.MethylationPlugin.config.extendedMods){
var rmTypes = ['4mC', '5hmC', '6mA'];
array.forEach(rmTypes, function(t){
if(mParams.hasOwnProperty(t))
delete mParams[t]
});
}
var thisB = this;
var s, m, t;
var mmix = {};
Expand All @@ -1993,57 +2001,12 @@ define([

},

_applyMethylationConfig: function (params) {
var thisB = this;
// check for methylation plugin
if (thisB.browser.plugins.hasOwnProperty(thisB.config.methylPlugin)) {
var m, t;
var tracks = lang.clone(thisB.browser.trackConfigsByName);
//console.log('methylation tracks');
for (m in params) {
if (params[m] === false) {
var mix = {};
mix['show' + m] = false;
for (t in tracks) {
if (thisB._testMethylation(tracks[t].type)) {
lang.mixin(thisB.browser.trackConfigsByName[t], mix);
}
}
// TODO: add command to disable toolbar buttons if necessary
} // end if params[m] === false
} // end for m in params
} // end if MethylationPlugin
},

_testMethylation: function (trackType) {
if (trackType === undefined || trackType === null)
return false;
return ((/(Methyl.*Plot$)/.test(trackType)));
},

_applySmallRNAConfig: function (params) {

var thisB = this;
// check for small rna plugin
//if(thisB.browser.plugins.hasOwnProperty(thisB.config.smrnaPlugin)){
var m, t;
var tracks = lang.clone(thisB.browser.trackConfigsByName);
for (m in params) {
if (params[m] === true) {
var mix = {};
mix['hide' + m] = true;
for (t in tracks) {
if (thisB._testSmallRNA(tracks[t].type)) {
lang.mixin(thisB.browser.trackConfigsByName[t], mix);
}

}
// TODO: add command to disable toolbar buttons if necessary
} // end if params[m] === true
} // end for m in params
//} // end if SmallRNAPlugin
},

_testSmallRNA: function (trackType) {
if (trackType === undefined || trackType === null)
return false;
Expand Down

0 comments on commit 3d0f672

Please sign in to comment.