From 7d3a95ef9f643ecf1e9b9b86eff1b56a1cd49006 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 6 Dec 2018 00:23:50 -0500 Subject: [PATCH 01/16] Removed redundancy from interactions --- .../interaction-arrows/inhibitorArrow.js | 6 +- font/sbolv/interaction-arrows/productArrow.js | 2 +- .../interaction-arrows/simulatorArrow.js | 2 +- lib/design.js | 3 +- lib/displayList.js | 71 +++++++++++++------ lib/interaction.js | 49 +++++++++---- lib/interactions/inhibition.js | 13 ++-- lib/interactions/production.js | 15 ++-- lib/interactions/stimulation.js | 15 ++-- 9 files changed, 117 insertions(+), 59 deletions(-) diff --git a/font/sbolv/interaction-arrows/inhibitorArrow.js b/font/sbolv/interaction-arrows/inhibitorArrow.js index 29399a2..60e1b16 100644 --- a/font/sbolv/interaction-arrows/inhibitorArrow.js +++ b/font/sbolv/interaction-arrows/inhibitorArrow.js @@ -7,9 +7,9 @@ function createGeometry(boxSize) { return { top: Vec2(boxSize.x/2,0), - bottomLeft: Vec2(boxSize.x/4,(2*boxSize.y)/4), - bottomRight: Vec2((boxSize.x * 3 )/4, (2*boxSize.y)/4), - middleBottom: Vec2(boxSize.x/2, (2*boxSize.y)/4) + bottomLeft: Vec2(boxSize.x/4,boxSize.y * 0.6), + bottomRight: Vec2((boxSize.x * 3 )/4, boxSize.y * 0.6), + middleBottom: Vec2(boxSize.x/2, boxSize.y * 0.6) }; } diff --git a/font/sbolv/interaction-arrows/productArrow.js b/font/sbolv/interaction-arrows/productArrow.js index 9c0b025..815455a 100644 --- a/font/sbolv/interaction-arrows/productArrow.js +++ b/font/sbolv/interaction-arrows/productArrow.js @@ -7,7 +7,7 @@ function createGeometry(boxSize) { return { top: Vec2(boxSize.x/2, boxSize.y/4), - bottom: Vec2(boxSize.x/2, boxSize.y), + bottom: Vec2(boxSize.x/2, boxSize.y * 0.8), left: Vec2(boxSize.x/3,boxSize.y/4), right: Vec2((boxSize.x * 2 )/3, boxSize.y/4), diff --git a/font/sbolv/interaction-arrows/simulatorArrow.js b/font/sbolv/interaction-arrows/simulatorArrow.js index bab51db..dbb6cdd 100644 --- a/font/sbolv/interaction-arrows/simulatorArrow.js +++ b/font/sbolv/interaction-arrows/simulatorArrow.js @@ -6,7 +6,7 @@ function createGeometry(boxSize) { return { - top: Vec2(boxSize.x/2, boxSize.y * 0.1), + top: Vec2(boxSize.x/2, boxSize.y * 0.2), bottom: Vec2(boxSize.x/2, boxSize.y * 0.8), left: Vec2(boxSize.x/3,boxSize.y * 0.8), diff --git a/lib/design.js b/lib/design.js index a37df72..a38fe3e 100755 --- a/lib/design.js +++ b/lib/design.js @@ -141,7 +141,8 @@ Design.prototype = { * otherwise it doesn't know where to render them */ let componentBoxHeight = this.geom.componentBoxHeight; - this.interactions = this.displayList.interactions.map(function(interactionObject) { + console.log(this.displayList.combinedInteractions, 'interactions') + this.interactions = this.displayList.combinedInteractions.map(function(interactionObject) { var interaction = Interaction.render(design, interactionObject, design.displayList.interactions); let interactionPosition = design.geom.interactionPosition; diff --git a/lib/displayList.js b/lib/displayList.js index 42b5f22..ba3c0f7 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -6,6 +6,7 @@ function DisplayList(displayListObject) { this.components = []; this.processes = []; this.interactions = []; + this.combinedInteractions = []; this.refs = Object.create(null); @@ -36,27 +37,10 @@ function DisplayList(displayListObject) { * Add rendering Info to participants of the interaction, right now it's just for inhibition */ if(displayListObject.interactions !== undefined) { - - - this.interactions = displayListObject.interactions.map(function(interaction) { - - //this is the set of interaction types that currently our code is able to rende - /*let AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000177", "SBO:0000179", "SBO:0000589"]; - - if (AvailableInteractions.indexOf(interaction.SBO) !== -1) { - for (let i in interaction.participants) { - - //find the segment for the circuit participating in the interaction, this way we can simply render the segment using renderSegment - for ( let j in displayList.components[0].segments ) { - - if (displayList.components[0].segments[j].name === interaction.participants[i].name ) { - interaction.participants[i].segment = displayList.components[0].segments[j]; - } - } - } - }*/ - return interaction; - }); + + this.interactions = displayListObject.interactions; + this.combinedInteractions = DisplayList.combineInteractions(displayList, displayListObject.interactions) + } @@ -194,6 +178,51 @@ DisplayList.Entity = function Entity(displayList, entity) { this.name = entity.name; } +/* +******************************************************************************************* +*/ +DisplayList.combineInteractions = function combineInteractions(displayList, interactions) { + + combinedInteractionsDict = {} + combinedInteractionsList = [] + for(interaction of interactions) { + + //this is the set of interaction types that currently our code is able to rende + AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000589"]; + + if (AvailableInteractions.indexOf(interaction.SBO) !== -1) { + + for (participant of interaction.participants) { + + if (participant.SO) { + + if (participant.segment.name in combinedInteractionsDict) { + + combinedInteractionsDict[participant.segment.name]['interactions'].push(interaction) + + } + else { + + segmentInfoDict = {} + segmentInfoDict['segment'] = participant.segment + segmentInfoDict['interactions'] = [] + segmentInfoDict['interactions'].push(interaction) + combinedInteractionsDict[participant.segment.name] = segmentInfoDict + + } + + } + + } + } + } + //get the values aa a list + for (key in combinedInteractionsDict) { + combinedInteractionsList.push(combinedInteractionsDict[key]) + } + return combinedInteractionsList +} + DisplayList.prototype = { getObjectByID: function getObjectByID(id) { diff --git a/lib/interaction.js b/lib/interaction.js index b54ee43..4e188e8 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -11,30 +11,51 @@ var Segment = require('./segment'), Matrix = require('./geom/matrix') -function renderInteraction(design, interaction, interactions) { +function renderInteraction(design, combinedInteraction, interactions) { var interactionPos = Matrix(); var segments = []; let pos = 0 - - if (interaction.SBO === "SBO:0000169") { - - Inhibition.render(design, interaction, segments, interactions); + onDNAsVerticalOffset = 0; + + if (combinedInteraction.segment.sequence.length > 1) { + combinedInteraction.segment.isCircuit = true; } + combinedInteraction.segment.isParticipant = true; + var segment = Segment.render(design, combinedInteraction.segment, interactions); + segments.push(segment) + + if (combinedInteraction.interactions.length === 1) { + nonDNAshorizontalOffset = (segment.bbox().width)/2 + } + else if (combinedInteraction.interactions.length > 1) { + numInteraction = combinedInteraction.interactions.length + nonDNAshorizontalOffset = (segment.bbox().width - (design.geom.defaultGlyphSize.x * numInteraction))/numInteraction + } + + for (interaction of combinedInteraction['interactions']) { - else if (interaction.SBO === "SBO:0000589") { + if (interaction.SBO === "SBO:0000169") { + + Inhibition.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); + nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 + } + + else if (interaction.SBO === "SBO:0000589") { - Production.render(design, interaction, segments, interactions); + Production.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); + nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 - } + } - else if (interaction.SBO === "SBO:0000170") { + else if (interaction.SBO === "SBO:0000170") { - Stimulation.render(design, interaction, segments, interactions); + Stimulation.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); + nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 - } + } - else if (interaction.SBO === "SBO:0000177") { + /*else if (interaction.SBO === "SBO:0000177") { nonCovelantBinding.render(design, interaction, segments, interactions); @@ -43,13 +64,13 @@ function renderInteraction(design, interaction, interactions) { else if (interaction.SBO === "SBO:0000179") { Degradation.render(design, interaction, segments, interactions); - } + }*/ else { console.log("Unknown interaction type") return; } - + } var group = design.surface.group(); segments.forEach(group.add.bind(group)); diff --git a/lib/interactions/inhibition.js b/lib/interactions/inhibition.js index 38d6163..57be01f 100644 --- a/lib/interactions/inhibition.js +++ b/lib/interactions/inhibition.js @@ -2,7 +2,7 @@ var Segment = require('../segment'), Helper = require('./helper') -function render(design, interaction, segments, interactions) { +function render(design, interaction, segments, interactions, nonDNAshorizontalOffset) { //make sure right type of interaction is passed to the function if (interaction.SBO !== "SBO:0000169") { @@ -22,7 +22,7 @@ function render(design, interaction, segments, interactions) { Helper.sortParticipants(interaction.participants); nonDNAsVerticalOffset = 0; - nonDNAshorizontalOffset = 0; + //nonDNAshorizontalOffset = 0; isCircuit = true; if (interaction.participants[0].type !== "engineered-region") { isCircuit = false; @@ -36,7 +36,7 @@ function render(design, interaction, segments, interactions) { interaction.participants[i].segment.isParticipant = true; //if participant is a Dna part or circuit - if (interaction.participants[i].SO) { + /* if (interaction.participants[i].SO) { if (isCircuit) { interaction.participants[i].segment.isCircuit = true; @@ -46,8 +46,10 @@ function render(design, interaction, segments, interactions) { var segment = Segment.render(design, interaction.participants[i].segment, interactions); nonDNAVerticalOffset = segment.bbox().height + 8; nonDNAshorizontalOffset = (segment.bbox().width)/2; - } + }*/ + nonDNAVerticalOffset = segments[0].bbox().height + 20 + console.log(nonDNAVerticalOffset) if (!interaction.participants[i].SO) { //need to set the role for the segment to be able to add the rendering for inhibition arrow in reder segment @@ -69,9 +71,10 @@ function render(design, interaction, segments, interactions) { //move the nonDNA part vertically segment.dy(-90); } + segments.push(segment); } - segments.push(segment); + //segments.push(segment); } } diff --git a/lib/interactions/production.js b/lib/interactions/production.js index 29700b8..4560187 100644 --- a/lib/interactions/production.js +++ b/lib/interactions/production.js @@ -2,7 +2,7 @@ var Segment = require('../segment'), Helper = require('./helper') -function render(design, interaction, segments, interactions) { +function render(design, interaction, segments, interactions, nonDNAshorizontalOffset) { //make sure right type of interaction is passed to the function if (interaction.SBO !== "SBO:0000589") { @@ -22,7 +22,7 @@ function render(design, interaction, segments, interactions) { */ Helper.sortParticipants(interaction.participants); nonDNAsVerticalOffset = 0; - nonDNAshorizontalOffset = 0; + //nonDNAshorizontalOffset = 0; isCircuit = true; if (interaction.participants[0].type !== "engineered-region") { isCircuit = false; @@ -36,7 +36,7 @@ function render(design, interaction, segments, interactions) { interaction.participants[i].segment.isParticipant = true; //if participant is a Dna part or circuit - if (interaction.participants[i].SO) { + /*if (interaction.participants[i].SO) { if (isCircuit) { interaction.participants[i].segment.isCircuit = true; } @@ -46,8 +46,9 @@ function render(design, interaction, segments, interactions) { nonDNAVerticalOffset = segment.bbox().height + 30; console.log(segment.bbox().height) nonDNAshorizontalOffset = (segment.bbox().width)/2; - } - + }*/ + + nonDNAVerticalOffset = segments[0].bbox().height + 20 if (!interaction.participants[i].SO) { interaction.participants[i].segment.role = "production_nonDNA"; @@ -60,6 +61,7 @@ function render(design, interaction, segments, interactions) { segment.dx(nonDNAshorizontalOffset - segment.bbox().width) //move the nonDNA part vertically segment.dy(-nonDNAVerticalOffset); + } else if (!isCircuit) { segment.dx(0) @@ -67,8 +69,9 @@ function render(design, interaction, segments, interactions) { segment.dy(-90); //segment.dx(nonDNAshorizontalOffset - segment.bbox().width) } + segments.push(segment); } - segments.push(segment); + // segments.push(segment); } } diff --git a/lib/interactions/stimulation.js b/lib/interactions/stimulation.js index 7f2f731..c6b8acc 100644 --- a/lib/interactions/stimulation.js +++ b/lib/interactions/stimulation.js @@ -2,7 +2,7 @@ var Segment = require('../segment'), Helper = require('./helper') -function render(design, interaction, segments, interactions) { +function render(design, interaction, segments, interactions, nonDNAshorizontalOffset) { //make sure right type of interaction is passed to the function @@ -23,7 +23,7 @@ function render(design, interaction, segments, interactions) { */ Helper.sortParticipants(interaction.participants); nonDNAsVerticalOffset = 0; - nonDNAshorizontalOffset = 0; + //nonDNAshorizontalOffset = 0; isCircuit = true; if (interaction.participants[0].type !== "engineered-region") { isCircuit = false; @@ -37,7 +37,7 @@ function render(design, interaction, segments, interactions) { interaction.participants[i].segment.isParticipant = true; //if participant is a Dna part or circuit - if (interaction.participants[i].SO) { + /* if (interaction.participants[i].SO) { if (isCircuit) { interaction.participants[i].segment.isCircuit = true; @@ -46,11 +46,11 @@ function render(design, interaction, segments, interactions) { //update participant offset design.geom.participantOffset = Helper.find_participant_offset(interaction.participants[i], interaction.displayId, "simulation"); var segment = Segment.render(design, interaction.participants[i].segment, interactions); - console.log(sgment.bbox().height) nonDNAVerticalOffset = segment.bbox().height + 30; nonDNAshorizontalOffset = (segment.bbox().width)/2; - } + }*/ + nonDNAVerticalOffset = segments[0].bbox().height + 25 if (!interaction.participants[i].SO) { //need to set the role for the segment to be able to add the rendering for inhibition arrow in reder segment @@ -62,15 +62,16 @@ function render(design, interaction, segments, interactions) { if (isCircuit ) { //segment.dx( (design.geom.participantOffset -1) * (design.geom.defaultGlyphSize.x + design.geom.glyphPadding) + design.geom.glyphPadding + design.geom.defaultGlyphSize.x/2) segment.dx(nonDNAshorizontalOffset - segment.bbox().width); - segment.dy(-nonDNAVerticalOffset - segment.bbox().height); + segment.dy(-nonDNAVerticalOffset); } else if (!isCircuit) { segment.dx(0) segment.dy(-90); //segment.dx(nonDNAshorizontalOffset - segment.bbox().width) } + segments.push(segment); } - segments.push(segment); + //segments.push(segment); } } From ae1537eb4a7f4a7a193b7e680283b240a07d1d07 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 6 Dec 2018 01:38:36 -0500 Subject: [PATCH 02/16] Add non dna interactions --- lib/displayList.js | 10 ++++- lib/getInteractionList.js | 3 +- lib/interaction.js | 83 +++++++++++++++++++++------------------ 3 files changed, 55 insertions(+), 41 deletions(-) diff --git a/lib/displayList.js b/lib/displayList.js index ba3c0f7..0199bc9 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -185,10 +185,15 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte combinedInteractionsDict = {} combinedInteractionsList = [] + nonDNAInteractions = [] for(interaction of interactions) { + if (interaction.SBO === "SBO:0000177" || interaction.SBO === "SBO:0000179") { + nonDNAInteractions.push(interaction) + } //this is the set of interaction types that currently our code is able to rende - AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000589"]; + let AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000589"]; + //let AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000177", "SBO:0000179", "SBO:0000589"]; if (AvailableInteractions.indexOf(interaction.SBO) !== -1) { @@ -220,6 +225,9 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte for (key in combinedInteractionsDict) { combinedInteractionsList.push(combinedInteractionsDict[key]) } + for (interaction of nonDNAInteractions) { + combinedInteractionsList.push(interaction) + } return combinedInteractionsList } diff --git a/lib/getInteractionList.js b/lib/getInteractionList.js index 2cf642b..a27479d 100644 --- a/lib/getInteractionList.js +++ b/lib/getInteractionList.js @@ -31,7 +31,8 @@ function getInteractionList(moduleDefinition) { let participantObj = {}; participantObj.displayId = participation.displayId; - participantObj.segment = getDisplayListSegment(participation.participant.definition) + if (participation.participant.definition) + participantObj.segment = getDisplayListSegment(participation.participant.definition) participantObj.name = participation.participant.definition.displayId; //Attaching type when participant is Non-DNA diff --git a/lib/interaction.js b/lib/interaction.js index 4e188e8..ac2f753 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -18,60 +18,65 @@ function renderInteraction(design, combinedInteraction, interactions) { let pos = 0 onDNAsVerticalOffset = 0; - if (combinedInteraction.segment.sequence.length > 1) { - combinedInteraction.segment.isCircuit = true; - } - combinedInteraction.segment.isParticipant = true; - var segment = Segment.render(design, combinedInteraction.segment, interactions); - segments.push(segment) + if (combinedInteraction.segment) { - if (combinedInteraction.interactions.length === 1) { - nonDNAshorizontalOffset = (segment.bbox().width)/2 - } - else if (combinedInteraction.interactions.length > 1) { - numInteraction = combinedInteraction.interactions.length - nonDNAshorizontalOffset = (segment.bbox().width - (design.geom.defaultGlyphSize.x * numInteraction))/numInteraction - } + if (combinedInteraction.segment.sequence.length > 1) { + combinedInteraction.segment.isCircuit = true; + } + combinedInteraction.segment.isParticipant = true; + var segment = Segment.render(design, combinedInteraction.segment, interactions); + segments.push(segment) + + if (combinedInteraction.interactions.length === 1) { + nonDNAshorizontalOffset = (segment.bbox().width)/2 + } + else if (combinedInteraction.interactions.length > 1) { + numInteraction = combinedInteraction.interactions.length + nonDNAshorizontalOffset = (segment.bbox().width - (design.geom.defaultGlyphSize.x * numInteraction))/numInteraction + } - for (interaction of combinedInteraction['interactions']) { + for (interaction of combinedInteraction['interactions']) { - if (interaction.SBO === "SBO:0000169") { + if (interaction.SBO === "SBO:0000169") { - Inhibition.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); - nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 - } + Inhibition.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); + nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 + } - else if (interaction.SBO === "SBO:0000589") { - - Production.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); - nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 + else if (interaction.SBO === "SBO:0000589") { - } + Production.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); + nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 + } - else if (interaction.SBO === "SBO:0000170") { + else if (interaction.SBO === "SBO:0000170") { - Stimulation.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); - nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 - - } - - /*else if (interaction.SBO === "SBO:0000177") { - - nonCovelantBinding.render(design, interaction, segments, interactions); + Stimulation.render(design, interaction, segments, interactions, nonDNAshorizontalOffset); + nonDNAshorizontalOffset += segments[segments.length -1].bbox().width + 50 + } + } + } + else { + //console.log(segments, "segments") + /*if (combinedInteraction.SBO === "SBO:0000177") { + //console.log(combinedInteraction) + nonCovelantBinding.render(design, combinedInteraction, segments, interactions); + //console.log("segments", segments) } - else if (interaction.SBO === "SBO:0000179") { - - Degradation.render(design, interaction, segments, interactions); - }*/ + else if (combinedInteraction.SBO === "SBO:0000179") { + // console.log("COmbinedInteraction", combinedInteraction) + Degradation.render(design, combinedInteraction, segments, interactions); + } else { + console.log("COmbinedInteraction", combinedInteraction) console.log("Unknown interaction type") return; - } - } - + }*/ + + } var group = design.surface.group(); segments.forEach(group.add.bind(group)); From 4367054297fecf7d393ec3bb18694e2974de7722 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 6 Dec 2018 02:09:00 -0500 Subject: [PATCH 03/16] resolve bug regarding non-covelant-binding --- lib/interaction.js | 4 ++-- lib/interactions/non-covelant-binding.js | 2 +- lib/segment.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/interaction.js b/lib/interaction.js index ac2f753..9fb313e 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -58,7 +58,7 @@ function renderInteraction(design, combinedInteraction, interactions) { } else { //console.log(segments, "segments") - /*if (combinedInteraction.SBO === "SBO:0000177") { + if (combinedInteraction.SBO === "SBO:0000177") { //console.log(combinedInteraction) nonCovelantBinding.render(design, combinedInteraction, segments, interactions); //console.log("segments", segments) @@ -74,7 +74,7 @@ function renderInteraction(design, combinedInteraction, interactions) { console.log("COmbinedInteraction", combinedInteraction) console.log("Unknown interaction type") return; - }*/ + } } var group = design.surface.group(); diff --git a/lib/interactions/non-covelant-binding.js b/lib/interactions/non-covelant-binding.js index b251d29..86f5628 100644 --- a/lib/interactions/non-covelant-binding.js +++ b/lib/interactions/non-covelant-binding.js @@ -36,7 +36,7 @@ function render(design, interaction, segments, interactions) { var segment = Segment.render(design, interaction.participants[i].segment, interactions); if (i == 0) { - productOffset = interaction.participants.segmentWidth; + productOffset = interaction.segmentWidth; } diff --git a/lib/segment.js b/lib/segment.js index 84263c7..6a52502 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -280,7 +280,7 @@ function renderSegment(design, segment, interactions,) { var arrowGlyph = arrowProps.glyph; arrowGlyph.transform({ matrix: Matrix.toSVGString(arrowTransform) }); group.add(arrowGlyph); - interaction.participants.segmentWidth = group.bbox().width + interaction.segmentWidth = group.bbox().width } //if glyph is the first reactant in a non-covelant-binding-reaction modify direction of arrow From 5a8e48530ab777f0e0ab6301b75366a79c2790cf Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Wed, 12 Dec 2018 01:40:24 -0500 Subject: [PATCH 04/16] Merge degradation with other circuit interactions --- lib/displayList.js | 19 ++++++++++++++++++- lib/interactions/inhibition.js | 3 +++ lib/interactions/non-covelant-binding.js | 1 + lib/interactions/production.js | 3 +++ lib/interactions/stimulation.js | 3 +++ lib/segment.js | 2 +- 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/displayList.js b/lib/displayList.js index 0199bc9..175bcf4 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -186,9 +186,14 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte combinedInteractionsDict = {} combinedInteractionsList = [] nonDNAInteractions = [] + degraded_NonDNAs = [] for(interaction of interactions) { - if (interaction.SBO === "SBO:0000177" || interaction.SBO === "SBO:0000179") { + if (interaction.SBO === "SBO:0000179") { + degraded_NonDNAs.push(interaction.participants[0].segment.name) + } + + if (interaction.SBO === "SBO:0000177") { nonDNAInteractions.push(interaction) } //this is the set of interaction types that currently our code is able to rende @@ -221,6 +226,18 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte } } } + + for (key in combinedInteractionsDict) { + console.log(combinedInteractionsDict) + for (interaction of combinedInteractionsDict[key]['interactions']) { + for (participant of interaction.participants) { + if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.name) != -1) { + console.log('participant',participant) + participant.isDegraded = true + } + } + } + } //get the values aa a list for (key in combinedInteractionsDict) { combinedInteractionsList.push(combinedInteractionsDict[key]) diff --git a/lib/interactions/inhibition.js b/lib/interactions/inhibition.js index 57be01f..c1ba153 100644 --- a/lib/interactions/inhibition.js +++ b/lib/interactions/inhibition.js @@ -54,6 +54,9 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //need to set the role for the segment to be able to add the rendering for inhibition arrow in reder segment interaction.participants[i].segment.role = "inhibition_nonDNA"; + if (interaction.participants[i].isDegraded) { + interaction.participants[i].segment.isDegradated = true + } interaction.participants[i].segment.participantRole = interaction.participants[i].role; var segment = Segment.render(design, interaction.participants[i].segment, interactions); diff --git a/lib/interactions/non-covelant-binding.js b/lib/interactions/non-covelant-binding.js index 86f5628..451814d 100644 --- a/lib/interactions/non-covelant-binding.js +++ b/lib/interactions/non-covelant-binding.js @@ -43,6 +43,7 @@ function render(design, interaction, segments, interactions) { if (interaction.participants[i].role === "product") { //segment.dx(110); + console.log('productOffset',productOffset) segment.dx(productOffset); } diff --git a/lib/interactions/production.js b/lib/interactions/production.js index 4560187..d2ced3e 100644 --- a/lib/interactions/production.js +++ b/lib/interactions/production.js @@ -52,6 +52,9 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf if (!interaction.participants[i].SO) { interaction.participants[i].segment.role = "production_nonDNA"; + if (interaction.participants[i].isDegraded) { + interaction.participants[i].segment.isDegradated = true + } interaction.participants[i].segment.participantRole = interaction.participants[i].role; var segment = Segment.render(design, interaction.participants[i].segment, interactions); diff --git a/lib/interactions/stimulation.js b/lib/interactions/stimulation.js index c6b8acc..08faab8 100644 --- a/lib/interactions/stimulation.js +++ b/lib/interactions/stimulation.js @@ -55,6 +55,9 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //need to set the role for the segment to be able to add the rendering for inhibition arrow in reder segment interaction.participants[i].segment.role = "simulation_nonDNA"; + if (interaction.participants[i].isDegraded) { + interaction.participants[i].segment.isDegradated = true + } interaction.participants[i].segment.participantRole = interaction.participants[i].role; var segment = Segment.render(design, interaction.participants[i].segment, interactions); diff --git a/lib/segment.js b/lib/segment.js index 6a52502..17161df 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -296,7 +296,7 @@ function renderSegment(design, segment, interactions,) { } - else if (segment.role === "degradationReactant") { + if (segment.isDegradated === true) { var arrowPos = Matrix(); //deponding on the implementation of the glyph, (if it starts from negative x area) we set the offset of degradation arrow From 2725ae176a366a55e98ec5c6a7850b9303662627 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Wed, 12 Dec 2018 02:19:52 -0500 Subject: [PATCH 05/16] fix product offset --- lib/displayList.js | 3 +-- lib/interactions/inhibition.js | 2 +- lib/interactions/non-covelant-binding.js | 9 ++++----- lib/interactions/production.js | 2 +- lib/interactions/stimulation.js | 2 +- lib/segment.js | 3 ++- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/displayList.js b/lib/displayList.js index 175bcf4..fe00b0a 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -228,11 +228,10 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte } for (key in combinedInteractionsDict) { - console.log(combinedInteractionsDict) + for (interaction of combinedInteractionsDict[key]['interactions']) { for (participant of interaction.participants) { if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.name) != -1) { - console.log('participant',participant) participant.isDegraded = true } } diff --git a/lib/interactions/inhibition.js b/lib/interactions/inhibition.js index c1ba153..0759166 100644 --- a/lib/interactions/inhibition.js +++ b/lib/interactions/inhibition.js @@ -58,7 +58,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf interaction.participants[i].segment.isDegradated = true } interaction.participants[i].segment.participantRole = interaction.participants[i].role; - var segment = Segment.render(design, interaction.participants[i].segment, interactions); + var segment = Segment.render(design, interaction.participants[i].segment, interactions, interaction); //move the nonDna part horizontally to put it above the DNA part interacting with it diff --git a/lib/interactions/non-covelant-binding.js b/lib/interactions/non-covelant-binding.js index 451814d..f11e7e4 100644 --- a/lib/interactions/non-covelant-binding.js +++ b/lib/interactions/non-covelant-binding.js @@ -19,6 +19,7 @@ function render(design, interaction, segments, interactions) { let reactantNumber = 0; let productOffset = 0; + let reactant2Offset = 0; let width = 0; for (let i in interaction.participants) { @@ -33,24 +34,22 @@ function render(design, interaction, segments, interactions) { interaction.participants[i].segment.isParticipant = true; - var segment = Segment.render(design, interaction.participants[i].segment, interactions); + var segment = Segment.render(design, interaction.participants[i].segment, interactions, interaction); if (i == 0) { productOffset = interaction.segmentWidth; - } if (interaction.participants[i].role === "product") { //segment.dx(110); - console.log('productOffset',productOffset) + reactant2Offset = segment.bbox().width + productOffset segment.dx(productOffset); - } else if (interaction.participants[i].segment.role === "reactant2") { segment.dx(220); - + //segment.dx(reactant2Offset); } segments.push(segment); diff --git a/lib/interactions/production.js b/lib/interactions/production.js index d2ced3e..0611d00 100644 --- a/lib/interactions/production.js +++ b/lib/interactions/production.js @@ -56,7 +56,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf interaction.participants[i].segment.isDegradated = true } interaction.participants[i].segment.participantRole = interaction.participants[i].role; - var segment = Segment.render(design, interaction.participants[i].segment, interactions); + var segment = Segment.render(design, interaction.participants[i].segment, interactions, interaction); if (isCircuit) { diff --git a/lib/interactions/stimulation.js b/lib/interactions/stimulation.js index 08faab8..010f03a 100644 --- a/lib/interactions/stimulation.js +++ b/lib/interactions/stimulation.js @@ -59,7 +59,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf interaction.participants[i].segment.isDegradated = true } interaction.participants[i].segment.participantRole = interaction.participants[i].role; - var segment = Segment.render(design, interaction.participants[i].segment, interactions); + var segment = Segment.render(design, interaction.participants[i].segment, interactions, interaction); if (isCircuit ) { diff --git a/lib/segment.js b/lib/segment.js index 17161df..05c124f 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -8,7 +8,7 @@ var Rect = require('./geom/rect'), Arrows = require('../font/sbolv/interaction-arrows/main') -function renderSegment(design, segment, interactions,) { +function renderSegment(design, segment, interactions, interaction) { var surface = design.surface; @@ -281,6 +281,7 @@ function renderSegment(design, segment, interactions,) { arrowGlyph.transform({ matrix: Matrix.toSVGString(arrowTransform) }); group.add(arrowGlyph); interaction.segmentWidth = group.bbox().width + } //if glyph is the first reactant in a non-covelant-binding-reaction modify direction of arrow From 8b53f6e0f8b1abe4a66c18cc831cbf7ba0f5953d Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Wed, 12 Dec 2018 04:32:02 -0500 Subject: [PATCH 06/16] code cleanup --- lib/component.js | 2 +- lib/displayList.js | 9 +++++---- lib/getDisplayList.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/component.js b/lib/component.js index b879f1c..e05e74c 100755 --- a/lib/component.js +++ b/lib/component.js @@ -55,7 +55,7 @@ helper.circuit_is_participant = function(segment, interactions) { else { for (interaction of interactions) { for (participant of interaction.participants) { - if (participant.SO && segment.name === participant.name) { + if (participant.SO && segment.name === participant.segment.name) { return true; } } diff --git a/lib/displayList.js b/lib/displayList.js index fe00b0a..cd58340 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -183,10 +183,10 @@ DisplayList.Entity = function Entity(displayList, entity) { */ DisplayList.combineInteractions = function combineInteractions(displayList, interactions) { - combinedInteractionsDict = {} - combinedInteractionsList = [] - nonDNAInteractions = [] - degraded_NonDNAs = [] + let combinedInteractionsDict = {} + let combinedInteractionsList = [] + let nonDNAInteractions = [] + let degraded_NonDNAs = [] for(interaction of interactions) { if (interaction.SBO === "SBO:0000179") { @@ -247,6 +247,7 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte return combinedInteractionsList } +/////////////////////////////////////////////////////////////////////////////////////// DisplayList.prototype = { getObjectByID: function getObjectByID(id) { diff --git a/lib/getDisplayList.js b/lib/getDisplayList.js index fcde465..ae32751 100644 --- a/lib/getDisplayList.js +++ b/lib/getDisplayList.js @@ -54,7 +54,7 @@ function recurseGetDisplayList(componentDefinition, segments, config, share, max } } - + segments = recurseGetDisplayList(component.definition, segments, config, share) } @@ -63,7 +63,7 @@ function recurseGetDisplayList(componentDefinition, segments, config, share, max return segments.map(segment => trimSequence(segment, max)) } -function getDisplayListSegment(componentDefinition, config, share) { +function getDisplayListSegment(componentDefinition, config, share,i) { var displayName = componentDefinition.displayId if (componentDefinition.name != '' && componentDefinition.name != componentDefinition.displayId) { From 3bd46e72e79a1541fa928b5c640497dd005434e2 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Wed, 19 Dec 2018 00:08:24 -0500 Subject: [PATCH 07/16] fix particpant roles name in condition for rotating stimulation arrow --- lib/segment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/segment.js b/lib/segment.js index 05c124f..0010f6b 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -261,7 +261,7 @@ function renderSegment(design, segment, interactions, interaction) { //if role of nonDNA part is not simulator flip the direction of simulation arrow //biologically it might never be the case - if (segment.participantRole !== "simulator") { + if (segment.participantRole !== "stimulator") { var arrowPos = Matrix(); var arrowTransform = Matrix.rotate(arrowPos, 180, { x:24, y:27}); arrowGlyph.transform({ matrix: Matrix.toSVGString(arrowTransform) }); From 4950f7bcdbf1789489a68529aa17f9dcb665c193 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 04:06:05 -0500 Subject: [PATCH 08/16] Add semgent Identity based on componentDefinition uri --- lib/displayList.js | 19 ++++++++++++++----- lib/getDisplayList.js | 5 ++++- lib/interactions/degradation.js | 2 +- lib/segment.js | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/lib/displayList.js b/lib/displayList.js index cd58340..9495e1a 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -186,11 +186,13 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte let combinedInteractionsDict = {} let combinedInteractionsList = [] let nonDNAInteractions = [] + let degradationsDict = {} let degraded_NonDNAs = [] for(interaction of interactions) { if (interaction.SBO === "SBO:0000179") { - degraded_NonDNAs.push(interaction.participants[0].segment.name) + degraded_NonDNAs.push(interaction.participants[0].segment.segmentId) + degradationsDict[interaction.participants[0].segment.segmentId] = interaction } if (interaction.SBO === "SBO:0000177") { @@ -206,9 +208,9 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte if (participant.SO) { - if (participant.segment.name in combinedInteractionsDict) { + if (participant.segment.segmentId in combinedInteractionsDict) { - combinedInteractionsDict[participant.segment.name]['interactions'].push(interaction) + combinedInteractionsDict[participant.segment.segmentId]['interactions'].push(interaction) } else { @@ -217,7 +219,7 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte segmentInfoDict['segment'] = participant.segment segmentInfoDict['interactions'] = [] segmentInfoDict['interactions'].push(interaction) - combinedInteractionsDict[participant.segment.name] = segmentInfoDict + combinedInteractionsDict[participant.segment.segmentId] = segmentInfoDict } @@ -231,8 +233,10 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte for (interaction of combinedInteractionsDict[key]['interactions']) { for (participant of interaction.participants) { - if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.name) != -1) { + if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.segmentId) != -1) { participant.isDegraded = true + console.log("name",interaction.participants[0].segment.segmentId) + degradationsDict[interaction.participants[0].segment.segmentId] = null } } } @@ -241,6 +245,11 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte for (key in combinedInteractionsDict) { combinedInteractionsList.push(combinedInteractionsDict[key]) } + for (key in degradationsDict) { + if (degradationsDict[key] !== null) { + combinedInteractionsList.push(degradationsDict[key]) + } + } for (interaction of nonDNAInteractions) { combinedInteractionsList.push(interaction) } diff --git a/lib/getDisplayList.js b/lib/getDisplayList.js index ae32751..aea3790 100644 --- a/lib/getDisplayList.js +++ b/lib/getDisplayList.js @@ -105,7 +105,6 @@ function getDisplayListSegment(componentDefinition, config, share,i) { if (componentDefinition.sequenceAnnotations.length === 0 && componentDefinition.components.length === 0) { - //console.log(componentDefinition); var glyph = 'unspecified' var name = componentDefinition.name != '' ? componentDefinition.name : componentDefinition.displayId var roles = componentDefinition.roles @@ -173,6 +172,8 @@ function getDisplayListSegment(componentDefinition, config, share,i) { return { name: displayName, + //extra field for identity of a segment + segmentId: componentDefinition.uri.toString(), sequence: [{ strand: "positive", type: glyph, @@ -189,6 +190,8 @@ function getDisplayListSegment(componentDefinition, config, share,i) { return { name: displayName, + //extra field for identity of a segment + segmentId: componentDefinition.uri.toString(), sequence: sortedSequenceAnnotations(componentDefinition).map((sequenceAnnotation) => { var glyph = 'unspecified' diff --git a/lib/interactions/degradation.js b/lib/interactions/degradation.js index b709499..bcbe77e 100644 --- a/lib/interactions/degradation.js +++ b/lib/interactions/degradation.js @@ -20,7 +20,7 @@ function render(design, interaction, segments, interactions) { } interaction.participants[i].segment.isParticipant = true; - var segment = Segment.render(design, interaction.participants[i].segment, interactions); + var segment = Segment.render(design, interaction.participants[i].segment, interactions, interaction); segments.push(segment); } } diff --git a/lib/segment.js b/lib/segment.js index 0010f6b..a1e3dce 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -297,6 +297,21 @@ function renderSegment(design, segment, interactions, interaction) { } + else if (segment.role === "degradationReactant") { + + var arrowPos = Matrix(); + //deponding on the implementation of the glyph, (if it starts from negative x area) we set the offset of degradation arrow + var effectiveOffset = glyphProps.glyphLength ? glyphProps.glyphLength : Math.max(glyph.bbox().width, glyphLength); + var arrowOffset = Vec2(effectiveOffset + 5, -boundingBoxSize.y); + var arrowTransform = Matrix.multiply( Matrix.translation(arrowOffset), arrowPos ); + var arrowProps = Arrows.DegradationArrow.render(design, glyphObject, boundingBoxSize ); + var arrowGlyph = arrowProps.glyph; + arrowGlyph.transform({ matrix: Matrix.toSVGString(arrowTransform) }); + group.add(arrowGlyph); + } + + + if (segment.isDegradated === true) { var arrowPos = Matrix(); From 78af28689c69fa1ed63ffea691bdb2cea682e900 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 05:17:19 -0500 Subject: [PATCH 09/16] modify combined interaction text label --- font/sbolv/interaction-arrows/main.js | 2 +- .../interaction-arrows/simulatorArrow.js | 62 ------------------- lib/displayList.js | 38 ++++++------ lib/interaction.js | 16 ++--- lib/interactions/stimulation.js | 2 +- lib/segment.js | 8 +-- 6 files changed, 31 insertions(+), 97 deletions(-) delete mode 100644 font/sbolv/interaction-arrows/simulatorArrow.js diff --git a/font/sbolv/interaction-arrows/main.js b/font/sbolv/interaction-arrows/main.js index 2a32874..9d0b607 100644 --- a/font/sbolv/interaction-arrows/main.js +++ b/font/sbolv/interaction-arrows/main.js @@ -2,7 +2,7 @@ module.exports = { 'InhibitorArrow': require('./inhibitorArrow'), 'ProductArrow': require('./productArrow'), -'SimulatorArrow': require('./simulatorArrow'), +'StimulatorArrow': require('./stimulatorArrow'), 'ReactantArrow': require('./reactantArrow'), 'DegradationArrow': require('./degradationArrow') } diff --git a/font/sbolv/interaction-arrows/simulatorArrow.js b/font/sbolv/interaction-arrows/simulatorArrow.js deleted file mode 100644 index dbb6cdd..0000000 --- a/font/sbolv/interaction-arrows/simulatorArrow.js +++ /dev/null @@ -1,62 +0,0 @@ - -var Vec2 = require('../../../lib/geom/vec2') -var Rect = require('../../../lib/geom/rect') - -function createGeometry(boxSize) { - - return { - - top: Vec2(boxSize.x/2, boxSize.y * 0.2), - bottom: Vec2(boxSize.x/2, boxSize.y * 0.8), - - left: Vec2(boxSize.x/3,boxSize.y * 0.8), - right: Vec2((boxSize.x * 2 )/3, boxSize.y * 0.8), - arrowBottom:Vec2(boxSize.x/2, boxSize.y) - - }; -} - -function renderGlyph(design, glyphObject, boxSize) { - - var geom = createGeometry(boxSize); - - var path = [ - - 'M' + Vec2.toPathString(geom.top), - 'L' + Vec2.toPathString(geom.bottom), - - 'M' + Vec2.toPathString(geom.left), - 'L' + Vec2.toPathString(geom.right), - 'L' + Vec2.toPathString(geom.arrowBottom), - 'Z' - - ].join(''); - - var glyph = design.surface.path(path); - var group = design.surface.group() - - glyph.attr('stroke', 'red'); - glyph.attr('stroke-width', glyphObject.thickness || '3px'); - - group.add(glyph); - - boundingBox = design.surface.rect(boxSize.x, boxSize.y); - boundingBox.attr('fill-opacity', 0); - - if(glyphObject.uri) - boundingBox.attr('data-uri', glyphObject.uri); - - group.add(boundingBox); - - return { - glyph: group - }; -} - -module.exports = { - - render: renderGlyph, -}; - - - diff --git a/lib/displayList.js b/lib/displayList.js index 9495e1a..805999d 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -39,7 +39,7 @@ function DisplayList(displayListObject) { if(displayListObject.interactions !== undefined) { this.interactions = displayListObject.interactions; - this.combinedInteractions = DisplayList.combineInteractions(displayList, displayListObject.interactions) + this.combinedInteractions = DisplayList.combinedInteractions(displayList, displayListObject.interactions) } @@ -181,23 +181,14 @@ DisplayList.Entity = function Entity(displayList, entity) { /* ******************************************************************************************* */ -DisplayList.combineInteractions = function combineInteractions(displayList, interactions) { +DisplayList.combinedInteractions = function combinedInteractions(displayList, interactions) { let combinedInteractionsDict = {} let combinedInteractionsList = [] - let nonDNAInteractions = [] let degradationsDict = {} let degraded_NonDNAs = [] for(interaction of interactions) { - if (interaction.SBO === "SBO:0000179") { - degraded_NonDNAs.push(interaction.participants[0].segment.segmentId) - degradationsDict[interaction.participants[0].segment.segmentId] = interaction - } - - if (interaction.SBO === "SBO:0000177") { - nonDNAInteractions.push(interaction) - } //this is the set of interaction types that currently our code is able to rende let AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000589"]; //let AvailableInteractions = ["SBO:0000169", "SBO:0000170", "SBO:0000177", "SBO:0000179", "SBO:0000589"]; @@ -227,6 +218,15 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte } } + + if (interaction.SBO === "SBO:0000179") { + degraded_NonDNAs.push(interaction.participants[0].segment.segmentId) + degradationsDict[interaction.participants[0].segment.segmentId] = interaction + } + + if (interaction.SBO === "SBO:0000177") { + combinedInteractionsList.push(interaction) + } } for (key in combinedInteractionsDict) { @@ -235,24 +235,24 @@ DisplayList.combineInteractions = function combineInteractions(displayList, inte for (participant of interaction.participants) { if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.segmentId) != -1) { participant.isDegraded = true - console.log("name",interaction.participants[0].segment.segmentId) - degradationsDict[interaction.participants[0].segment.segmentId] = null + degradationsDict[participant.segment.segmentId] = null } } } } - //get the values aa a list - for (key in combinedInteractionsDict) { - combinedInteractionsList.push(combinedInteractionsDict[key]) - } + + //add interactions of type degradation which are not participating in circiut interactions for (key in degradationsDict) { if (degradationsDict[key] !== null) { combinedInteractionsList.push(degradationsDict[key]) } } - for (interaction of nonDNAInteractions) { - combinedInteractionsList.push(interaction) + + //get the values aa a list + for (key in combinedInteractionsDict) { + combinedInteractionsList.push(combinedInteractionsDict[key]) } + return combinedInteractionsList } diff --git a/lib/interaction.js b/lib/interaction.js index 9fb313e..76b049f 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -57,17 +57,13 @@ function renderInteraction(design, combinedInteraction, interactions) { } } else { - //console.log(segments, "segments") + if (combinedInteraction.SBO === "SBO:0000177") { - //console.log(combinedInteraction) - nonCovelantBinding.render(design, combinedInteraction, segments, interactions); - //console.log("segments", segments) - + nonCovelantBinding.render(design, combinedInteraction, segments, interactions); } - else if (combinedInteraction.SBO === "SBO:0000179") { - // console.log("COmbinedInteraction", combinedInteraction) - Degradation.render(design, combinedInteraction, segments, interactions); + else if (combinedInteraction.SBO === "SBO:0000179") { + Degradation.render(design, combinedInteraction, segments, interactions); } else { @@ -100,13 +96,13 @@ function renderInteraction(design, combinedInteraction, interactions) { design.geom.interactionPosition = design.geom.interactionPosition + group.bbox().height + design.geom.interactionPadding; - if(interaction.displayId !== undefined) { + if(combinedInteraction.segment !== undefined) { var labelText = design.surface.text(''); labelText.font({ anchor: 'left' }); labelText.build(true); - var label = labelText.tspan(interaction.displayId); + var label = labelText.tspan(combinedInteraction.segment.name + " interactions"); label.attr('alignment-baseline', 'middle'); labelText.build(false); diff --git a/lib/interactions/stimulation.js b/lib/interactions/stimulation.js index 010f03a..9b42c96 100644 --- a/lib/interactions/stimulation.js +++ b/lib/interactions/stimulation.js @@ -54,7 +54,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf if (!interaction.participants[i].SO) { //need to set the role for the segment to be able to add the rendering for inhibition arrow in reder segment - interaction.participants[i].segment.role = "simulation_nonDNA"; + interaction.participants[i].segment.role = "stimulation_nonDNA"; if (interaction.participants[i].isDegraded) { interaction.participants[i].segment.isDegradated = true } diff --git a/lib/segment.js b/lib/segment.js index a1e3dce..4434ff8 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -253,13 +253,13 @@ function renderSegment(design, segment, interactions, interaction) { group.add(arrowGlyph); } - //if glyph object has the role of a simulator in a simulation, Add simulation arrow to the object - else if (segment.role === "simulation_nonDNA") { + //if glyph object has the role of a stimulator in a simulation, Add simulation arrow to the object + else if (segment.role === "stimulation_nonDNA") { - var arrowProps = Arrows.SimulatorArrow.render(design, glyphObject, boundingBoxSize ); + var arrowProps = Arrows.StimulatorArrow.render(design, glyphObject, boundingBoxSize ); var arrowGlyph = arrowProps.glyph; - //if role of nonDNA part is not simulator flip the direction of simulation arrow + //if role of nonDNA part is not stimulator flip the direction of simulation arrow //biologically it might never be the case if (segment.participantRole !== "stimulator") { var arrowPos = Matrix(); From d658cafc9ed02fc02f18e90fee5b3ee19f8ca34e Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 05:32:50 -0500 Subject: [PATCH 10/16] change label for complex and degradation --- lib/interaction.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/interaction.js b/lib/interaction.js index 76b049f..263ccf0 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -95,25 +95,28 @@ function renderInteraction(design, combinedInteraction, interactions) { group.add(box); design.geom.interactionPosition = design.geom.interactionPosition + group.bbox().height + design.geom.interactionPadding; - + var labelTextString = '' if(combinedInteraction.segment !== undefined) { + labelTextString = combinedInteraction.segment.name + " interactions" + } + else if(combinedInteraction.displayId !== undefined) { + labelTextString = combinedInteraction.displayId + } + + var labelText = design.surface.text(''); + labelText.font({ anchor: 'left' }); + labelText.build(true); - var labelText = design.surface.text(''); - labelText.font({ anchor: 'left' }); - labelText.build(true); - - var label = labelText.tspan(combinedInteraction.segment.name + " interactions"); + var label = labelText.tspan(labelTextString); - label.attr('alignment-baseline', 'middle'); - labelText.build(false); + label.attr('alignment-baseline', 'middle'); + labelText.build(false); - labelText.dy(-box.bbox().height) - labelText.dx(-100) - group.add(labelText); - - } - + labelText.dy(-box.bbox().height) + labelText.dx(-100) + group.add(labelText); + group.displayList = segments; interaction.svg = group; From a0e74e4ca9688bb42b14cab2ebdb33cca2586c08 Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 06:41:18 -0500 Subject: [PATCH 11/16] sort interactions on top of a circuit --- lib/interaction.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/interaction.js b/lib/interaction.js index 263ccf0..953641f 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -10,6 +10,34 @@ var Segment = require('./segment'), Vec2 = require('./geom/vec2'), Matrix = require('./geom/matrix') +/* +* helper function to sort interactions on top of circuit +* this method puts all the interactinos of type stimulation and inhibtion +* to the left of interactions of type genetic production +*/ +function sortInteractions(interactionsList) { + + let interactions = interactionsList; + let currentProductionIndex = interactions.length - 1; + let numProduction = 0; + + for (interaction in interactionsList) { + + if (interaction.SBO === "SBO:0000589") { + numProduction++; + } + } + + for (let i = 0; i < interactionsList.length - numProduction - 1; ++i) { + + if (interactionsList[i].SBO === "SBO:0000589") { + temp = interactionsList[currentProductionIndex]; + interactionsList[currentProductionIndex] = interactionsList[i]; + interactionsList[i] = temp; + currentProductionIndex--; + } + } +} function renderInteraction(design, combinedInteraction, interactions) { @@ -20,7 +48,10 @@ function renderInteraction(design, combinedInteraction, interactions) { if (combinedInteraction.segment) { - if (combinedInteraction.segment.sequence.length > 1) { + //first sort the interactions + sortInteractions(combinedInteraction['interactions']); + + if (combinedInteraction.segment.sequence.length > 1) { combinedInteraction.segment.isCircuit = true; } combinedInteraction.segment.isParticipant = true; @@ -95,12 +126,12 @@ function renderInteraction(design, combinedInteraction, interactions) { group.add(box); design.geom.interactionPosition = design.geom.interactionPosition + group.bbox().height + design.geom.interactionPadding; - var labelTextString = '' + var labelTextString = ''; if(combinedInteraction.segment !== undefined) { - labelTextString = combinedInteraction.segment.name + " interactions" + labelTextString = combinedInteraction.segment.name + " interactions"; } else if(combinedInteraction.displayId !== undefined) { - labelTextString = combinedInteraction.displayId + labelTextString = combinedInteraction.displayId; } var labelText = design.surface.text(''); From 64c848f83749c2b0e287bb09bf38f7e15e63a8fe Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 13:17:02 -0500 Subject: [PATCH 12/16] remove commented parts --- lib/displayList.js | 8 ++------ lib/interaction.js | 4 ++-- lib/interactions/inhibition.js | 18 +----------------- lib/interactions/production.js | 26 ++++++-------------------- lib/interactions/stimulation.js | 17 +---------------- 5 files changed, 12 insertions(+), 61 deletions(-) diff --git a/lib/displayList.js b/lib/displayList.js index 805999d..71d8a9b 100755 --- a/lib/displayList.js +++ b/lib/displayList.js @@ -205,17 +205,14 @@ DisplayList.combinedInteractions = function combinedInteractions(displayList, in } else { - segmentInfoDict = {} segmentInfoDict['segment'] = participant.segment segmentInfoDict['interactions'] = [] segmentInfoDict['interactions'].push(interaction) combinedInteractionsDict[participant.segment.segmentId] = segmentInfoDict - } - + } } - } } @@ -229,8 +226,7 @@ DisplayList.combinedInteractions = function combinedInteractions(displayList, in } } - for (key in combinedInteractionsDict) { - + for (key in combinedInteractionsDict) { for (interaction of combinedInteractionsDict[key]['interactions']) { for (participant of interaction.participants) { if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.segmentId) != -1) { diff --git a/lib/interaction.js b/lib/interaction.js index 953641f..a2f1057 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -21,14 +21,14 @@ function sortInteractions(interactionsList) { let currentProductionIndex = interactions.length - 1; let numProduction = 0; - for (interaction in interactionsList) { + for (interaction of interactionsList) { if (interaction.SBO === "SBO:0000589") { numProduction++; } } - for (let i = 0; i < interactionsList.length - numProduction - 1; ++i) { + for (let i = 0; i < interactionsList.length - numProduction; ++i) { if (interactionsList[i].SBO === "SBO:0000589") { temp = interactionsList[currentProductionIndex]; diff --git a/lib/interactions/inhibition.js b/lib/interactions/inhibition.js index 0759166..351b5a7 100644 --- a/lib/interactions/inhibition.js +++ b/lib/interactions/inhibition.js @@ -35,21 +35,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //need to set it to true since we don't want to show the label for the segments interaction.participants[i].segment.isParticipant = true; - //if participant is a Dna part or circuit - /* if (interaction.participants[i].SO) { - - if (isCircuit) { - interaction.participants[i].segment.isCircuit = true; - } - //update participant offset - design.geom.participantOffset = Helper.find_participant_offset(interaction.participants[i], interaction.displayId, "inhibition"); - var segment = Segment.render(design, interaction.participants[i].segment, interactions); - nonDNAVerticalOffset = segment.bbox().height + 8; - nonDNAshorizontalOffset = (segment.bbox().width)/2; - }*/ - nonDNAVerticalOffset = segments[0].bbox().height + 20 - console.log(nonDNAVerticalOffset) if (!interaction.participants[i].SO) { //need to set the role for the segment to be able to add the rendering for inhibition arrow in reder segment @@ -75,9 +61,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf segment.dy(-90); } segments.push(segment); - } - - //segments.push(segment); + } } } diff --git a/lib/interactions/production.js b/lib/interactions/production.js index 0611d00..13883c2 100644 --- a/lib/interactions/production.js +++ b/lib/interactions/production.js @@ -29,25 +29,12 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf } for (let i in interaction.participants) { - //clear all the previous rolles attached to participant segment - interaction.participants[i].segment.role = null; + //clear all the previous rolles attached to participant segment + interaction.participants[i].segment.role = null; - //need to set it to true since we don't want to show the label for the segments - interaction.participants[i].segment.isParticipant = true; - - //if participant is a Dna part or circuit - /*if (interaction.participants[i].SO) { - if (isCircuit) { - interaction.participants[i].segment.isCircuit = true; - } - //update participant offset - design.geom.participantOffset = Helper.find_participant_offset(interaction.participants[i], interaction.displayId, "production"); - var segment = Segment.render(design, interaction.participants[i].segment, interactions); - nonDNAVerticalOffset = segment.bbox().height + 30; - console.log(segment.bbox().height) - nonDNAshorizontalOffset = (segment.bbox().width)/2; - }*/ - + //need to set it to true since we don't want to show the label for the segments + interaction.participants[i].segment.isParticipant = true; + nonDNAVerticalOffset = segments[0].bbox().height + 20 if (!interaction.participants[i].SO) { @@ -73,8 +60,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //segment.dx(nonDNAshorizontalOffset - segment.bbox().width) } segments.push(segment); - } - // segments.push(segment); + } } } diff --git a/lib/interactions/stimulation.js b/lib/interactions/stimulation.js index 9b42c96..c303d18 100644 --- a/lib/interactions/stimulation.js +++ b/lib/interactions/stimulation.js @@ -36,20 +36,6 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //need to set it to true since we don't want to show the label for the segments interaction.participants[i].segment.isParticipant = true; - //if participant is a Dna part or circuit - /* if (interaction.participants[i].SO) { - - if (isCircuit) { - interaction.participants[i].segment.isCircuit = true; - } - - //update participant offset - design.geom.participantOffset = Helper.find_participant_offset(interaction.participants[i], interaction.displayId, "simulation"); - var segment = Segment.render(design, interaction.participants[i].segment, interactions); - nonDNAVerticalOffset = segment.bbox().height + 30; - nonDNAshorizontalOffset = (segment.bbox().width)/2; - }*/ - nonDNAVerticalOffset = segments[0].bbox().height + 25 if (!interaction.participants[i].SO) { @@ -73,8 +59,7 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //segment.dx(nonDNAshorizontalOffset - segment.bbox().width) } segments.push(segment); - } - //segments.push(segment); + } } } From 23e21ec5d330ab43ecaa5068790fe65e9321ae3f Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 13:20:53 -0500 Subject: [PATCH 13/16] remove commented code --- lib/interaction.js | 2 -- lib/interactions/inhibition.js | 1 - lib/interactions/production.js | 1 - lib/interactions/stimulation.js | 1 - lib/segment.js | 11 ++++------- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/interaction.js b/lib/interaction.js index a2f1057..57c9d1c 100644 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -149,8 +149,6 @@ function renderInteraction(design, combinedInteraction, interactions) { group.add(labelText); group.displayList = segments; - interaction.svg = group; - return group; } diff --git a/lib/interactions/inhibition.js b/lib/interactions/inhibition.js index 351b5a7..a9d49cb 100644 --- a/lib/interactions/inhibition.js +++ b/lib/interactions/inhibition.js @@ -49,7 +49,6 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf //move the nonDna part horizontally to put it above the DNA part interacting with it if (isCircuit) { - //segment.dx( (design.geom.participantOffset -1) * (design.geom.defaultGlyphSize.x + design.geom.glyphPadding) + design.geom.glyphPadding + design.geom.defaultGlyphSize.x/2 + 25) segment.dx(nonDNAshorizontalOffset - segment.bbox().width) //move the nonDNA part vertically segment.dy(-nonDNAVerticalOffset); diff --git a/lib/interactions/production.js b/lib/interactions/production.js index 13883c2..022c0b3 100644 --- a/lib/interactions/production.js +++ b/lib/interactions/production.js @@ -47,7 +47,6 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf if (isCircuit) { - //segment.dx( (design.geom.participantOffset -1) * (design.geom.defaultGlyphSize.x + design.geom.glyphPadding) + design.geom.glyphPadding + design.geom.defaultGlyphSize.x/2) segment.dx(nonDNAshorizontalOffset - segment.bbox().width) //move the nonDNA part vertically segment.dy(-nonDNAVerticalOffset); diff --git a/lib/interactions/stimulation.js b/lib/interactions/stimulation.js index c303d18..b6b7493 100644 --- a/lib/interactions/stimulation.js +++ b/lib/interactions/stimulation.js @@ -49,7 +49,6 @@ function render(design, interaction, segments, interactions, nonDNAshorizontalOf if (isCircuit ) { - //segment.dx( (design.geom.participantOffset -1) * (design.geom.defaultGlyphSize.x + design.geom.glyphPadding) + design.geom.glyphPadding + design.geom.defaultGlyphSize.x/2) segment.dx(nonDNAshorizontalOffset - segment.bbox().width); segment.dy(-nonDNAVerticalOffset); } diff --git a/lib/segment.js b/lib/segment.js index 4434ff8..1d988fc 100755 --- a/lib/segment.js +++ b/lib/segment.js @@ -418,15 +418,12 @@ function renderSegment(design, segment, interactions, interaction) { if (!segment.isParticipant) { group.add(labelText); - } - - - + } } - group.displayList = segment; - segment.svg = group; - console.log(group.bbox().height) + group.displayList = segment; + segment.svg = group; + return group; } From 0ce640d5cc7d022693337a3a94df8047e4ff941a Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 13:27:10 -0500 Subject: [PATCH 14/16] Add validation conditions when creating interaction list --- lib/getInteractionList.js | 41 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/getInteractionList.js b/lib/getInteractionList.js index a27479d..6ccd673 100644 --- a/lib/getInteractionList.js +++ b/lib/getInteractionList.js @@ -30,31 +30,34 @@ function getInteractionList(moduleDefinition) { let participantObj = {}; - participantObj.displayId = participation.displayId; - if (participation.participant.definition) + if (participation.displayId !== undefined) { + participantObj.displayId = participation.displayId; + } + + if (participation.participant.definition) { participantObj.segment = getDisplayListSegment(participation.participant.definition) - participantObj.name = participation.participant.definition.displayId; + participantObj.name = participation.participant.definition.displayId; - //Attaching type when participant is Non-DNA - if( /*participation.participant.definition.roles.length === 0 */participation.participant.definition.types[0]._parts.fragment != "DnaRegion") { + //Attaching type when participant is Non-DNA + if(participation.participant.definition.types[0]._parts.fragment != "DnaRegion") { - if (participation.participant.definition.types.length === 1) { - //Attaching type - participantObj.type = participation.participant.definition.types[0]._parts.fragment; - } - } + if (participation.participant.definition.types.length === 1) { + //Attaching type + participantObj.type = participation.participant.definition.types[0]._parts.fragment; + } + } - //Attaching type when participant is DNA - else if( participation.participant.definition.roles.length === 1 ) { + //Attaching type when participant is DNA + else if( participation.participant.definition.roles.length === 1 ) { - var SOCode = participation.participant.definition.roles[0]._parts.path.split('/').pop(); - //var SOCode = participation._roles[0]._parts.path.split('/').pop(); - // This property only exists for DNA parts - participantObj.SO = SOCode ; - participantObj.type = soToGlyphType(SOCode); - - } + var SOCode = participation.participant.definition.roles[0]._parts.path.split('/').pop(); + //var SOCode = participation._roles[0]._parts.path.split('/').pop(); + // This property only exists for DNA parts + participantObj.SO = SOCode ; + participantObj.type = soToGlyphType(SOCode); + } + } if (participation.roles.length === 1) { From 3ede092ee6854ec8e88851bcb2913050aaa2d75d Mon Sep 17 00:00:00 2001 From: asadeg02 Date: Thu, 20 Dec 2018 15:57:11 -0500 Subject: [PATCH 15/16] Add stimulatorArrow.js --- .../interaction-arrows/stimulatorArrow.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 font/sbolv/interaction-arrows/stimulatorArrow.js diff --git a/font/sbolv/interaction-arrows/stimulatorArrow.js b/font/sbolv/interaction-arrows/stimulatorArrow.js new file mode 100644 index 0000000..dbb6cdd --- /dev/null +++ b/font/sbolv/interaction-arrows/stimulatorArrow.js @@ -0,0 +1,62 @@ + +var Vec2 = require('../../../lib/geom/vec2') +var Rect = require('../../../lib/geom/rect') + +function createGeometry(boxSize) { + + return { + + top: Vec2(boxSize.x/2, boxSize.y * 0.2), + bottom: Vec2(boxSize.x/2, boxSize.y * 0.8), + + left: Vec2(boxSize.x/3,boxSize.y * 0.8), + right: Vec2((boxSize.x * 2 )/3, boxSize.y * 0.8), + arrowBottom:Vec2(boxSize.x/2, boxSize.y) + + }; +} + +function renderGlyph(design, glyphObject, boxSize) { + + var geom = createGeometry(boxSize); + + var path = [ + + 'M' + Vec2.toPathString(geom.top), + 'L' + Vec2.toPathString(geom.bottom), + + 'M' + Vec2.toPathString(geom.left), + 'L' + Vec2.toPathString(geom.right), + 'L' + Vec2.toPathString(geom.arrowBottom), + 'Z' + + ].join(''); + + var glyph = design.surface.path(path); + var group = design.surface.group() + + glyph.attr('stroke', 'red'); + glyph.attr('stroke-width', glyphObject.thickness || '3px'); + + group.add(glyph); + + boundingBox = design.surface.rect(boxSize.x, boxSize.y); + boundingBox.attr('fill-opacity', 0); + + if(glyphObject.uri) + boundingBox.attr('data-uri', glyphObject.uri); + + group.add(boundingBox); + + return { + glyph: group + }; +} + +module.exports = { + + render: renderGlyph, +}; + + + From 6e9258e0fe74391d667832cb441342608c531709 Mon Sep 17 00:00:00 2001 From: Chris Myers Date: Thu, 20 Dec 2018 14:42:34 -0700 Subject: [PATCH 16/16] Fix issue with support for spoof URL and share links --- lib/getInteractionList.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/getInteractionList.js b/lib/getInteractionList.js index 6ccd673..92cf791 100644 --- a/lib/getInteractionList.js +++ b/lib/getInteractionList.js @@ -3,7 +3,7 @@ var sboToInteractionType = require('./sboToInteractionType') var sboToRole = require('./sboToRole') var getDisplayListSegment = require('./getDisplayList').getDisplayListSegment -function getInteractionList(moduleDefinition) { +function getInteractionList(moduleDefinition, config, share) { let interactions = []; @@ -35,7 +35,7 @@ function getInteractionList(moduleDefinition) { } if (participation.participant.definition) { - participantObj.segment = getDisplayListSegment(participation.participant.definition) + participantObj.segment = getDisplayListSegment(participation.participant.definition,config,share) participantObj.name = participation.participant.definition.displayId; //Attaching type when participant is Non-DNA