use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class StochMathMapping_4_8 method refreshSpeciesContextMappings.
/**
* Insert the method's description here.
* Creation date: (10/26/2006 11:47:26 AM)
* @exception cbit.vcell.parser.ExpressionException The exception description.
* @exception cbit.vcell.mapping.MappingException The exception description.
* @exception cbit.vcell.math.MathException The exception description.
*/
private void refreshSpeciesContextMappings() throws cbit.vcell.parser.ExpressionException, MappingException, cbit.vcell.math.MathException {
//
// create a SpeciesContextMapping for each speciesContextSpec.
//
// set initialExpression from SpeciesContextSpec.
// set diffusing5
// set variable (only if "Constant" or "Function", else leave it as null)-----why commented?
//
//
// have to put geometric paras into mathsymbolmapping, since species initial condition needs the volume size symbol.
// and the parameters later on were added into contants or functions in refreshMathDescription()
//
StructureMapping[] structureMappings = getSimulationContext().getGeometryContext().getStructureMappings();
for (int i = 0; i < structureMappings.length; i++) {
StructureMapping sm = structureMappings[i];
StructureMapping.StructureMappingParameter parm = sm.getParameterFromRole(StructureMapping.ROLE_Size);
getMathSymbol(parm, sm);
}
getSpeciesContextMappingList().removeAllElements();
SpeciesContextSpec[] speciesContextSpecs = getSimulationContext().getReactionContext().getSpeciesContextSpecs();
for (int i = 0; i < speciesContextSpecs.length; i++) {
SpeciesContextSpec scs = speciesContextSpecs[i];
SpeciesContextMapping scm = new SpeciesContextMapping(scs.getSpeciesContext());
scm.setPDERequired(getSimulationContext().isPDERequired(scs.getSpeciesContext()));
scm.setHasEventAssignment(getSimulationContext().hasEventAssignment(scs.getSpeciesContext()));
scm.setHasHybridReaction(false);
for (ReactionSpec reactionSpec : getSimulationContext().getReactionContext().getReactionSpecs()) {
if (!reactionSpec.isExcluded() && reactionSpec.hasHybrid(getSimulationContext(), scs.getSpeciesContext())) {
scm.setHasHybridReaction(true);
}
}
// scm.setAdvecting(isAdvectionRequired(scs.getSpeciesContext()));
if (scs.isConstant()) {
SpeciesContextSpec.SpeciesContextSpecParameter initCountParm = scs.getInitialCountParameter();
SpeciesContextSpec.SpeciesContextSpecParameter initConcParm = scs.getInitialConcentrationParameter();
Expression initCondInCount = null;
// initial condition is concentration
if (initConcParm != null && initConcParm.getExpression() != null) {
initCondInCount = getExpressionConcToAmt(new Expression(initConcParm, getNameScope()), speciesContextSpecs[i].getSpeciesContext());
} else {
initCondInCount = new Expression(initCountParm, getNameScope());
}
// initCondInCount.bindExpression(this);
initCondInCount = getSubstitutedExpr(initCondInCount, true, true);
scm.setDependencyExpression(initCondInCount);
}
//
// test if participant in fast reaction step, request elimination if possible
//
scm.setFastParticipant(false);
ReactionSpec[] reactionSpecs = getSimulationContext().getReactionContext().getReactionSpecs();
for (int j = 0; j < reactionSpecs.length; j++) {
ReactionSpec reactionSpec = reactionSpecs[j];
if (reactionSpec.isExcluded()) {
continue;
}
ReactionStep rs = reactionSpec.getReactionStep();
if (rs instanceof SimpleReaction && rs.countNumReactionParticipants(scs.getSpeciesContext()) > 0) {
if (reactionSpec.isFast()) {
scm.setFastParticipant(true);
}
}
}
getSpeciesContextMappingList().addElement(scm);
}
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class StructureAnalyzer method refreshFastMatrices.
/**
* This method was created in VisualAge.
*/
private void refreshFastMatrices() throws Exception {
// System.out.println("StructureAnalyzer.refreshFastMatrices()");
//
// update scheme matrix for fast system
//
fastSchemeMatrix = new RationalNumberMatrix(fastSpeciesContextMappings.length, fastReactionSteps.length);
for (int i = 0; i < fastSpeciesContextMappings.length; i++) {
for (int j = 0; j < fastReactionSteps.length; j++) {
fastSchemeMatrix.set_elem(i, j, fastReactionSteps[j].getStoichiometry(fastSpeciesContextMappings[i].getSpeciesContext()));
}
}
//
for (int i = 0; i < fastSpeciesContextMappings.length; i++) {
SpeciesContextMapping scm = fastSpeciesContextMappings[i];
SpeciesContext sc = scm.getSpeciesContext();
//
// collect fast rate expression
//
Expression exp = new Expression(0.0);
for (int j = 0; j < fastReactionSteps.length; j++) {
int stoichiometry = fastReactionSteps[j].getStoichiometry(sc);
ReactionSpec reactionSpec = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpec(fastReactionSteps[j]);
if (stoichiometry != 0) {
if (!reactionSpec.isFast()) {
throw new Exception("expected only fast rates");
}
if (reactionSpec.isExcluded()) {
throw new Exception("expected only included rates");
}
ReactionParticipant[] rps = fastReactionSteps[j].getReactionParticipants();
ReactionParticipant rp0 = null;
for (ReactionParticipant rp : rps) {
if (rp.getSpeciesContext() == sc) {
rp0 = rp;
break;
}
}
//
if (rp0 != null) {
Structure structure = fastReactionSteps[j].getStructure();
Expression fastRateExpression = getReactionRateExpression(fastReactionSteps[j], rp0).renameBoundSymbols(mathMapping_4_8.getNameScope());
if ((structure instanceof Membrane) && (rp0.getStructure() != structure)) {
Membrane membrane = (Membrane) structure;
MembraneMapping membraneMapping = (MembraneMapping) mathMapping_4_8.getSimulationContext().getGeometryContext().getStructureMapping(membrane);
Expression fluxCorrection = new Expression(mathMapping_4_8.getFluxCorrectionParameter(membraneMapping, (Feature) rp0.getStructure()), mathMapping_4_8.getNameScope());
exp = Expression.add(exp, Expression.mult(fluxCorrection, fastRateExpression));
} else {
exp = Expression.add(exp, new Expression(fastRateExpression));
}
}
}
}
// exp.bindExpression(mathMapping);
scm.setFastRate(exp.flatten());
}
// System.out.println("StructureAnalyzer.refreshFastMatrices(), scheme matrix:");
// fastSchemeMatrix.show();
//
// update null space matrix
//
fastNullSpaceMatrix = fastSchemeMatrix.findNullSpace();
// if (fastNullSpaceMatrix==null){
// System.out.println("fast system has full rank");
// }else{
// System.out.println("StructureAnalyzer.refreshFastMatrices(), nullSpace matrix:");
// fastNullSpaceMatrix.show();
// }
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectDescription.
private String getSourceObjectDescription(VCDocument vcDocument, Issue issue) {
if (vcDocument instanceof BioModel) {
Object object = issue.getSource();
{
DecoratedIssueSource dis = BeanUtils.downcast(DecoratedIssueSource.class, object);
if (dis != null) {
return dis.getSourcePath();
}
}
String description = "";
if (object instanceof SymbolTableEntry) {
description = ((SymbolTableEntry) object).getName();
} else if (object instanceof ReactionStep) {
description = ((ReactionStep) object).getName();
} else if (object instanceof ReactionRule) {
description = ((ReactionRule) object).getName();
} else if (object instanceof SpeciesPattern) {
// Object parent = issue.getIssueContext().getContextObject();
// if (parent instanceof SpeciesContext){
// description = ((SpeciesContext)parent).getName();
// }
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// description = thing.getName();
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) object).toString());
description = ((SpeciesPattern) object).toString();
// }
} else if (object instanceof MolecularType) {
description = ((MolecularType) object).getName();
} else if (object instanceof MolecularComponent) {
description = ((MolecularComponent) object).getName();
} else if (object instanceof ComponentStateDefinition) {
description = ((ComponentStateDefinition) object).getName();
} else if (object instanceof Structure) {
description = ((Structure) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = ((Geometry) object).getName();
} else if (object instanceof StructureMapping) {
description = ((StructureMapping) object).getStructure().getName();
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof UnmappedGeometryClass) {
description = ((UnmappedGeometryClass) object).getGeometryClass().getName();
} else if (object instanceof MicroscopeMeasurement) {
description = ((MicroscopeMeasurement) object).getName();
} else if (object instanceof SpatialObject) {
description = ((SpatialObject) object).getName();
} else if (object instanceof SpatialProcess) {
description = ((SpatialProcess) object).getName();
} else if (object instanceof GeometryContext) {
description = "Geometry";
} else if (object instanceof ModelOptimizationSpec) {
description = ((ModelOptimizationSpec) object).getParameterEstimationTask().getName();
} else if (object instanceof Simulation) {
description = ((Simulation) object).getName();
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
description = scs.getSpeciesContext().getName();
} else if (object instanceof ReactionCombo) {
ReactionSpec rs = ((ReactionCombo) object).getReactionSpec();
description = rs.getReactionStep().getName();
} else if (object instanceof RbmModelContainer) {
// RbmModelContainer mc = (RbmModelContainer)object;
description = "Rules validator";
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
description = sc.getName();
} else if (object instanceof Model) {
Model m = (Model) object;
description = m.getName();
} else if (object instanceof BioEvent) {
return ((BioEvent) object).getName() + "";
} else if (object instanceof MathDescription) {
return ((MathDescription) object).getName() + "";
} else {
System.err.println("unknown object type in IssueTableModel.getSourceObjectDescription(): " + object.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
Object object = issue.getSource();
String description = "";
if (object instanceof Variable) {
description = ((Variable) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = "Geometry";
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof MathDescription) {
return "math";
} else if (object instanceof Simulation) {
return "Simulation " + ((Simulation) object).getName() + "";
}
return description;
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectDescription()");
return "";
}
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class ITextWriter method writeReactionContext.
// ReactionContext - SpeciesContextSpec: ignored boundary conditions.
protected void writeReactionContext(Section simContextSection, SimulationContext simContext) throws DocumentException {
ReactionContext rc = simContext.getReactionContext();
if (rc == null) {
return;
}
Section rcSection = null;
// add reaction specs
ReactionSpec[] reactionSpecs = rc.getReactionSpecs();
Table reactionSpecTable = null;
for (int i = 0; i < reactionSpecs.length; i++) {
if (i == 0) {
reactionSpecTable = getTable(4, 100, 1, 3, 3);
// reactionSpecTable.setTableFitsPage(true);
reactionSpecTable.addCell(createCell("Reaction Mapping", getBold(DEF_HEADER_FONT_SIZE), 4, 1, Element.ALIGN_CENTER, true));
reactionSpecTable.addCell(createHeaderCell("Name", getBold(), 1));
reactionSpecTable.addCell(createHeaderCell("Type", getBold(), 1));
reactionSpecTable.addCell(createHeaderCell("Enabled (T/F)", getBold(), 1));
reactionSpecTable.addCell(createHeaderCell("Fast (T/F)", getBold(), 1));
reactionSpecTable.endHeaders();
}
String reactionName = reactionSpecs[i].getReactionStep().getName();
String reactionType = reactionSpecs[i].getReactionStep().getDisplayType();
reactionSpecTable.addCell(createCell(reactionName, getFont()));
reactionSpecTable.addCell(createCell(reactionType, getFont()));
reactionSpecTable.addCell(createCell((reactionSpecs[i].isExcluded() ? " F " : " T "), getFont()));
reactionSpecTable.addCell(createCell((reactionSpecs[i].isFast() ? " T " : " F "), getFont()));
}
if (reactionSpecTable != null) {
rcSection = simContextSection.addSection("Reaction Mapping For " + simContext.getName(), simContextSection.numberDepth() + 1);
rcSection.add(reactionSpecTable);
}
// add species context specs
SpeciesContextSpec[] speciesContSpecs = rc.getSpeciesContextSpecs();
Table speciesSpecTable = null;
int[] widths = { 2, 2, 4, 4, 1 };
for (int i = 0; i < speciesContSpecs.length; i++) {
if (i == 0) {
speciesSpecTable = getTable(5, 100, 1, 3, 3);
speciesSpecTable.addCell(createCell("Initial Conditions", getBold(DEF_HEADER_FONT_SIZE), 5, 1, Element.ALIGN_CENTER, true));
speciesSpecTable.addCell(createHeaderCell("Species", getBold(), 1));
speciesSpecTable.addCell(createHeaderCell("Structure", getBold(), 1));
speciesSpecTable.addCell(createHeaderCell("Initial Conc.", getBold(), 1));
speciesSpecTable.addCell(createHeaderCell("Diffusion Const.", getBold(), 1));
speciesSpecTable.addCell(createHeaderCell("Fixed (T/F)", getBold(), 1));
speciesSpecTable.endHeaders();
}
String speciesName = speciesContSpecs[i].getSpeciesContext().getSpecies().getCommonName();
String structName = speciesContSpecs[i].getSpeciesContext().getStructure().getName();
String diff = speciesContSpecs[i].getDiffusionParameter().getExpression().infix();
VCUnitDefinition diffUnit = speciesContSpecs[i].getDiffusionParameter().getUnitDefinition();
SpeciesContextSpecParameter initParam = speciesContSpecs[i].getInitialConditionParameter();
String initConc = initParam == null ? "" : initParam.getExpression().infix();
VCUnitDefinition initConcUnit = initParam == null ? null : initParam.getUnitDefinition();
speciesSpecTable.addCell(createCell(speciesName, getFont()));
speciesSpecTable.addCell(createCell(structName, getFont()));
speciesSpecTable.addCell(createCell(initConc + (initConcUnit == null ? "" : " " + initConcUnit.getSymbolUnicode()), getFont()));
speciesSpecTable.addCell(createCell(diff + (diffUnit == null ? "" : " " + diffUnit.getSymbolUnicode()), getFont()));
speciesSpecTable.addCell(createCell((speciesContSpecs[i].isConstant() ? " T " : " F "), getFont()));
}
if (speciesSpecTable != null) {
if (rcSection == null) {
rcSection = simContextSection.addSection("Reaction Mapping For " + simContext.getName(), simContextSection.numberDepth() + 1);
}
speciesSpecTable.setWidths(widths);
rcSection.add(speciesSpecTable);
}
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class BioModelEditor method setRightBottomPanelOnSelection.
@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
if (selections == null) {
return;
}
JComponent bottomComponent = rightBottomEmptyPanel;
int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
boolean bShowInDatabaseProperties = false;
boolean bShowPathway = false;
if (selections.length == 1) {
Object singleSelection = selections[0];
if (singleSelection instanceof ReactionStep) {
bottomComponent = getReactionPropertiesPanel();
} else if (singleSelection instanceof ReactionRule) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (singleSelection instanceof SpeciesContext) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (singleSelection instanceof MolecularType) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (singleSelection instanceof RbmObservable) {
bottomComponent = getObservablePropertiesPanel();
} else if (singleSelection instanceof Structure) {
bottomComponent = getStructurePropertiesPanel();
getStructurePropertiesPanel().setModel(bioModel.getModel());
} else if (singleSelection instanceof Parameter) {
bottomComponent = getParameterPropertiesPanel();
} else if (singleSelection instanceof SimulationContext) {
bottomComponent = getApplicationPropertiesPanel();
} else if (singleSelection instanceof ParameterEstimationTask) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
} else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
bottomComponent = getReactionParticipantPropertiesPanel();
} else if (singleSelection instanceof BioModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = bioModelMetaDataPanel;
} else if (singleSelection instanceof MathModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = mathModelMetaDataPanel;
} else if (singleSelection instanceof GeometryInfo) {
bShowInDatabaseProperties = true;
bottomComponent = geometryMetaDataPanel;
} else if (singleSelection instanceof SpeciesContextSpec) {
bottomComponent = getSpeciesContextSpecPanel();
} else if (singleSelection instanceof ReactionSpec) {
bottomComponent = getKineticsTypeTemplatePanel();
} else if (singleSelection instanceof ReactionRuleSpec) {
//
bottomComponent = getReactionRuleSpecPropertiesPanel();
} else if (singleSelection instanceof BioModelsNetModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = getBioModelsNetPropertiesPanel();
} else if (singleSelection instanceof Simulation) {
bottomComponent = getSimulationSummaryPanel();
} else if (singleSelection instanceof DataSymbol) {
bottomComponent = getDataSymbolsSpecPanel();
} else if (singleSelection instanceof BioEvent) {
bottomComponent = getEventPanel();
} else if (singleSelection instanceof SpatialObject) {
bottomComponent = getSpatialObjectPropertyPanel();
} else if (singleSelection instanceof SpatialProcess) {
bottomComponent = getSpatialProcessPropertyPanel();
} else if (singleSelection instanceof BioPaxObject) {
bottomComponent = bioPaxObjectPropertiesPanel;
} else if (singleSelection instanceof BioModel || singleSelection instanceof VCMetaData) {
bottomComponent = bioModelEditorAnnotationPanel;
} else if (singleSelection instanceof PathwayData) {
bShowPathway = true;
bottomComponent = getBioModelEditorPathwayPanel();
} else if (singleSelection instanceof Model) {
} else if (singleSelection instanceof RuleParticipantSignature) {
bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
} else if (singleSelection instanceof CSGObject) {
bottomComponent = csgObjectPropertiesPanel;
csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
} else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionPropertiesPanel();
} else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
bottomComponent = getStructurePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
bottomComponent = getObservablePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
bottomComponent = getApplicationsPropertiesPanel();
getApplicationsPropertiesPanel().setBioModel(bioModel);
} else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
}
}
}
if (bShowPathway) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) == bottomComponent) {
break;
}
}
String tabTitle = "Pathway Preview";
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
}
} else if (bShowInDatabaseProperties) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
break;
}
}
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
}
}
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
rightSplitPane.repaint();
}
if (rightBottomTabbedPane.getSelectedComponent() != bottomComponent) {
rightBottomTabbedPane.setSelectedComponent(bottomComponent);
}
}
Aggregations