use of org.vcell.model.rbm.NetworkConstraints in project vcell by virtualcell.
the class BNGExecutorServiceMultipass method extractNetworkConstraints.
private static NetworkConstraints extractNetworkConstraints(String cBngInputString) {
NetworkConstraints nc = new NetworkConstraints();
String s1 = cBngInputString.substring(cBngInputString.indexOf("max_iter=>") + "max_iter=>".length());
s1 = s1.substring(0, s1.indexOf(","));
int maxi = Integer.parseInt(s1);
nc.setMaxIteration(maxi);
String s2 = cBngInputString.substring(cBngInputString.indexOf("max_agg=>") + "max_agg=>".length());
s2 = s2.substring(0, s2.indexOf(","));
int maxa = Integer.parseInt(s2);
nc.setMaxMoleculesPerSpecies(maxa);
return nc;
}
use of org.vcell.model.rbm.NetworkConstraints in project vcell by virtualcell.
the class SimContextTable method getAppComponentsForDatabase.
/**
* getXMLStringForDatabase : this returns the XML string for the container element <AppComponents> for application-related protocols
* and other extra specifications. For now, BioEvents falls under this category, so the BioEvents element (list of bioevents)
* is obtained from the simContext (via the XMLProducer) and added as content to <AppComponents> element. The <AppComponents>
* element is converted to XML string which is the return value of this method. This string is stored in the database in the
* SimContextTable. Instead of creating new fields for each possible application component, it is convenient to store them
* all under a blanket XML element <AppComponents>.
* @param simContext
* @return
*/
public static String getAppComponentsForDatabase(SimulationContext simContext) {
Element appComponentsElement = new Element(XMLTags.ApplicationComponents);
// for now, create the element only if application is stochastic. Can change it later.
if (simContext.isStoch()) {
// add 'randomizeInitCondition' flag only if simContext is non-spatial
if (simContext.getGeometry().getDimension() == 0) {
Element appRelatedFlagsElement = new Element(XMLTags.ApplicationSpecificFlagsTag);
if (simContext.isRandomizeInitCondition()) {
appRelatedFlagsElement.setAttribute(XMLTags.RandomizeInitConditionTag, "true");
} else {
appRelatedFlagsElement.setAttribute(XMLTags.RandomizeInitConditionTag, "false");
}
appComponentsElement.addContent(appRelatedFlagsElement);
}
}
if (simContext.isInsufficientIterations()) {
appComponentsElement.setAttribute(XMLTags.InsufficientIterationsTag, "true");
} else {
appComponentsElement.setAttribute(XMLTags.InsufficientIterationsTag, "false");
}
if (simContext.isInsufficientMaxMolecules()) {
appComponentsElement.setAttribute(XMLTags.InsufficientMaxMoleculesTag, "true");
} else {
appComponentsElement.setAttribute(XMLTags.InsufficientMaxMoleculesTag, "false");
}
if (simContext.isUsingMassConservationModelReduction()) {
appComponentsElement.setAttribute(XMLTags.MassConservationModelReductionTag, "true");
} else {
appComponentsElement.setAttribute(XMLTags.MassConservationModelReductionTag, "false");
}
Xmlproducer xmlProducer = new Xmlproducer(false);
NetworkConstraints constraints = simContext.getNetworkConstraints();
if (constraints != null) {
appComponentsElement.addContent(xmlProducer.getXML(constraints, simContext));
}
// first fill in bioevents from simContext
BioEvent[] bioEvents = simContext.getBioEvents();
if (bioEvents != null && bioEvents.length > 0) {
try {
Element bioEventsElement = xmlProducer.getXML(bioEvents);
appComponentsElement.addContent(bioEventsElement);
} catch (XmlParseException e) {
throw new RuntimeException("Error generating XML for bioevents : " + e.getMessage(), e);
}
}
SimulationContextParameter[] appParams = simContext.getSimulationContextParameters();
if (appParams != null && appParams.length > 0) {
try {
Element appParamsElement = xmlProducer.getXML(appParams);
appComponentsElement.addContent(appParamsElement);
} catch (Exception e) {
throw new RuntimeException("Error generating XML for application parameters : " + e.getMessage(), e);
}
}
SpatialObject[] spatialObjects = simContext.getSpatialObjects();
if (spatialObjects != null && spatialObjects.length > 0) {
try {
Element spatialObjectsElement = xmlProducer.getXML(spatialObjects);
appComponentsElement.addContent(spatialObjectsElement);
} catch (XmlParseException e) {
throw new RuntimeException("Error generating XML for spatialObjects : " + e.getMessage(), e);
}
}
SpatialProcess[] spatialProcesses = simContext.getSpatialProcesses();
if (spatialProcesses != null && spatialProcesses.length > 0) {
try {
Element spatialProcessesElement = xmlProducer.getXML(spatialProcesses);
appComponentsElement.addContent(spatialProcessesElement);
} catch (XmlParseException e) {
throw new RuntimeException("Error generating XML for spatialProcesses : " + e.getMessage(), e);
}
}
// microscope measurements
Element element = xmlProducer.getXML(simContext.getMicroscopeMeasurement());
appComponentsElement.addContent(element);
// rate rules
RateRule[] rateRules = simContext.getRateRules();
if (rateRules != null && rateRules.length > 0) {
try {
Element rateRulesElement = xmlProducer.getXML(rateRules);
appComponentsElement.addContent(rateRulesElement);
} catch (XmlParseException e) {
throw new RuntimeException("Error generating XML for bioevents : " + e.getMessage(), e);
}
}
AssignmentRule[] assignmentRules = simContext.getAssignmentRules();
if (assignmentRules != null && assignmentRules.length > 0) {
try {
Element assignmentRulesElement = xmlProducer.getXML(assignmentRules);
appComponentsElement.addContent(assignmentRulesElement);
} catch (XmlParseException e) {
throw new RuntimeException("Error generating XML for bioevents : " + e.getMessage(), e);
}
}
// ReactionRuleSpecs
ReactionRuleSpec[] reactionRuleSpecs = simContext.getReactionContext().getReactionRuleSpecs();
if (reactionRuleSpecs != null && reactionRuleSpecs.length > 0) {
Element reactionRuleSpecsElement = xmlProducer.getXML(reactionRuleSpecs);
appComponentsElement.addContent(reactionRuleSpecsElement);
}
String appComponentsXMLStr = null;
if (appComponentsElement.getContent() != null) {
appComponentsXMLStr = XmlUtil.xmlToString(appComponentsElement);
}
return appComponentsXMLStr;
}
use of org.vcell.model.rbm.NetworkConstraints in project vcell by virtualcell.
the class IssuePanel method invokeHyperlink.
private void invokeHyperlink(Issue issue) {
if (selectionManager != null) {
// followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
IssueContext issueContext = issue.getIssueContext();
IssueSource object = issue.getSource();
if (object instanceof DecoratedIssueSource) {
DecoratedIssueSource dis = (DecoratedIssueSource) object;
dis.activateView(selectionManager);
} else if (object instanceof Parameter) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
} else if (object instanceof StructureMapping) {
StructureMapping structureMapping = (StructureMapping) object;
StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof SpatialObject) {
SpatialObject spatialObject = (SpatialObject) object;
SimulationContext simulationContext = spatialObject.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
} else if (object instanceof SpatialProcess) {
SpatialProcess spatialProcess = (SpatialProcess) object;
SimulationContext simulationContext = spatialProcess.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
} else if (object instanceof GeometryContext.UnmappedGeometryClass) {
UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof MicroscopeMeasurement) {
SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
} else if (object instanceof BioEvent) {
BioEvent be = (BioEvent) object;
SimulationContext simulationContext = be.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
} else if (object instanceof OutputFunctionIssueSource) {
SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
if (simulationOwner instanceof SimulationContext) {
SimulationContext simulationContext = (SimulationContext) simulationOwner;
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
} else if (simulationOwner instanceof MathModel) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
}
} else if (object instanceof Simulation) {
Simulation simulation = (Simulation) object;
SimulationOwner simulationOwner = simulation.getSimulationOwner();
if (simulationOwner instanceof SimulationContext) {
SimulationContext simulationContext = (SimulationContext) simulationOwner;
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
} else if (simulationOwner instanceof MathModel) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
}
} else if (object instanceof AssignmentRule) {
AssignmentRule ar = (AssignmentRule) object;
SimulationContext sc = ar.getSimulationContext();
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.assignmentRules), new Object[] { ar });
} else if (object instanceof RateRule) {
RateRule rr = (RateRule) object;
SimulationContext sc = rr.getSimulationContext();
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.rateRules), new Object[] { rr });
} else if (object instanceof GeometryContext) {
setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
} else if (object instanceof Structure) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
} else if (object instanceof MolecularType) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
} else if (object instanceof ReactionStep) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
} else if (object instanceof ReactionRule) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
followHyperlink(av, new Object[] { object });
} else if (object instanceof ReactionCombo) {
ReactionCombo rc = (ReactionCombo) object;
followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
} else if (object instanceof SpeciesContext) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
} else if (object instanceof RbmObservable) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
} else if (object instanceof MathDescription) {
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof SpeciesPattern) {
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
// } else {
System.err.println("SpeciesPattern object missing a proper issue context.");
// }
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmNetworkConstraintsBad:
NetworkConstraints nc = sc.getNetworkConstraints();
if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, nc.getMaxMoleculesPerSpecies() + "", NetworkTransformer.defaultMaxMoleculesPerSpecies + "");
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
} else {
NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, nc.getMaxIteration() + "", NetworkTransformer.defaultMaxIteration + "");
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
}
break;
default:
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
break;
}
} else if (object instanceof Geometry) {
if (issueContext.hasContextType(ContextType.SimContext)) {
SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
} else if (issueContext.hasContextType(ContextType.MathModel)) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
} else if (issueContext.hasContextType(ContextType.MathDescription)) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
}
} else {
System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
}
}
}
use of org.vcell.model.rbm.NetworkConstraints in project vcell by virtualcell.
the class ReturnBNGOutput method validateConstraints.
private void validateConstraints(BNGOutputSpec outputSpec) {
NetworkConstraints nc = owner.getSimulationContext().getNetworkConstraints();
Dimension dim = new Dimension(380, 210);
boolean showStoichiometryTable = false;
if (nc.isStoichiometryDifferent()) {
showStoichiometryTable = true;
// make it larger to accommodate the table
dim = new Dimension(380, 310);
}
ValidateConstraintsPanel panel = new ValidateConstraintsPanel(owner, showStoichiometryTable);
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(owner);
ChildWindow childWindow = childWindowManager.addChildWindow(panel, panel, "Apply the new constraints?");
childWindow.pack();
panel.setChildWindow(childWindow);
childWindow.setPreferredSize(dim);
childWindow.showModal();
if (panel.getButtonPushed() == ValidateConstraintsPanel.ActionButtons.Apply) {
System.out.println("pressed APPLY from task");
TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.TaskEndAdjustSimulationContextFlagsOnly, "");
owner.setNewCallbackMessage(tcm);
String string = "Updating the network constraints with the test values.";
System.out.println(string);
sc.getNetworkConstraints().updateConstraintsFromTest();
owner.updateOutputSpecToSimulationContext(outputSpec);
tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, string);
sc.firePropertyChange("appendToConsole", "", tcm);
return;
} else {
System.out.println("pressed CANCEL from task");
owner.updateOutputSpecToSimulationContext(null);
TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.Clean, "");
sc.appendToConsole(tcm);
String string = "The Network constraints were not updated with the test values.";
tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, string);
sc.firePropertyChange("appendToConsole", "", tcm);
// owner.refreshInterface();
return;
}
}
Aggregations