Search in sources :

Example 51 with Issue

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));
        }
    }
}
Also used : Issue(org.vcell.util.Issue) ReactionStep(cbit.vcell.model.ReactionStep) Product(cbit.vcell.model.Product) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Reactant(cbit.vcell.model.Reactant)

Example 52 with Issue

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;
}
Also used : FunctionInvocation(cbit.vcell.parser.FunctionInvocation) Issue(org.vcell.util.Issue) ModelFunction(cbit.vcell.model.Model.ModelFunction) FunctionType(cbit.vcell.parser.ASTFuncNode.FunctionType) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ExpressionException(cbit.vcell.parser.ExpressionException) VCUnitException(cbit.vcell.units.VCUnitException) PropertyVetoException(java.beans.PropertyVetoException) MatrixException(cbit.vcell.matrix.MatrixException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ModelException(cbit.vcell.model.ModelException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) VCUnitException(cbit.vcell.units.VCUnitException) VCUnitEvaluator(cbit.vcell.parser.VCUnitEvaluator) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) FunctionFilter(cbit.vcell.parser.Expression.FunctionFilter) Expression(cbit.vcell.parser.Expression)

Example 53 with Issue

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;
}
Also used : Issue(org.vcell.util.Issue)

Example 54 with Issue

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;
}
Also used : Issue(org.vcell.util.Issue)

Example 55 with Issue

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;
}
Also used : Issue(org.vcell.util.Issue)

Aggregations

Issue (org.vcell.util.Issue)88 ArrayList (java.util.ArrayList)18 IssueContext (org.vcell.util.IssueContext)14 Expression (cbit.vcell.parser.Expression)13 ExpressionException (cbit.vcell.parser.ExpressionException)13 PropertyVetoException (java.beans.PropertyVetoException)9 MolecularType (org.vcell.model.rbm.MolecularType)9 Structure (cbit.vcell.model.Structure)8 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)8 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)7 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)7 Model (cbit.vcell.model.Model)6 ModelParameter (cbit.vcell.model.Model.ModelParameter)6 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)6 BioModel (cbit.vcell.biomodel.BioModel)5 ModelException (cbit.vcell.model.ModelException)5 Product (cbit.vcell.model.Product)5 Reactant (cbit.vcell.model.Reactant)5 ReactionParticipant (cbit.vcell.model.ReactionParticipant)5 InteriorPoint (org.sbml.jsbml.ext.spatial.InteriorPoint)5