use of org.vcell.util.Issue in project vcell by virtualcell.
the class DocumentValidUtil method checkIssuesForErrors.
public static void checkIssuesForErrors(BioModel bioModel) {
Vector<Issue> issueList = new Vector<Issue>();
IssueContext issueContext = new IssueContext();
bioModel.gatherIssues(issueContext, issueList);
checkIssuesForErrors(issueList);
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class Workflow method reportIssues.
public void reportIssues(ArrayList<Issue> issues, Severity minSeverity, boolean bExceptionOnError) {
boolean bAbort = false;
StringBuffer errorBuffer = new StringBuffer();
for (Issue issue : issues) {
if (issue.getSeverity().ordinal() >= minSeverity.ordinal()) {
System.out.println("ISSUE: " + issue.toString());
}
if (issue.getSeverity() == Issue.SEVERITY_ERROR) {
bAbort = true;
errorBuffer.append(issue.getCategory() + ":" + issue.getMessage() + " \n");
}
}
if (bAbort && bExceptionOnError) {
throw new RuntimeException(errorBuffer.toString());
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class MolecularType method gatherIssues.
@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
issueContext = issueContext.newChildContext(ContextType.MolecularType, this);
if (name == null) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Name of " + getDisplayType() + " is null", Issue.Severity.ERROR));
} else if (name.equals("")) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Name of " + getDisplayType() + " is empty", Issue.Severity.ERROR));
} else if (!name.equals(TokenMangler.fixTokenStrict(name))) {
String msg = "Name of " + getDisplayType() + " is invalid";
String tip = "Valid names must start with a letter or underscore and contain only letters, numbers and the '_' character (underscore)";
issueList.add(new Issue(this, this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.ERROR));
}
if (componentList == null) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, getDisplayType() + " '" + getDisplayName() + MolecularComponent.typeName + "' List is null", Issue.Severity.ERROR));
} else if (componentList.isEmpty()) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, getDisplayType() + " '" + getDisplayName() + MolecularComponent.typeName + "' List is empty", Issue.Severity.INFO));
} else {
for (MolecularComponent mc : componentList) {
MolecularComponent[] mcList = getMolecularComponents(mc.getName());
if (mcList.length > 1) {
String msg = "Duplicate " + mc.getDisplayType() + " '" + mc.getDisplayName() + "' in the definition of the " + MolecularType.typeName + ".";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
}
String mcName = mc.getName();
if (!mcName.equals(TokenMangler.fixTokenStrict(mcName))) {
String msg = "Name of " + MolecularComponent.typeName + " " + mcName + " is invalid";
String tip = "Valid names must start with a letter or underscore and contain only letters, numbers and the '_' character (underscore)";
issueList.add(new Issue(this, mc, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.ERROR));
}
for (ComponentStateDefinition csd : mc.getComponentStateDefinitions()) {
String csdName = csd.getName();
if (!csdName.equals(TokenMangler.fixTokenStrict(csdName))) {
String msg = "Name of " + ComponentStateDefinition.typeName + " " + csdName + " is invalid";
String tip = "Valid names must start with a letter or underscore and contain only letters, numbers and the '_' character (underscore)";
issueList.add(new Issue(this, csd, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.ERROR));
}
}
}
for (MolecularComponent entity : componentList) {
entity.gatherIssues(issueContext, issueList);
}
}
if (!isAnchorAll() && getAnchors().isEmpty()) {
String msg = getDisplayType() + " " + getDisplayName() + " must be anchored to at least one Structure.";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
}
}
use of org.vcell.util.Issue 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 org.vcell.util.Issue in project vcell by virtualcell.
the class SimulationContext method gatherIssueForMathOverride.
@Override
public Issue gatherIssueForMathOverride(IssueContext issueContext, Simulation simulation, String overriddenConstantName) {
issueContext = issueContext.newChildContext(ContextType.SimContext, this);
ReservedSymbol reservedSymbol = getModel().getReservedSymbolByName(overriddenConstantName);
if (reservedSymbol != null && reservedSymbol.getRole() == ReservedSymbolRole.KMOLE) {
String msg = "overriding unit factor KMOLE is no longer supported, unit conversion has been completely redesigned";
return new Issue(simulation, issueContext, Issue.IssueCategory.Simulation_Override_NotSupported, msg, Severity.ERROR);
}
if (reservedSymbol != null && reservedSymbol.getRole() == ReservedSymbolRole.N_PMOLE) {
String msg = "overriding unit factor N_PMOLE is no longer supported, unit conversion has been completely redesigned";
return new Issue(simulation, issueContext, Issue.IssueCategory.Simulation_Override_NotSupported, msg, Severity.ERROR);
}
return null;
}
Aggregations