<commit_before>define("p3/widget/PathwayMapHeatmapContainer", [
	"dojo/_base/declare", "dojo/_base/lang",
	"dojo/on", "dojo/topic", "dojo/dom-construct", "dojo/dom", "dojo/query", "dojo/when", "dojo/request",
	"dijit/layout/ContentPane", "dijit/layout/BorderContainer", "dijit/TooltipDialog", "dijit/Dialog", "dijit/popup",
	"dijit/TitlePane", "dijit/registry", "dijit/form/Form", "dijit/form/RadioButton", "dijit/form/Select", "dijit/form/Button",
	"./ContainerActionBar", "./HeatmapContainer", "./SelectionToGroup", "../util/PathJoin", "FileSaver"

], function(declare, lang,
			on, Topic, domConstruct, dom, Query, when, request,
			ContentPane, BorderContainer, TooltipDialog, Dialog, popup,
			TitlePane, registry, Form, RadioButton, Select, Button,
			ContainerActionBar, HeatmapContainer, SelectionToGroup, PathJoin, saveAs){

	return declare([BorderContainer, HeatmapContainer], {
		gutters: false,
		state: null,
		visible: false,
		pmState: null,
		containerActions: [
			[
				"Flip Axis",
				"fa icon-rotate-left fa-2x",
				{label: "Flip Axis", multiple: false, validTypes: ["*"]},
				function(){
					// flip internal flag
					if(this.pmState.heatmapAxis === ""){
						this.pmState.heatmapAxis = "Transposed";
					}else{
						this.pmState.heatmapAxis = "";
					}

					Topic.publish("PathwayMap", "refreshHeatmap");
				},
				true
			]
		],
		constructor: function(){
			this.dialog = new Dialog({});

			var self = this;
			// subscribe
			Topic.subscribe("PathwayMap", lang.hitch(self, function(){
				// console.log("PathwayMapHeatmapContainer:", arguments);
				var key = arguments[0], value = arguments[1];

				switch(key){
					case "updatePmState":
						self.pmState = value;
						break;
					case "refreshHeatmap":
						Topic.publish("PathwayMap", "requestHeatmapData", self.pmState);
						break;
					case "updateHeatmapData":
						self.currentData = value;
						if(typeof(self.flashDom.refreshData) == "function"){
							self.flashDom.refreshData();
							// Topic.publish("PathwayMap", "hideLoadingMask");
						}
						break;
					default:
						break;
				}
			}));
		},
		_setVisibleAttr: function(visible){
			this.visible = visible;

			if(this.visible && !this._firstView){
				this.onFirstView();
				this.initializeFlash('PathwayMapHeatMap');
			}
		},
		onFirstView: function(){
			if(this._firstView){
				return;
			}

			// action buttons for heatmap viewer
			this.containerActionBar = new ContainerActionBar({
				baseClass: "BrowserHeader",
				region: "top"
			});
			this.containerActions.forEach(function(a){
				this.containerActionBar.addAction(a[0], a[1], a[2], lang.hitch(this, a[3]), a[4]);
			}, this);
			this.addChild(this.containerActionBar);

			this.addChild(new ContentPane({
				region: "center",
				content: "<div id='flashTarget'></div>",
				style: "padding:0"
			}));

			this.inherited(arguments);
			this._firstView = true;
		},
		flashReady: function(){
			if(typeof(this.flashDom.refreshData) == "function"){
				Topic.publish("PathwayMap", "refreshHeatmap");
			}
		},
		flashCellClicked: function(flashObjectID, colID, rowID){
			//console.log("flashCellClicked is called ", colID, rowID);
			var isTransposed = (this.pmState.heatmapAxis === 'Transposed');
			var originalAxis = this._getOriginalAxis(isTransposed, colID, rowID);

			var ecNumber = originalAxis.columnIds;
			var genomeId = originalAxis.rowIds;

			var query = "?and(eq(ec_number," + ecNumber + "),eq(genome_id," + genomeId + "),eq(annotation,PATRIC))";

			Topic.publish("PathwayMap", "showLoadingMask");
			request.get(PathJoin(window.App.dataServiceURL, "pathway", query), {
				handleAs: 'json',
				headers: {
					'Accept': "application/json",
					'X-Requested-With': null,
					'Authorization': (window.App.authorizationToken || "")
				}
			}).then(lang.hitch(this, function(features){
				Topic.publish("PathwayMap", "hideLoadingMask");

				this.dialog.set('content', this._buildPanelCellClicked(isTransposed, ecNumber, genomeId, features));
				var actionBar = this._buildPanelButtons(colID, rowID, ecNumber, genomeId, features);
				domConstruct.place(actionBar, this.dialog.containerNode, "last");

				this.dialog.show();
			}));

		},
		flashCellsSelected: function(flashObjectID, colIDs, rowIDs){
			//console.log("flashCellsSelected is called", colIDs, rowIDs);
			if(rowIDs.length == 0) return;
			var isTransposed = (this.pmState.heatmapAxis === 'Transposed');
			var originalAxis = this._getOriginalAxis(isTransposed, colIDs, rowIDs);

			var ecNumbers = originalAxis.columnIds;
			var genomeIds = originalAxis.rowIds;<commit_msg>add to release package<commit_after>define("p3/widget/PathwayMapHeatmapContainer", [
	"dojo/_base/declare", "dojo/_base/lang",
	"dojo/on", "dojo/topic", "dojo/dom-construct", "dojo/dom", "dojo/query", "dojo/when", "dojo/request",
	"dijit/layout/ContentPane", "dijit/layout/BorderContainer", "dijit/TooltipDialog", "dijit/Dialog", "dijit/popup",
	"dijit/TitlePane", "dijit/registry", "dijit/form/Form", "dijit/form/RadioButton", "dijit/form/Select", "dijit/form/Button",
	"./ContainerActionBar", "./HeatmapContainer", "./SelectionToGroup", "../util/PathJoin", "FileSaver"

], function(declare, lang,
			on, Topic, domConstruct, dom, Query, when, request,
			ContentPane, BorderContainer, TooltipDialog, Dialog, popup,
			TitlePane, registry, Form, RadioButton, Select, Button,
			ContainerActionBar, HeatmapContainer, SelectionToGroup, PathJoin, saveAs){

	return declare([BorderContainer, HeatmapContainer], {
		gutters: false,
		state: null,
		visible: false,
		pmState: null,
		containerActions: [
			[
				"Flip Axis",
				"fa icon-rotate-left fa-2x",
				{label: "Flip Axis", multiple: false, validTypes: ["*"]},
				function(){
					// flip internal flag
					if(this.pmState.heatmapAxis === ""){
						this.pmState.heatmapAxis = "Transposed";
					}else{
						this.pmState.heatmapAxis = "";
					}

					Topic.publish("PathwayMap", "refreshHeatmap");
				},
				true
			]
		],
		constructor: function(){
			this.dialog = new Dialog({});

			var self = this;
			// subscribe
			Topic.subscribe("PathwayMap", lang.hitch(self, function(){
				// console.log("PathwayMapHeatmapContainer:", arguments);
				var key = arguments[0], value = arguments[1];

				switch(key){
					case "updatePmState":
						self.pmState = value;
						break;
					case "refreshHeatmap":
						Topic.publish("PathwayMap", "requestHeatmapData", self.pmState);
						break;
					case "updateHeatmapData":
						self.currentData = value;
						if(typeof(self.flashDom.refreshData) == "function"){
							self.flashDom.refreshData();
							// Topic.publish("PathwayMap", "hideLoadingMask");
						}
						break;
					default:
						break;
				}
			}));
		},
		_setVisibleAttr: function(visible){
			this.visible = visible;

			if(this.visible && !this._firstView){
				this.onFirstView();
				this.initializeFlash('PathwayMapHeatMap');
			}
		},
		onFirstView: function(){
			if(this._firstView){
				return;
			}

			// action buttons for heatmap viewer
			this.containerActionBar = new ContainerActionBar({
				baseClass: "BrowserHeader",
				region: "top"
			});
			this.containerActions.forEach(function(a){
				this.containerActionBar.addAction(a[0], a[1], a[2], lang.hitch(this, a[3]), a[4]);
			}, this);
			this.addChild(this.containerActionBar);

			this.addChild(new ContentPane({
				region: "center",
				content: "<div id='flashTarget'></div>",
				style: "padding:0"
			}));

			this.inherited(arguments);
			this._firstView = true;
		},
		flashReady: function(){
			if(typeof(this.flashDom.refreshData) == "function"){
				Topic.publish("PathwayMap", "refreshHeatmap");
			}
		},
		flashCellClicked: function(flashObjectID, colID, rowID){
			//console.log("flashCellClicked is called ", colID, rowID);
			var isTransposed = (this.pmState.heatmapAxis === 'Transposed');
			var originalAxis = this._getOriginalAxis(isTransposed, colID, rowID);

			var ecNumber = originalAxis.columnIds;
			var genomeId = originalAxis.rowIds;

			var query = "?and(eq(ec_number," + ecNumber + "),eq(genome_id," + genomeId + "),eq(annotation,PATRIC))&limit(25000,0)";

			Topic.publish("PathwayMap", "showLoadingMask");
			request.get(PathJoin(window.App.dataServiceURL, "pathway", query), {
				handleAs: 'json',
				headers: {
					'Accept': "application/json",
					'X-Requested-With': null,
					'Authorization': (window.App.authorizationToken || "")
				}
			}).then(lang.hitch(this, function(response){
				Topic.publish("PathwayMap", "hideLoadingMask");

				// dedupe features
				var featureSet = {};
				response.forEach(function(d){
					if(!featureSet.hasOwnProperty(d.feature_id)){
						featureSet[d.feature_id] = true;
					}
				});
				var features = Object.keys(featureSet);

				this.dialog.set('content', this._buildPanelCellClicked(isTransposed, ecNumber, genomeId, features));
				var actionBar = this._buildPanelButtons(colID, rowID, ecNumber, genomeId, features);
				domConstruct.place(actionBar, this.dialog.containerNode, "last");

				this.dialog.show();
			}));

		},
		flashCellsSelected: function(flashObjectID, colIDs, rowIDs){
			//console.log("flashCellsSelected is called", colIDs, rowIDs);
			if(rowIDs.length == 0) return;
			var isTransposed = (this.pmState.heatmapAxis === 'Transposed');
			var originalAxis = this._getOriginalAxis(isTransposed, colIDs, rowIDs);

			var ecNumbers = originalAxis.columnIds;
			var genomeIds = originalAxis.rowIds;
{'fraction_non_alphanumeric': 0.15887949260042283, 'fraction_numerical': 0.002959830866807611, 'mean_word_length': 3.9952481520591343, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3399217', 'n_tokens_mistral': 3790, 'n_tokens_neox': 3054, 'n_words': 557}