From aa9a2fe60be967d206dbd8edbf838648d5780075 Mon Sep 17 00:00:00 2001 From: Salih Altun Date: Tue, 25 May 2021 11:08:49 +0300 Subject: [PATCH] SBGN Brick: Translation #671 --- app/js/backbone-views.js | 50 ++++++++++++++++++++++++++---------- index.html | 55 ++++++++++++++++++++++++++++++++++++++++ package-lock.json | 2 +- 3 files changed, 92 insertions(+), 15 deletions(-) diff --git a/app/js/backbone-views.js b/app/js/backbone-views.js index 9a8382a21..b72115956 100644 --- a/app/js/backbone-views.js +++ b/app/js/backbone-views.js @@ -3450,6 +3450,13 @@ var ReactionTemplateView = Backbone.View.extend({ const params = self.getTranscriptionParameters(); self.chiseInstance.createTranscription(params.label, params.orientation); } + else if (brickType === "translation") { + const params = self.getTranslationParameters(); + self.chiseInstance.createTranslation(params.regulatorLabel, params.outputLabel, params.orientation); + } + else { + console.error("SBGN Bricks Modal - updatePreview() - brick type not found"); + } const padding = 5; self.cy.fit(self.cy.elements(), padding); },500); @@ -3870,6 +3877,17 @@ var ReactionTemplateView = Backbone.View.extend({ orientation: orientation } }, + getTranslationParameters: function() { + const regulatorLabel = $("#translation-regulator-name").val(); + const outputLabel = $("#translation-output-name").val(); + const orientation = $("#metabolic-reaction-orientation-select").val(); + + return { + regulatorLabel: regulatorLabel, + outputLabel: outputLabel, + orientation: orientation + } + }, enableImageButtons: function(jQueryElements) { jQueryElements.removeClass("image-button-disabled-appearance") .addClass("image-button-enabled-appearance"); @@ -4034,6 +4052,14 @@ var ReactionTemplateView = Backbone.View.extend({ self.updatePreview(); }); + $(document).on("input", "#translation-regulator-name", function() { + self.updatePreview(); + }); + + $(document).on("input", "#translation-output-name", function() { + self.updatePreview(); + }); + $(document).on("change", "#conversion-reaction-selector", function() { const conversionType = $(this).val(); @@ -4237,6 +4263,10 @@ var ReactionTemplateView = Backbone.View.extend({ const params = self.getTranscriptionParameters(); chiseInstance.createTranscription(params.label, params.orientation); } + else if (templateType === "translation") { + const params = self.getTranslationParameters(); + chiseInstance.createTranslation(params.regulatorLabel, params.outputLabel, params.orientation); + } else { console.error("SBGN Bricks - ReactionTemplateView - Create: Reaction type doesn't exist.") } @@ -4285,57 +4315,49 @@ var ReactionTemplateView = Backbone.View.extend({ "input-side-html": $('#reaction-template-left-td').html(), "output-side-html": $("#reaction-template-right-td").html(), "top-input-row": $("#reaction-top-input-row").html(), - "input-types": ["Simple Chemical"], - "output-types": ["Simple Chemical"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/BKO:0000585/"] }, "conversion": { "input-side-html": $('#conversion-template-left-td').html(), "output-side-html": $("#conversion-template-right-td").html(), "top-input-row": $("#conversion-top-input-row").html(), - "input-types": ["Macromolecule"], - "output-types": ["Macromolecule"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/BKO:0000570/"] }, "multimerization": { "input-side-html": $('#multimerization-template-left-td').html(), "output-side-html": $("#multimerization-template-right-td").html(), "top-input-row": $("#multimerization-top-input-row").html(), - "input-types": ["Macromolecule"], - "output-types": ["Macromolecule"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/BKO:0000221/"] }, "association": { "input-side-html": $('#association-template-left-td').html(), "output-side-html": $("#association-template-right-td").html(), "top-input-row": $("#association-top-input-row").html(), - "input-types": ["Macromolecule"], - "output-types": ["Macromolecule"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/SBO:0000526/"] }, "dissociation": { "input-side-html": $('#dissociation-template-left-td').html(), "output-side-html": $("#dissociation-template-right-td").html(), "top-input-row": $("#dissociation-top-input-row").html(), - "input-types": ["Macromolecule"], - "output-types": ["Macromolecule"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/BKO:0000166/"] }, "degradation": { "input-side-html": $('#degradation-template-left-td').html(), "output-side-html": $("#degradation-template-right-td").html(), "top-input-row": $("#degradation-top-input-row").html(), - "input-types": ["Macromolecule"], - "output-types": ["Source and Sink"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/SBO:0000179/"] }, "transcription": { "input-side-html": $('#transcription-template-left-td').html(), "output-side-html": $("#transcription-template-right-td").html(), "top-input-row": $("#transcription-top-input-row").html(), - "input-types": ["Source and Sink"], - "output-types": ["Nucleic Acid Feature"], "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/SBO:0000183/"] + }, + "translation": { + "input-side-html": $('#translation-template-left-td').html(), + "output-side-html": $("#translation-template-right-td").html(), + "top-input-row": $("#translation-top-input-row").html(), + "help-link": ["http://sbgnbricks.org/BKO/full/entry/all/BKO:0000481/"] } } return this; diff --git a/index.html b/index.html index 828a640ec..ba93a044c 100644 --- a/index.html +++ b/index.html @@ -2394,6 +2394,7 @@ + @@ -2865,6 +2866,60 @@ + + +
+ + + + + +
+ + + + +
+
Input
+ + + + + +
+ + +
+
+ + + + + + +
+
Output
+ + + + + +
+ + +
+
+ + diff --git a/package-lock.json b/package-lock.json index 60184cf9e..0255dc215 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2358,7 +2358,7 @@ "dev": true }, "chise": { - "version": "github:iVis-at-Bilkent/chise.js#070ca71fccd9c97c068689130b474e9995b517a5", + "version": "github:iVis-at-Bilkent/chise.js#2fca29586af59c791e33f6282fa8c00c710255c5", "from": "github:iVis-at-Bilkent/chise.js#unstable", "requires": { "lodash.isequal": "^4.5.0"