use of org.vcell.util.Issue in project vcell by virtualcell.
the class ReactionSpec method gatherIssues.
/**
* Insert the method's description here.
* Creation date: (11/1/2005 10:06:04 AM)
* @param issueList java.util.Vector
*/
public void gatherIssues(IssueContext issueContext, List<Issue> issueList, ReactionContext rc) {
ReactionCombo r = new ReactionCombo(this, rc);
ReactionStep step = getReactionStep();
if (!isExcluded() && rc.getSimulationContext().isStoch() && (rc.getSimulationContext().getGeometry().getDimension() > 0)) {
boolean haveParticle = false;
boolean haveContinuous = false;
for (ReactionParticipant p : step.getReactionParticipants()) {
if (p instanceof Product || p instanceof Reactant) {
SpeciesContextSpec candidate = rc.getSpeciesContextSpec(p.getSpeciesContext());
if (candidate.isForceContinuous() && !candidate.isConstant()) {
haveParticle = true;
} else if (!candidate.isForceContinuous() && !candidate.isConstant()) {
haveContinuous = true;
}
}
}
if (haveParticle && haveContinuous) {
String msg = "Reaction " + step.getName() + " has both continuous and particle Participants.";
String tip = "Mass conservation for reactions of binding between discrete and continuous species is handled approximately. <br>" + "To avoid any algorithmic approximation, which may produce undesired results, the user is advised to indicate <br>" + "the continuous species in those reactions as modifiers (i.e. 'catalysts') in the physiology.";
issueList.add(new Issue(r, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_WARNING));
}
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class AbstractMathMapping method getIdentifierSubstitutions.
/**
* Substitutes appropriate variables for speciesContext bindings
*
* @return cbit.vcell.parser.Expression
* @param origExp cbit.vcell.parser.Expression
* @param structureMapping cbit.vcell.mapping.StructureMapping
*/
protected Expression getIdentifierSubstitutions(Expression origExp, VCUnitDefinition desiredExpUnitDef, GeometryClass geometryClass) throws ExpressionException, MappingException {
String[] symbols = origExp.getSymbols();
if (symbols == null) {
return origExp;
}
VCUnitDefinition expUnitDef = null;
try {
VCUnitEvaluator unitEvaluator = new VCUnitEvaluator(simContext.getModel().getUnitSystem());
expUnitDef = unitEvaluator.getUnitDefinition(origExp);
if (desiredExpUnitDef == null) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println("...........exp='" + expStr + "', desiredUnits are null");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[null], observed=[" + expUnitDef.getSymbol() + "]", Issue.SEVERITY_WARNING));
} else if (expUnitDef == null) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println("...........exp='" + expStr + "', evaluated Units are null");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + desiredExpUnitDef.getSymbol() + "], observed=[null]", Issue.SEVERITY_WARNING));
} else if (desiredExpUnitDef.isTBD()) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
// System.out.println("...........exp='"+expStr+"', desiredUnits are ["+desiredExpUnitDef.getSymbol()+"] and expression units are ["+expUnitDef.getSymbol()+"]");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + desiredExpUnitDef.getSymbol() + "], observed=[" + expUnitDef.getSymbol() + "] for exp = " + expStr, Issue.SEVERITY_WARNING));
} else if (!desiredExpUnitDef.isEquivalent(expUnitDef) && !expUnitDef.isTBD()) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
// System.out.println("...........exp='"+expStr+"', desiredUnits are ["+desiredExpUnitDef.getSymbol()+"] and expression units are ["+expUnitDef.getSymbol()+"]");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + desiredExpUnitDef.getSymbol() + "], observed=[" + expUnitDef.getSymbol() + "] for exp = " + expStr, Issue.SEVERITY_WARNING));
}
} catch (VCUnitException e) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println(".........exp='" + expStr + "' exception='" + e.getMessage() + "'");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + ((desiredExpUnitDef != null) ? (desiredExpUnitDef.getSymbol()) : ("null")) + "], exception=" + e.getMessage(), Issue.SEVERITY_WARNING));
} catch (ExpressionException e) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println(".........exp='" + expStr + "' exception='" + e.getMessage() + "'");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + ((desiredExpUnitDef != null) ? (desiredExpUnitDef.getSymbol()) : ("null")) + "], exception=" + e.getMessage(), Issue.SEVERITY_WARNING));
} catch (Exception e) {
e.printStackTrace(System.out);
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + ((desiredExpUnitDef != null) ? (desiredExpUnitDef.getSymbol()) : ("null")) + "], exception=" + e.getMessage(), Issue.SEVERITY_WARNING));
}
Expression newExp = new Expression(origExp);
//
// flatten user-defined functions
//
FunctionInvocation[] functionInvocations = newExp.getFunctionInvocations(new FunctionFilter() {
@Override
public boolean accept(String functionName, FunctionType functionType) {
return functionType == FunctionType.USERDEFINED;
}
});
for (FunctionInvocation functionInvocation : functionInvocations) {
if (functionInvocation.getSymbolTableFunctionEntry() instanceof Model.ModelFunction) {
ModelFunction modelFunction = (ModelFunction) functionInvocation.getSymbolTableFunctionEntry();
newExp.substituteInPlace(functionInvocation.getFunctionExpression(), modelFunction.getFlattenedExpression(functionInvocation));
}
}
//
// then substitute Math symbols for Biological symbols.
//
newExp.bindExpression(null);
for (int i = 0; i < symbols.length; i++) {
SymbolTableEntry ste = origExp.getSymbolBinding(symbols[i]);
if (ste == null) {
throw new ExpressionBindingException("symbol '" + symbols[i] + "' not bound");
// ste = simContext.getGeometryContext().getModel().getSpeciesContext(symbols[i]);
}
if (ste != null) {
String newName = getMathSymbol(ste, geometryClass);
if (!newName.equals(symbols[i])) {
newExp.substituteInPlace(new Expression(symbols[i]), new Expression(newName));
}
}
}
return newExp;
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class IssueManagerContainer method hasErrorIssues.
public boolean hasErrorIssues(Displayable owner, MolecularType mt) {
if (issueManager == null) {
return false;
}
if (owner == null) {
return false;
}
List<Issue> allIssueList = issueManager.getIssueList();
for (Issue issue : allIssueList) {
if (issue.getSeverity() != Issue.Severity.ERROR) {
continue;
}
Object source = issue.getSource();
Object detailedSource = issue.getDetailedSource();
if (mt != null & source == owner && detailedSource == mt) {
return true;
}
}
return false;
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class IssueManagerContainer method hasErrorIssues.
public boolean hasErrorIssues(Displayable owner, MolecularComponentPattern mcp, MolecularComponent mc) {
if (issueManager == null) {
return false;
}
if (owner == null) {
return false;
}
List<Issue> allIssueList = issueManager.getIssueList();
for (Issue issue : allIssueList) {
if (issue.getSeverity() != Issue.Severity.ERROR) {
continue;
}
Object source = issue.getSource();
Object detailedSource = issue.getDetailedSource();
if (mcp != null && source == owner && detailedSource == mcp) {
return true;
} else if (mc != null & source == owner && detailedSource == mc) {
return true;
}
}
return false;
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class IssueManagerContainer method hasErrorIssues.
public boolean hasErrorIssues(Displayable owner, ComponentStatePattern csp, ComponentStateDefinition csd) {
if (issueManager == null) {
return false;
}
if (owner == null) {
return false;
}
List<Issue> allIssueList = issueManager.getIssueList();
for (Issue issue : allIssueList) {
if (issue.getSeverity() != Issue.Severity.ERROR) {
continue;
}
Object source = issue.getSource();
Object detailedSource = issue.getDetailedSource();
if (csp != null && source == owner && detailedSource == csp) {
return true;
} else if (csd != null & source == owner && detailedSource == csd) {
return true;
}
}
return false;
}
Aggregations