use of cbit.vcell.model.ReactionRule in project vcell by virtualcell.
the class BioPaxRelationshipTableModel method refreshData.
private void refreshData() {
ArrayList<BioPaxRelationshipTableRow> entityRows = new ArrayList<BioPaxRelationshipTableRow>();
if (bioModel != null) {
HashSet<RelationshipObject> relationshipObjects = null;
if (bioPaxObject != null) {
relationshipObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioPaxObject);
}
List<BioPaxRelationshipTableRow> allEntityRows = new ArrayList<BioPaxRelationshipTableRow>();
if (bioPaxObject instanceof Conversion) {
for (ReactionStep rs : bioModel.getModel().getReactionSteps()) {
BioPaxRelationshipTableRow entityRow = new BioPaxRelationshipTableRow(rs);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioModelEntityObject() == rs) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allEntityRows.add(entityRow);
}
}
for (ReactionRule rr : bioModel.getModel().getRbmModelContainer().getReactionRuleList()) {
BioPaxRelationshipTableRow entityRow = new BioPaxRelationshipTableRow(rr);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioModelEntityObject() == rr) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allEntityRows.add(entityRow);
}
}
} else if (bioPaxObject instanceof PhysicalEntity) {
for (SpeciesContext rs : bioModel.getModel().getSpeciesContexts()) {
BioPaxRelationshipTableRow entityRow = new BioPaxRelationshipTableRow(rs);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioModelEntityObject() == rs) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allEntityRows.add(entityRow);
}
}
}
if (searchText == null || searchText.length() == 0) {
entityRows.addAll(allEntityRows);
} else {
for (BioPaxRelationshipTableRow rs : allEntityRows) {
BioModelEntityObject object = rs.getBioModelEntityObject();
String lowerCaseSearchText = searchText.toLowerCase();
if (object.getName().toLowerCase().contains(lowerCaseSearchText) || object.getTypeLabel().toLowerCase().contains(lowerCaseSearchText)) {
entityRows.add(rs);
}
}
}
}
setData(entityRows);
GuiUtils.flexResizeTableColumns(ownerTable);
}
use of cbit.vcell.model.ReactionRule in project vcell by virtualcell.
the class SimulationContext method gatherIssues.
public void gatherIssues(IssueContext issueContext, List<Issue> issueVector, boolean bIgnoreMathDescription) {
// issueContext = issueContext.newChildContext(ContextType.SimContext, this);
if (applicationType.equals(Application.RULE_BASED_STOCHASTIC)) {
for (ReactionRuleSpec rrs : getReactionContext().getReactionRuleSpecs()) {
if (rrs.isExcluded()) {
continue;
}
ReactionRule rr = rrs.getReactionRule();
if (rr.getReactantPatterns().size() > 2) {
String message = "NFSim doesn't support more than 2 reactants within a reaction rule.";
issueVector.add(new Issue(rr, issueContext, IssueCategory.Identifiers, message, Issue.Severity.WARNING));
}
if (rr.isReversible() && rr.getProductPatterns().size() > 2) {
String message = "NFSim doesn't support more than 2 products within a reversible reaction rule.";
issueVector.add(new Issue(rr, issueContext, IssueCategory.Identifiers, message, Issue.Severity.WARNING));
}
}
for (ReactionSpec rrs : getReactionContext().getReactionSpecs()) {
if (rrs.isExcluded()) {
continue;
}
ReactionStep rs = rrs.getReactionStep();
if (rs.getNumReactants() > 2) {
String message = "NFSim doesn't support more than 2 reactants within a reaction step.";
issueVector.add(new Issue(rs, issueContext, IssueCategory.Identifiers, message, Issue.Severity.WARNING));
}
if (rs.isReversible() && rs.getNumProducts() > 2) {
String message = "NFSim doesn't support more than 2 products within a reversible reaction step.";
issueVector.add(new Issue(rs, issueContext, IssueCategory.Identifiers, message, Issue.Severity.WARNING));
}
}
// we give warning when we have plain reactions with participants with patterns;
// making rules from these may result in inconsistent interpretation for the constant rates
boolean isParticipantWithPattern = false;
for (ReactionSpec rrs : getReactionContext().getReactionSpecs()) {
if (rrs.isExcluded()) {
continue;
}
ReactionStep rs = rrs.getReactionStep();
for (Reactant r : rs.getReactants()) {
if (r.getSpeciesContext().hasSpeciesPattern()) {
isParticipantWithPattern = true;
break;
}
}
if (isParticipantWithPattern) {
break;
}
for (Product p : rs.getProducts()) {
if (p.getSpeciesContext().hasSpeciesPattern()) {
isParticipantWithPattern = true;
break;
}
}
if (isParticipantWithPattern) {
break;
}
}
if (isParticipantWithPattern) {
String message = SimulationContext.rateWarning2;
String tooltip = SimulationContext.rateWarning;
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, message, tooltip, Issue.Severity.WARNING));
}
for (Structure struct : getModel().getStructures()) {
String name = struct.getName();
if (!name.equals(TokenMangler.fixTokenStrict(name))) {
String msg = "'" + name + "' not legal identifier for rule-based stochastic applications, try '" + TokenMangler.fixTokenStrict(name) + "'.";
issueVector.add(new Issue(struct, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
}
}
}
if (fieldBioEvents != null) {
for (BioEvent bioEvent : fieldBioEvents) {
bioEvent.gatherIssues(issueContext, issueVector);
}
}
if (spatialObjects != null) {
for (SpatialObject spatialObject : spatialObjects) {
spatialObject.gatherIssues(issueContext, issueVector);
}
}
if (spatialProcesses != null) {
for (SpatialProcess spatialProcess : spatialProcesses) {
spatialProcess.gatherIssues(issueContext, issueVector);
}
}
if (applicationType.equals(Application.NETWORK_DETERMINISTIC) && getModel().getRbmModelContainer().getMolecularTypeList().size() > 0) {
// we're going to use network transformer to flatten (or we already did)
if (isInsufficientIterations()) {
issueVector.add(new Issue(this, issueContext, IssueCategory.RbmNetworkConstraintsBad, IssueInsufficientIterations, Issue.Severity.WARNING));
}
if (isInsufficientMaxMolecules()) {
issueVector.add(new Issue(this, issueContext, IssueCategory.RbmNetworkConstraintsBad, IssueInsufficientMolecules, Issue.Severity.WARNING));
}
}
getReactionContext().gatherIssues(issueContext, issueVector);
getGeometryContext().gatherIssues(issueContext, issueVector);
if (fieldAnalysisTasks != null) {
for (AnalysisTask analysisTask : fieldAnalysisTasks) {
analysisTask.gatherIssues(issueContext, issueVector);
}
}
getOutputFunctionContext().gatherIssues(issueContext, issueVector);
getMicroscopeMeasurement().gatherIssues(issueContext, issueVector);
if (getMathDescription() != null && !bIgnoreMathDescription) {
getMathDescription().gatherIssues(issueContext, issueVector);
}
if (networkConstraints == null) {
// issueVector.add(new Issue(this, issueContext, IssueCategory.RbmNetworkConstraintsBad, "Network Constraints is null", Issue.Severity.ERROR));
} else {
networkConstraints.gatherIssues(issueContext, issueVector);
}
}
use of cbit.vcell.model.ReactionRule in project vcell by virtualcell.
the class SpeciesPatternRoundShape method paintCompartment.
public void paintCompartment(Graphics g) {
Color structureColor = Color.black;
Structure structure = null;
if (owner instanceof ReactionRule && !speciesShapes.isEmpty()) {
ReactionRule rr = (ReactionRule) owner;
ReactantPattern rp = rr.getReactantPattern(sp);
ProductPattern pp = rr.getProductPattern(sp);
if (rp != null) {
structure = rp.getStructure();
} else if (pp != null) {
structure = pp.getStructure();
} else {
structure = ((ReactionRule) owner).getStructure();
}
} else if (owner instanceof SpeciesContext && ((SpeciesContext) owner).hasSpeciesPattern()) {
structure = ((SpeciesContext) owner).getStructure();
structureColor = Color.gray;
} else if (owner instanceof RbmObservable && !speciesShapes.isEmpty()) {
structure = ((RbmObservable) owner).getStructure();
} else {
// other things don't have structure
return;
}
if (structure == null) {
return;
}
// don't have a real structure, so we show them structureless (for now)
if (structure.getName() == null) {
return;
}
Graphics2D g2 = (Graphics2D) g;
Color colorOld = g2.getColor();
Paint paintOld = g2.getPaint();
Font fontOld = g2.getFont();
Font font;
// width of compartment shape, adjusted continuously based on zoom factor
int w;
String name = structure.getName();
int z = shapePanel.getZoomFactor();
if (z > -3) {
font = fontOld.deriveFont(Font.BOLD);
g.setFont(font);
w = 46 + 3 * z;
name = buildCompartmentName(g, name, "..", w);
} else if (z < LargeShapeCanvas.SmallestZoomFactorWithText) {
font = fontOld.deriveFont(fontOld.getSize2D() * 0.8f);
g.setFont(font);
w = 20;
name = buildCompartmentName(g, name, ".", w);
} else {
font = fontOld;
g.setFont(font);
w = 44 + 3 * z;
name = buildCompartmentName(g, name, "..", w);
}
// a bit darker for border
Color darker = Color.gray;
Rectangle2D border = new Rectangle2D.Double(xPos - 9, yPos - 4, w, 58);
g2.setColor(darker);
g2.draw(border);
Color lighter = new Color(224, 224, 224);
Rectangle2D filling = new Rectangle2D.Double(xPos - 9, yPos - 3, w, 57);
g2.setPaint(lighter);
g2.fill(filling);
g.setColor(structureColor);
g2.drawString(name, xPos - 4, yPos + 48);
g2.setFont(fontOld);
g2.setPaint(paintOld);
g2.setColor(colorOld);
}
use of cbit.vcell.model.ReactionRule in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectPathDescription.
private String getSourceObjectPathDescription(VCDocument vcDocument, Issue issue) {
VCAssert.assertValid(issue);
Object source = issue.getSource();
{
IssueOrigin io = BeanUtils.downcast(IssueOrigin.class, source);
if (io != null) {
return io.getDescription();
}
}
if (vcDocument instanceof BioModel) {
BioModel bioModel = (BioModel) vcDocument;
String description = "";
if (source instanceof SymbolTableEntry) {
if (source instanceof SpeciesContext) {
description = "Model / Species";
} else if (source instanceof RbmObservable) {
description = "Model / Observables";
} else {
description = ((SymbolTableEntry) source).getNameScope().getPathDescription();
}
} else if (source instanceof MolecularType) {
description = "Model / Molecules";
} else if (source instanceof ReactionStep) {
ReactionStep reactionStep = (ReactionStep) source;
description = ((ReactionNameScope) reactionStep.getNameScope()).getPathDescription();
} else if (source instanceof ReactionRule) {
ReactionRule reactionRule = (ReactionRule) source;
description = ((ReactionRuleNameScope) reactionRule.getNameScope()).getPathDescription();
} else if (source instanceof SpeciesPattern) {
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// description = "Model / Species";
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = ((ReactionRuleNameScope)thing.getNameScope()).getPathDescription();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// description = "Model / Observables";
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) source).toString());
description = ((SpeciesPattern) source).toString();
// }
} else if (source instanceof Structure) {
Structure structure = (Structure) source;
description = "Model / " + structure.getTypeName() + "(" + structure.getName() + ")";
} else if (source instanceof StructureMapping) {
StructureMapping structureMapping = (StructureMapping) source;
description = ((StructureMappingNameScope) structureMapping.getNameScope()).getPathDescription();
} else if (source instanceof OutputFunctionIssueSource) {
SimulationContext simulationContext = (SimulationContext) ((OutputFunctionIssueSource) source).getOutputFunctionContext().getSimulationOwner();
description = "App(" + simulationContext.getName() + ") / " + "Simulations" + " / " + "Output Functions";
} else if (source instanceof Simulation) {
Simulation simulation = (Simulation) source;
try {
SimulationContext simulationContext = bioModel.getSimulationContext(simulation);
description = "App(" + simulationContext.getName() + ") / Simulations";
} catch (ObjectNotFoundException e) {
e.printStackTrace();
description = "App(" + "unknown" + ") / Simulations";
}
} else if (source instanceof UnmappedGeometryClass) {
UnmappedGeometryClass unmappedGC = (UnmappedGeometryClass) source;
description = "App(" + unmappedGC.getSimulationContext().getName() + ") / Subdomain(" + unmappedGC.getGeometryClass().getName() + ")";
} else if (source instanceof GeometryContext) {
description = "App(" + ((GeometryContext) source).getSimulationContext().getName() + ")";
} else if (source instanceof ModelOptimizationSpec) {
description = "App(" + ((ModelOptimizationSpec) source).getSimulationContext().getName() + ") / Parameter Estimation";
} else if (source instanceof MicroscopeMeasurement) {
description = "App(" + ((MicroscopeMeasurement) source).getSimulationContext().getName() + ") / Microscope Measurements";
} else if (source instanceof SpatialObject) {
description = "App(" + ((SpatialObject) source).getSimulationContext().getName() + ") / Spatial Objects";
} else if (source instanceof SpatialProcess) {
description = "App(" + ((SpatialProcess) source).getSimulationContext().getName() + ") / Spatial Processes";
} else if (source instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) source;
description = "App(" + scs.getSimulationContext().getName() + ") / Specifications / Species";
} else if (source instanceof ReactionCombo) {
ReactionCombo rc = (ReactionCombo) source;
description = "App(" + rc.getReactionContext().getSimulationContext().getName() + ") / Specifications / Reactions";
} else if (source instanceof RbmModelContainer) {
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmMolecularTypesTableBad:
description = "Model / " + MolecularType.typeName + "s";
break;
case RbmReactionRulesTableBad:
description = "Model / Reactions";
break;
case RbmObservablesTableBad:
description = "Model / Observables";
break;
case RbmNetworkConstraintsBad:
description = "Network Constrains";
break;
default:
description = "Model";
break;
}
} else if (source instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) source;
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmNetworkConstraintsBad:
description = "Specifications / Network";
break;
default:
description = "Application";
break;
}
} else if (source instanceof Model) {
description = "Model";
} else if (source instanceof BioEvent) {
return "Protocols / Events";
} else if (source instanceof MathDescription) {
return "Math Description";
} else {
System.err.println("unknown source type in IssueTableModel.getSourceObjectPathDescription(): " + source.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
if (source instanceof Geometry) {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_GEOMETRY;
} else if (source instanceof OutputFunctionIssueSource) {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_OUTPUTFUNCTIONS;
} else if (source instanceof Simulation) {
return "Simulation(" + ((Simulation) source).getName() + ")";
} else {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_VCML;
}
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectPathDescription()");
return "";
}
}
use of cbit.vcell.model.ReactionRule 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 "";
}
}
Aggregations