Skip to content

Commit

Permalink
Merge pull request #1049 from StochSS/develop
Browse files Browse the repository at this point in the history
Release v.2.1.5
  • Loading branch information
BryanRumsey authored Oct 27, 2020
2 parents 3806bde + c095d02 commit 897e03b
Show file tree
Hide file tree
Showing 59 changed files with 808 additions and 420 deletions.
31 changes: 4 additions & 27 deletions client/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,29 +248,6 @@ module.exports = {

return templates.select(modalID, selectID, title, label, options)
},
addExistingWorkflowToProjectHtml : (options) => {
let modalID = "newProjectWorkflowModal"
let selectID = "workflowPathInput"
let title = "Add Existing Workflow to Workflow Group"
let label = "Path to the workflow"
options = options.map(function (name) {
return `<option value="${name}">${name}</option>`
})
options = options.join(" ")

return templates.select(modalID, selectID, title, label, options)
},
addExistingWorkflowToProjectSuccessHtml : (message) => {
let modalID = "newProjectModelSuccessModal"
let title = "Success!"

return templates.message(modalID, title, message)
},
addExistingWorkflowToProjectErrorHtml : (title, message) => {
let modalID = "newProjectModelErrorModal"

return templates.message(modalID, title, message)
},
newProjectModelSuccessHtml : (message) => {
let modalID = "newProjectModelSuccessModal"
let title = "Success!"
Expand Down Expand Up @@ -432,23 +409,23 @@ module.exports = {
renderDefaultModeModalHtml : () => {
let concentrationDesciption = `Variables will only be represented using continuous (floating point) values.`;
let populationDescription = `Population - Variables will only be represented using discrete (integer count) values.`;
let hybridDescription = `Allows a species to be represented using continuous and/or discrete values.`;
let hybridDescription = `Allows a variable to be represented using continuous and/or discrete values.`;

return `
<div id="defaultModeModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content info">
<div class="modal-header">
<h5 class="modal-title">Default Variables Mode (required)</h5>
<h5 class="modal-title">Default Variable Mode (required)</h5>
<button type="button" class="close close-modal" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div>
<p>
The default mode is used to set the mode of all species added to the model.
The mode of a species is used to determine how it will be represented in a Hybrid Concentration/Population simulation.
The default mode is used to set the mode of all variables added to the model.
The mode of a variable is used to determine how it will be represented in a simulation.
</p>
<p>Select one of the following: </p>
</div>
Expand Down
4 changes: 4 additions & 0 deletions client/models/event-assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ module.exports = State.extend({
initialize: function (attrs, options) {
State.prototype.initialize.apply(this, arguments);
},
validateComponent: function() {
if(!this.expression.trim()) return false;
return true;
}
});
7 changes: 7 additions & 0 deletions client/models/event-assignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ module.exports = Collection.extend({
removeEventAssignment: function (eventAssignment) {
this.remove(eventAssignment);
},
validateCollection: function () {
if(this.length <= 0) return false;
for(var i = 0; i < this.length; i++) {
if(!this.models[i].validateComponent()) return false;
}
return true;
}
});
17 changes: 17 additions & 0 deletions client/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,25 @@ module.exports = State.extend({
type: 'boolean',
default: true,
},
advanced_error: 'boolean'
},
initialize: function (attrs, options) {
State.prototype.initialize.apply(this, arguments);
this.eventAssignments.on('add change remove', this.updateValid, this)
this.validateComponent()
},
validateComponent: function () {
advanced_error = false;
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if(!this.triggerExpression.trim()) return false;
if(!this.priority.trim()) {
this.advanced_error = true;
return false;
};
if(!this.eventAssignments.validateCollection()) return false;
return true;
},
updateValid: function () {
this.collection.parent.updateValid();
}
});
9 changes: 9 additions & 0 deletions client/models/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ module.exports = Collection.extend({
this.remove(event);
this.parent.updateValid()
},
validateCollection: function () {
for(var i = 0; i < this.length; i++) {
if(!this.models[i].validateComponent()) {
this.parent.error = {'id':this.models[i].compID,'type':'event'}
return false
}
}
return true;
}
});
8 changes: 4 additions & 4 deletions client/models/model-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ var State = require('ampersand-state');

module.exports = State.extend({
props: {
endSim: 'number',
timeStep: 'number'
endSim: 'any',
timeStep: 'any'
},
initialize: function (attrs, options) {
State.prototype.initialize.apply(this, arguments)
},
validate: function () {
if(this.endSim == 0 || isNaN(this.endSim)) return false;
if(this.timeStep == 0 || isNaN(this.timeStep)) return false;
if(this.endSim === "" || isNaN(this.endSim)) return false;
if(this.timeStep === "" || isNaN(this.timeStep)) return false;
return true;
}
});
32 changes: 26 additions & 6 deletions client/models/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = Model.extend({
defaultID: 'number',
defaultMode: 'string',
annotation: 'string',
volume: 'number'
volume: 'any'
},
collections: {
species: Species,
Expand All @@ -62,19 +62,39 @@ module.exports = Model.extend({
directory: 'string',
isPreview: 'boolean',
for: 'string',
valid: 'boolean'
valid: 'boolean',
error: 'object'
},
initialize: function (attrs, options){
Model.prototype.initialize.apply(this, arguments);
this.species.on('add change remove', this.updateValid, this);
this.parameters.on('add change remove', this.updateValid, this);
this.reactions.on('add change remove', this.updateValid, this);
this.eventsCollection.on('add change remove', this.updateValid, this);
this.rules.on('add change remove', this.updateValid, this);
},
validateModel: function () {
if(this.volume == 0 || isNaN(this.volume)) return false;
if(this.species.length <= 0) return false;
if(this.reactions.length <= 0 && this.eventsCollection.length <= 0 && this.rules.length <= 0) return false
if(this.modelSettings.validate() === false) return false;
if(!this.species.validateCollection()) return false;
if(!this.parameters.validateCollection()) return false;
if(!this.reactions.validateCollection()) return false;
if(!this.eventsCollection.validateCollection()) return false;
if(!this.rules.validateCollection()) return false;
if(this.reactions.length <= 0 && this.eventsCollection.length <= 0 && this.rules.length <= 0) {
this.error = {"type":"process"}
return false;
}
if(!this.volume === "" || isNaN(this.volume)) {
this.error = {"type":"volume"}
return false
};
if(this.modelSettings.validate() === false) {
this.error = {"type":"timespan"}
return false
};
return true;
},
updateValid: function () {
this.error = {}
this.valid = this.validateModel()
},
getDefaultID: function () {
Expand Down
5 changes: 5 additions & 0 deletions client/models/parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ module.exports = State.extend({
initialize: function (attrs, options) {
State.prototype.initialize.apply(this, arguments);
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if(this.expression === "" || isNaN(this.expression)) return false
return true;
}
});
9 changes: 9 additions & 0 deletions client/models/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ module.exports = Collection.extend({
removeParameter: function (parameter) {
this.remove(parameter);
},
validateCollection: function () {
for(var i = 0; i < this.length; i++) {
if(!this.models[i].validateComponent()) {
this.parent.error = {'id':this.models[i].compID,'type':'parameter'}
return false
}
}
return true;
}
});
42 changes: 42 additions & 0 deletions client/models/reaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ module.exports = State.extend({
initialize: function (attrs, options) {
var self = this;
State.prototype.initialize.apply(this, arguments);
if(!this.reactionType.startsWith('custom')) {
let reactionType = this.updateReactionType();
if(this.reactionType !== reactionType){
this.reactionType = reactionType
this.buildSummary()
}
}
this.on('change-reaction', function () {
self.buildSummary();
self.checkModes();
Expand Down Expand Up @@ -129,4 +136,39 @@ module.exports = State.extend({
}
this.hasConflict = Boolean(hasContinuous && (hasDynamic || hasDiscrete))
},
updateReactionType: function () {
let numReactants = this.reactants.length
let numProducts = this.products.length
let prodRatio1 = numProducts > 0 ? this.products.models[0].ratio : 0
if(numReactants == 0 && numProducts == 1 && prodRatio1 == 1) return "creation";

let reactRatio1 = numReactants > 0 ? this.reactants.models[0].ratio : 0
let prodRatio2 = numProducts > 1 ? this.products.models[1].ratio : 0
if(numReactants == 1){
if(reactRatio1 == 1) {
if(numProducts == 0) return "destruction";
if(numProducts == 2 && prodRatio1 == 1 && prodRatio2 == 1) return "split";
}

if(numProducts == 1 && prodRatio1 == 1){
if(reactRatio1 == 1) return "change";
if(reactRatio1 == 2) return "dimerization";
}
}

let reactRatio2 = numReactants > 1 ? this.reactants.models[1].ratio : 0
if(numReactants == 2 && reactRatio1 == 1 && reactRatio2 == 1){
if(numProducts == 1 && prodRatio1 == 1) return "merge";
if(numProducts == 2 && prodRatio1 == 1 && prodRatio2 == 1) return "four";
}
return "custom-massaction"
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if(!this.propensity.trim() && this.reactionType === "custom-propensity") return false;
if(this.reactionType.startsWith('custom')) {
if(this.reactants.length <= 0 && this.products.length <= 0) return false;
}
return true;
}
});
9 changes: 9 additions & 0 deletions client/models/reactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ Reactions = Collection.extend({
this.remove(reaction);
this.parent.updateValid()
},
validateCollection: function () {
for(var i = 0; i < this.length; i++) {
if(!this.models[i].validateComponent()) {
this.parent.error = {'id':this.models[i].compID,'type':'reaction'}
return false
}
}
return true
}
});

Events.createEmitter(Reactions);
Expand Down
5 changes: 5 additions & 0 deletions client/models/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ module.exports = State.extend({
initialize: function (attrs, options) {
State.prototype.initialize.apply(this, arguments);
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if(!this.expression.trim()) return false;
return true;
}
});
9 changes: 9 additions & 0 deletions client/models/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,13 @@ module.exports = Collection.extend({
return this.parent.parameters.at(0)
}
},
validateCollection: function () {
for(var i = 0; i < this.length; i++) {
if(!this.models[i].validateComponent()) {
this.parent.error = {'id':this.models[i].compID,'type':'rule'}
return false
}
}
return true;
}
});
15 changes: 12 additions & 3 deletions client/models/specie.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ module.exports = State.extend({
props: {
compID: 'number',
name: 'string',
value: 'number',
value: 'any',
mode: 'string',
switchTol: 'number',
switchMin: 'number',
switchTol: 'any',
switchMin: 'any',
isSwitchTol: 'boolean',
annotation: 'string',
diffusionCoeff: 'number',
Expand All @@ -42,4 +42,13 @@ module.exports = State.extend({
initialize: function (attrs, options) {
State.prototype.initialize.apply(this, arguments);
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if(this.value === "" || isNaN(this.value)) return false;
if(this.mode === "dynamic") {
if(this.isSwitchTol && (this.switchTol === "" || isNaN(this.switchTol))) return false;
if(!this.isSwitchTol && (this.switchMin === "" || isNaN(this.switchMin))) return false;
}
return true;
}
});
13 changes: 13 additions & 0 deletions client/models/species.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,17 @@ module.exports = Collection.extend({
this.remove(specie);
this.parent.updateValid()
},
validateCollection: function () {
if(this.length <= 0) {
this.parent.error = {'type':'species'}
return false;
}
for(var i = 0; i < this.length; i++) {
if(!this.models[i].validateComponent()) {
this.parent.error = {'id':this.models[i].compID,'type':'species'}
return false
}
}
return true;
}
});
Loading

0 comments on commit 897e03b

Please sign in to comment.