Skip to content

Commit

Permalink
Merge pull request #103 from VisBOL/merged-interaction
Browse files Browse the repository at this point in the history
Merged interaction
  • Loading branch information
cjmyers authored Dec 20, 2018
2 parents b016f78 + 6e9258e commit a736aaa
Show file tree
Hide file tree
Showing 16 changed files with 276 additions and 179 deletions.
6 changes: 3 additions & 3 deletions font/sbolv/interaction-arrows/inhibitorArrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

};
}
Expand Down
2 changes: 1 addition & 1 deletion font/sbolv/interaction-arrows/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module.exports = {
'InhibitorArrow': require('./inhibitorArrow'),
'ProductArrow': require('./productArrow'),
'SimulatorArrow': require('./simulatorArrow'),
'StimulatorArrow': require('./stimulatorArrow'),
'ReactantArrow': require('./reactantArrow'),
'DegradationArrow': require('./degradationArrow')
}
2 changes: 1 addition & 1 deletion font/sbolv/interaction-arrows/productArrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/design.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
101 changes: 80 additions & 21 deletions lib/displayList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function DisplayList(displayListObject) {
this.components = [];
this.processes = [];
this.interactions = [];
this.combinedInteractions = [];

this.refs = Object.create(null);

Expand Down Expand Up @@ -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.combinedInteractions(displayList, displayListObject.interactions)

}


Expand Down Expand Up @@ -194,6 +178,81 @@ DisplayList.Entity = function Entity(displayList, entity) {
this.name = entity.name;
}

/*
*******************************************************************************************
*/
DisplayList.combinedInteractions = function combinedInteractions(displayList, interactions) {

let combinedInteractionsDict = {}
let combinedInteractionsList = []
let degradationsDict = {}
let degraded_NonDNAs = []
for(interaction of interactions) {

//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"];

if (AvailableInteractions.indexOf(interaction.SBO) !== -1) {

for (participant of interaction.participants) {

if (participant.SO) {

if (participant.segment.segmentId in combinedInteractionsDict) {

combinedInteractionsDict[participant.segment.segmentId]['interactions'].push(interaction)

}
else {
segmentInfoDict = {}
segmentInfoDict['segment'] = participant.segment
segmentInfoDict['interactions'] = []
segmentInfoDict['interactions'].push(interaction)
combinedInteractionsDict[participant.segment.segmentId] = segmentInfoDict

}
}
}
}

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) {
for (interaction of combinedInteractionsDict[key]['interactions']) {
for (participant of interaction.participants) {
if (!participant.SO && degraded_NonDNAs.indexOf(participant.segment.segmentId) != -1) {
participant.isDegraded = true
degradationsDict[participant.segment.segmentId] = null
}
}
}
}

//add interactions of type degradation which are not participating in circiut interactions
for (key in degradationsDict) {
if (degradationsDict[key] !== null) {
combinedInteractionsList.push(degradationsDict[key])
}
}

//get the values aa a list
for (key in combinedInteractionsDict) {
combinedInteractionsList.push(combinedInteractionsDict[key])
}

return combinedInteractionsList
}

///////////////////////////////////////////////////////////////////////////////////////
DisplayList.prototype = {

getObjectByID: function getObjectByID(id) {
Expand Down
9 changes: 6 additions & 3 deletions lib/getDisplayList.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function recurseGetDisplayList(componentDefinition, segments, config, share, max

}
}

segments = recurseGetDisplayList(component.definition, segments, config, share)
}

Expand All @@ -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) {
Expand Down Expand Up @@ -105,7 +105,6 @@ function getDisplayListSegment(componentDefinition, config, share) {

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
Expand Down Expand Up @@ -173,6 +172,8 @@ function getDisplayListSegment(componentDefinition, config, share) {

return {
name: displayName,
//extra field for identity of a segment
segmentId: componentDefinition.uri.toString(),
sequence: [{
strand: "positive",
type: glyph,
Expand All @@ -189,6 +190,8 @@ function getDisplayListSegment(componentDefinition, config, share) {

return {
name: displayName,
//extra field for identity of a segment
segmentId: componentDefinition.uri.toString(),
sequence: sortedSequenceAnnotations(componentDefinition).map((sequenceAnnotation) => {

var glyph = 'unspecified'
Expand Down
44 changes: 24 additions & 20 deletions lib/getInteractionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand All @@ -30,30 +30,34 @@ function getInteractionList(moduleDefinition) {


let participantObj = {};
participantObj.displayId = participation.displayId;
participantObj.segment = getDisplayListSegment(participation.participant.definition)
participantObj.name = participation.participant.definition.displayId;
if (participation.displayId !== undefined) {
participantObj.displayId = participation.displayId;
}

if (participation.participant.definition) {
participantObj.segment = getDisplayListSegment(participation.participant.definition,config,share)
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) {

Expand Down
Loading

0 comments on commit a736aaa

Please sign in to comment.