Search in sources :

Example 71 with Issue

use of org.vcell.util.Issue in project vcell by virtualcell.

the class ReactionRule method checkReactantPatterns.

public void checkReactantPatterns(IssueContext issueContext, List<Issue> issueList) {
    issueContext = issueContext.newChildContext(ContextType.ReactionRule, this);
    int cnt = 0;
    // StringBuilder warning = new StringBuilder();
    for (ReactantPattern rp : reactantPatterns) {
        ++cnt;
        if (rp.getSpeciesPattern().getMolecularTypePatterns().size() == 0) {
            String msg = "Reactant " + cnt + " does not have any molecules.\n";
            // warning.append(msg);
            if (issueList != null) {
                issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
            }
        } else {
            rp.getSpeciesPattern().checkSpeciesPattern(issueContext, issueList);
            for (MolecularTypePattern mtpThis : rp.getSpeciesPattern().getMolecularTypePatterns()) {
                checkComponentStateConsistency(issueContext, issueList, mtpThis);
            }
        }
    }
// setReactantWarning(warning.length() == 0 ? null : warning.toString());
}
Also used : Issue(org.vcell.util.Issue) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 72 with Issue

use of org.vcell.util.Issue in project vcell by virtualcell.

the class ReactionRule method checkProductPatterns.

public void checkProductPatterns(IssueContext issueContext, List<Issue> issueList) {
    issueContext = issueContext.newChildContext(ContextType.ReactionRule, this);
    int reactantCnt = 0;
    for (ReactantPattern rp : reactantPatterns) {
        reactantCnt += rp.getSpeciesPattern().getMolecularTypePatterns().size();
    }
    int productCnt = 0;
    int cnt = 0;
    // StringBuilder warning = new StringBuilder();
    for (ProductPattern pp : productPatterns) {
        productCnt += pp.getSpeciesPattern().getMolecularTypePatterns().size();
        ++cnt;
        if (pp.getSpeciesPattern().getMolecularTypePatterns().size() == 0) {
            String msg = "Product " + cnt + " does not have any molecules.\n";
            // warning.append(msg);
            if (issueList != null) {
                issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
            }
        } else {
            pp.getSpeciesPattern().checkSpeciesPattern(issueContext, issueList);
            for (MolecularTypePattern mtpThis : pp.getSpeciesPattern().getMolecularTypePatterns()) {
                checkComponentStateConsistency(issueContext, issueList, mtpThis);
            }
        }
    }
    if (productCnt != reactantCnt) {
        String msg = "The number of molecules in products does not match the number of molecules in reactants.";
        // warning.append(msg);
        if (issueList != null) {
            issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_INFO));
        }
    }
// setProductWarning(warning.length() == 0 ? null : warning.toString());
}
Also used : Issue(org.vcell.util.Issue) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 73 with Issue

use of org.vcell.util.Issue in project vcell by virtualcell.

the class ReactionRule method checkComponentStateConsistency.

public void checkComponentStateConsistency(IssueContext issueContext, List<Issue> issueList, MolecularTypePattern mtpThis) {
    if (issueList == null) {
        // this may be called during parsing before the model is consistent
        return;
    }
    issueContext = issueContext.newChildContext(ContextType.ReactionRule, this);
    MolecularType mtThat = mtpThis.getMolecularType();
    for (MolecularComponentPattern mcpThis : mtpThis.getComponentPatternList()) {
        if (mcpThis.isImplied()) {
            continue;
        }
        ComponentStatePattern cspThis = mcpThis.getComponentStatePattern();
        String mcNameThis = mcpThis.getMolecularComponent().getName();
        MolecularComponent[] mcThatList = mtThat.getMolecularComponents(mcNameThis);
        if (mcThatList.length == 0) {
            System.out.println("we already fired an issue about component missing");
            // nothing to do here, we already fired an issue about component missing
            continue;
        } else if (mcThatList.length > 1) {
            String msg = "Multiple " + MolecularComponent.typeName + "s with the same name are not yet supported.";
            issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_ERROR));
        } else {
            // found exactly 1 component
            MolecularComponent mcThat = mcThatList[0];
            List<ComponentStateDefinition> csdListThat = mcThat.getComponentStateDefinitions();
            if (csdListThat.size() == 0) {
                // component has no states, we check if mcpThis has any states... it shouldn't
                if (cspThis == null) {
                    // all is well
                    continue;
                }
                if (!cspThis.isAny() || (cspThis.getComponentStateDefinition() != null)) {
                    String msg = MolecularComponentPattern.typeName + " " + mcNameThis + " is in an invalid State.";
                    issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_WARNING));
                }
            } else {
                // we check if mcpThis has any of these states... it should!
                if ((cspThis == null) || cspThis.isAny() || (cspThis.getComponentStateDefinition() == null)) {
                // String msg = "Component pattern " + mcNameThis + " must be in an explicit State.";
                // issueList.add(new Issue(this, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
                } else {
                    String csdNameThis = cspThis.getComponentStateDefinition().getName();
                    if (csdNameThis.isEmpty() || (mcThat.getComponentStateDefinition(csdNameThis) == null)) {
                        String msg = "Invalid State " + csdNameThis + " for component pattern " + mcNameThis;
                        issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_WARNING));
                    }
                }
            }
        }
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Issue(org.vcell.util.Issue) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularComponent(org.vcell.model.rbm.MolecularComponent) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) ArrayList(java.util.ArrayList) List(java.util.List)

Example 74 with Issue

use of org.vcell.util.Issue in project vcell by virtualcell.

the class ReactionStep method gatherIssues.

/**
 * Insert the method's description here.
 * Creation date: (5/12/2004 10:26:42 PM)
 * @param issueList java.util.Vector
 */
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
    issueContext = issueContext.newChildContext(ContextType.ReactionStep, this);
    if (fieldKinetics != null) {
        fieldKinetics.gatherIssues(issueContext, issueList);
    }
    if (fieldName != null && fieldName.startsWith("_reverse_")) {
        String msg = "The prefix '_reverse_' is a BioNetGen reserved keyword. Please rename the " + getDisplayType() + ".";
        issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
    }
    if (structure instanceof Membrane) {
        if (fieldKinetics instanceof MassActionKinetics) {
            if ((getNumReactants() > 1) || (getNumProducts() > 1)) {
                if (isForMembraneMembraneMassAction()) {
                    Issue issue = new Issue(this, issueContext, IssueCategory.KineticsExpressionError, "A mass action rate law is not physically correct for bimolecular reactions in membranes (see more).", Severity.WARNING);
                    issue.setHyperlink(MASS_ACTION_ONLINE_DISCUSSION);
                    issueList.add(issue);
                }
            }
        }
        if (getPhysicsOptions() == PHYSICS_ELECTRICAL_ONLY || getPhysicsOptions() == PHYSICS_MOLECULAR_AND_ELECTRICAL) {
            Feature negFeature = getModel().getElectricalTopology().getNegativeFeature((Membrane) structure);
            Feature posFeature = getModel().getElectricalTopology().getPositiveFeature((Membrane) structure);
            if (negFeature == null || posFeature == null) {
                issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Reaction '" + getName() + "' electrical structure '" + structure.getName() + "' negative and positive compartment must be set", Issue.Severity.ERROR));
            } else {
                for (ReactionParticipant rxParticipant : getReactionParticipants()) {
                    if (rxParticipant.getStructure() != negFeature && rxParticipant.getStructure() != posFeature && rxParticipant.getStructure() != structure) {
                        String msg = "Check STRUCTURE '" + structure.getName() + "' has pos/neg feature settings appropriate for reaction '" + getName() + "' participants";
                        issueList.add(new Issue(structure, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
                    }
                }
            }
        }
    }
    if (fieldKinetics instanceof MassActionKinetics) {
        if (getNumReactants() == 0) {
            String msg = "With Mass Action kinetics this reaction will be interpreted as a degradation of the product.";
            String tool = "Use General Kinetics if you want the product to be generated. As is now this reaction is interpreted as a degradation.";
            issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tool, Issue.Severity.WARNING));
        }
    }
}
Also used : Issue(org.vcell.util.Issue)

Example 75 with Issue

use of org.vcell.util.Issue in project vcell by virtualcell.

the class SpeciesContext method checkBondsSufficiency.

private void checkBondsSufficiency(IssueContext issueContext, List<Issue> issueList, SpeciesPattern sp) {
    if (sp.getMolecularTypePatterns().size() < 2) {
        return;
    }
    int numberOfMolecularTypeCandidates = 0;
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (mtp.getComponentPatternList().size() > 0) {
            numberOfMolecularTypeCandidates++;
        }
    }
    if (numberOfMolecularTypeCandidates < 2) {
        // we need at least 2 molecular types with at least 1 component each
        return;
    }
    boolean atLeastOneBad = false;
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        boolean bondSpecifiedExists = false;
        for (MolecularComponentPattern mcp : mtp.getComponentPatternList()) {
            if (mcp.getBondType() == BondType.Specified) {
                Bond b = mcp.getBond();
                if (b != null) {
                    bondSpecifiedExists = true;
                    break;
                }
            }
        }
        if (!bondSpecifiedExists) {
            atLeastOneBad = true;
        }
    }
    if (atLeastOneBad) {
        String msg = "Each Molecular Pattern of the Species Pattern " + sp.toString() + " needs at least one explicit Bond.\n";
        IssueSource parent = issueContext.getContextObject();
        issueList.add(new Issue(parent, issueContext, IssueCategory.Identifiers, msg, Issue.Severity.ERROR));
    }
}
Also used : IssueSource(org.vcell.util.Issue.IssueSource) Issue(org.vcell.util.Issue) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Bond(org.vcell.model.rbm.SpeciesPattern.Bond)

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