use of org.vcell.util.Displayable in project vcell by virtualcell.
the class SpeciesContext method findComponentUsage.
public void findComponentUsage(MolecularType mt, MolecularComponent mc, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
if (!hasSpeciesPattern()) {
return;
}
SpeciesPattern sp = getSpeciesPattern();
for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
if (mtp.getMolecularType() == mt) {
List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
for (MolecularComponentPattern mcp : componentPatterns) {
if (mcp.getMolecularComponent() == mc) {
// here all components are always in use
if (mcp.getBond() != null) {
// we only care about the components with a bond
String key = sp.getDisplayName();
key = getDisplayType() + getDisplayName() + key;
usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
}
}
}
}
}
}
use of org.vcell.util.Displayable in project vcell by virtualcell.
the class SpeciesContext method findStateUsage.
public void findStateUsage(MolecularType mt, MolecularComponent mc, ComponentStateDefinition csd, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
if (!hasSpeciesPattern()) {
return;
}
SpeciesPattern sp = getSpeciesPattern();
for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
if (mtp.getMolecularType() == mt) {
List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
for (MolecularComponentPattern mcp : componentPatterns) {
if (mcp.getMolecularComponent() == mc) {
// here some state is always in use if available
ComponentStatePattern csp = mcp.getComponentStatePattern();
if (csp == null) {
System.out.println("This component " + mc.getName() + " should have had some State specified.");
continue;
}
if ((csp.getComponentStateDefinition() == csd) && (mcp.getBond() != null)) {
// we only care if there's a bond
String key = sp.getDisplayName();
key = getDisplayType() + getDisplayName() + key;
usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
}
}
}
}
}
}
use of org.vcell.util.Displayable in project vcell by virtualcell.
the class Kinetics method gatherIssues.
/**
* Insert the method's description here.
* Creation date: (5/12/2004 2:53:13 PM)
*/
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
issueContext = issueContext.newChildContext(ContextType.ModelProcessDynamics, this);
//
for (int i = 0; fieldUnresolvedParameters != null && i < fieldUnresolvedParameters.length; i++) {
issueList.add(new Issue(fieldUnresolvedParameters[i], issueContext, IssueCategory.UnresolvedParameter, "Unresolved parameter '" + fieldUnresolvedParameters[i].getName() + "' in reaction '" + reactionStep.getName() + "'", Issue.SEVERITY_ERROR));
}
//
for (int i = 0; fieldKineticsParameters != null && i < fieldKineticsParameters.length; i++) {
if (fieldKineticsParameters[i].getRole() == ROLE_UserDefined) {
try {
if (!isReferenced(fieldKineticsParameters[i], 0)) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.KineticsUnreferencedParameter, "Unreferenced Kinetic Parameter '" + fieldKineticsParameters[i].getName() + "' in reaction '" + reactionStep.getName() + "'", Issue.SEVERITY_WARNING));
}
} catch (ExpressionException e) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.KineticsExpressionError, "error resolving expression " + e.getMessage(), Issue.SEVERITY_WARNING));
} catch (ModelException e) {
issueList.add(new Issue(getReactionStep(), issueContext, IssueCategory.CyclicDependency, "cyclic dependency in the parameter definitions", Issue.SEVERITY_ERROR));
}
}
}
//
if (fieldKineticsParameters != null) {
for (KineticsParameter kineticsParameter : fieldKineticsParameters) {
if (kineticsParameter.getExpression() == null) {
issueList.add(new Issue(kineticsParameter, issueContext, IssueCategory.KineticsExpressionMissing, "expression is missing", Issue.SEVERITY_INFO));
} else {
Expression exp = kineticsParameter.getExpression();
String[] symbols = exp.getSymbols();
String issueMessagePrefix = "Kinetic parameter '" + kineticsParameter.getName() + "' in reaction '" + getReactionStep().getName() + "' ";
if (symbols != null) {
for (int j = 0; j < symbols.length; j++) {
SymbolTableEntry ste = exp.getSymbolBinding(symbols[j]);
if (ste instanceof KineticsProxyParameter) {
ste = ((KineticsProxyParameter) ste).getTarget();
}
if (ste == null) {
issueList.add(new Issue(kineticsParameter, issueContext, IssueCategory.KineticsExpressionUndefinedSymbol, issueMessagePrefix + "references undefined symbol '" + symbols[j] + "'", Issue.SEVERITY_ERROR));
} else if (ste instanceof SpeciesContext) {
if (!getReactionStep().getModel().contains((SpeciesContext) ste)) {
issueList.add(new Issue(kineticsParameter, issueContext, IssueCategory.KineticsExpressionUndefinedSymbol, issueMessagePrefix + "references undefined species '" + symbols[j] + "'", Issue.SEVERITY_ERROR));
}
if (reactionStep.countNumReactionParticipants((SpeciesContext) ste) == 0) {
issueList.add(new Issue(kineticsParameter, issueContext, IssueCategory.KineticsExpressionNonParticipantSymbol, issueMessagePrefix + "references species context '" + symbols[j] + "', but it is not a reactant/product/catalyst of this reaction", Issue.SEVERITY_WARNING));
}
} else if (ste instanceof ModelParameter) {
if (!getReactionStep().getModel().contains((ModelParameter) ste)) {
issueList.add(new Issue(kineticsParameter, issueContext, IssueCategory.KineticsExpressionUndefinedSymbol, issueMessagePrefix + "references undefined global parameter '" + symbols[j] + "'", Issue.SEVERITY_ERROR));
}
}
}
}
}
}
// looking for local param which masks a global and issueing a warning
for (KineticsParameter kineticsParameter : fieldKineticsParameters) {
String name = kineticsParameter.getName();
SymbolTableEntry ste = getReactionStep().getNameScope().getExternalEntry(name, getReactionStep());
String steName;
if (ste != null) {
if (ste instanceof Displayable) {
steName = ((Displayable) ste).getDisplayType() + " " + ste.getName();
} else {
steName = ste.getClass().getSimpleName() + " " + ste.getName();
}
String msg = steName + " is overriden by a local parameter " + name + " in reaction " + getReactionStep().getName();
issueList.add(new Issue(kineticsParameter, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
}
}
}
try {
//
// determine unit consistency for each expression
//
ModelUnitSystem modelUnitSystem = getReactionStep().getModel().getUnitSystem();
VCUnitEvaluator unitEvaluator = new VCUnitEvaluator(modelUnitSystem);
for (int i = 0; i < fieldKineticsParameters.length; i++) {
try {
VCUnitDefinition paramUnitDef = fieldKineticsParameters[i].getUnitDefinition();
VCUnitDefinition expUnitDef = unitEvaluator.getUnitDefinition(fieldKineticsParameters[i].getExpression());
if (paramUnitDef == null) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.Units, "defined unit is null", Issue.SEVERITY_WARNING));
} else if (paramUnitDef.isTBD()) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.Units, "undefined unit " + modelUnitSystem.getInstance_TBD().getSymbol(), Issue.SEVERITY_WARNING));
} else if (expUnitDef == null) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.Units, "computed unit is null", Issue.SEVERITY_WARNING));
} else if (paramUnitDef.isTBD() || (!paramUnitDef.isEquivalent(expUnitDef) && !expUnitDef.isTBD())) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.Units, "inconsistent units, defined=[" + fieldKineticsParameters[i].getUnitDefinition().getSymbol() + "], computed=[" + expUnitDef.getSymbol() + "]", Issue.SEVERITY_WARNING));
}
} catch (VCUnitException e) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.Units, e.getMessage(), Issue.SEVERITY_WARNING));
} catch (ExpressionException e) {
issueList.add(new Issue(fieldKineticsParameters[i], issueContext, IssueCategory.Units, e.getMessage(), Issue.SEVERITY_WARNING));
}
}
} catch (Throwable e) {
issueList.add(new Issue(getReactionStep(), issueContext, IssueCategory.Units, "unexpected exception: " + e.getMessage(), Issue.SEVERITY_INFO));
}
//
for (int i = 0; i < fieldKineticsParameters.length; i++) {
RealInterval simpleBounds = bounds[fieldKineticsParameters[i].getRole()];
if (simpleBounds != null) {
String parmName = reactionStep.getNameScope().getName() + "." + fieldKineticsParameters[i].getName();
issueList.add(new SimpleBoundsIssue(fieldKineticsParameters[i], issueContext, simpleBounds, "parameter " + parmName + ": must be within " + simpleBounds.toString()));
}
}
}
use of org.vcell.util.Displayable in project vcell by virtualcell.
the class ComponentStateDefinition method dependenciesToHtml.
public String dependenciesToHtml(Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
String errMsg = "State '<b>" + getDisplayName() + "'</b> is already being used by:<br>";
final int MaxListSize = 7;
int count = 0;
for (String key : usedHere.keySet()) {
System.out.println(key);
if (count >= MaxListSize) {
errMsg += "<br> ... and more.";
break;
}
Pair<Displayable, SpeciesPattern> o = usedHere.get(key);
Displayable e = o.one;
SpeciesPattern sp = o.two;
errMsg += "<br> - " + e.getDisplayType().toLowerCase() + " <b>" + e.getDisplayName() + "</b>";
errMsg += ", " + sp.getDisplayType().toLowerCase() + " " + " <b>" + sp.getDisplayName() + "</b>";
count++;
}
return errMsg;
}
use of org.vcell.util.Displayable in project vcell by virtualcell.
the class MolecularComponent method dependenciesToHtml.
public String dependenciesToHtml(Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
String errMsg = typeName + " '<b>" + getDisplayName() + "'</b> is already being used by:<br>";
final int MaxListSize = 7;
int count = 0;
for (String key : usedHere.keySet()) {
System.out.println(key);
if (count >= MaxListSize) {
errMsg += "<br> ... and more.";
break;
}
Pair<Displayable, SpeciesPattern> o = usedHere.get(key);
Displayable e = o.one;
SpeciesPattern sp = o.two;
errMsg += "<br> - " + e.getDisplayType().toLowerCase() + " <b>" + e.getDisplayName() + "</b>";
errMsg += ", " + sp.getDisplayType().toLowerCase() + " " + " <b>" + sp.getDisplayName() + "</b>";
count++;
}
return errMsg;
}
Aggregations