Search in sources :

Example 46 with Issue

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

the class SpeciesContextSpec method gatherIssues.

/**
 * Insert the method's description here.
 * Creation date: (11/1/2005 10:03:46 AM)
 * @param issueVector java.util.Vector
 */
public void gatherIssues(IssueContext issueContext, List<Issue> issueVector) {
    issueContext = issueContext.newChildContext(ContextType.SpeciesContextSpec, this);
    // 
    for (int i = 0; i < fieldParameters.length; i++) {
        RealInterval simpleBounds = parameterBounds[fieldParameters[i].getRole()];
        if (simpleBounds != null) {
            String parmName = fieldParameters[i].getNameScope().getName() + "." + fieldParameters[i].getName();
            issueVector.add(new SimpleBoundsIssue(fieldParameters[i], issueContext, simpleBounds, "parameter " + parmName + ": must be within " + simpleBounds.toString()));
        }
    }
    if (bForceContinuous && !bConstant && getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() > 0)) {
        // if it's particle or constant we're good
        SpeciesContext sc = getSpeciesContext();
        ReactionContext rc = getSimulationContext().getReactionContext();
        ReactionSpec[] rsArray = rc.getReactionSpecs();
        for (ReactionSpec rs : rsArray) {
            if (!rs.isExcluded()) {
                // we only care about reactions which are not excluded
                // true if "this" is part of current reaction
                boolean iAmParticipant = false;
                // true if current reaction has at least a particle participant
                boolean haveParticle = false;
                ReactionStep step = rs.getReactionStep();
                for (ReactionParticipant p : step.getReactionParticipants()) {
                    if (p instanceof Product || p instanceof Reactant) {
                        SpeciesContextSpec candidate = rc.getSpeciesContextSpec(p.getSpeciesContext());
                        if (candidate == this) {
                            iAmParticipant = true;
                        } else if (!candidate.isForceContinuous() && !candidate.isConstant()) {
                            haveParticle = true;
                        }
                    }
                }
                if (iAmParticipant && haveParticle) {
                    String msg = "Continuous Species won't conserve mass in particle reaction " + rs.getReactionStep().getName() + ".";
                    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.";
                    issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_WARNING));
                    // we issue warning as soon as we found the first reaction which satisfies criteria
                    break;
                }
            }
        }
    }
    if (!bForceContinuous && bConstant) {
        if (getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() > 0)) {
            String msg = "Clamped Species must be continuous rather than particles.";
            String tip = "If choose 'clamped', must also choose 'forceContinuous'";
            issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_ERROR));
        }
    }
    if (bForceContinuous && !bConstant) {
        if (getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() == 0)) {
            String msg = "Non-constant species is forced continuous, not supported for nonspatial stochastic applications.";
            issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_ERROR));
        }
    }
}
Also used : Issue(org.vcell.util.Issue) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Product(cbit.vcell.model.Product) SpeciesContext(cbit.vcell.model.SpeciesContext) RealInterval(net.sourceforge.interval.ia_math.RealInterval) Reactant(cbit.vcell.model.Reactant) ReactionStep(cbit.vcell.model.ReactionStep) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 47 with Issue

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

the class StructureMapping method detectMappingConflictIssues.

private static void detectMappingConflictIssues(IssueContext issueContext, List<Issue> issueVector, StructureMapping ours) {
    if (ours.getGeometryClass() == null) {
        return;
    }
    final String ourStructureName = ours.getStructure().getName();
    final String ourStructureTypeName = ours.getStructure().getTypeName();
    final String ourSubdomainName = ours.getGeometryClass().getName();
    SimulationContext sc = ours.simulationContext;
    // list of incompatible structures mapped to the same subdomain, correctly built but not used
    String incompatibilityList = "";
    boolean incompatibilityFound = false;
    StructureMapping[] structureMappings = sc.getGeometryContext().getStructureMappings();
    for (StructureMapping theirs : structureMappings) {
        if (ours == theirs) {
            // don't compare ours with itself
            continue;
        }
        if (theirs.getGeometryClass() == null) {
            // 'theirs' is unmapped but some others may be, keep looking
            continue;
        }
        final String theirSubdomainName = theirs.getGeometryClass().getName();
        if (!ourSubdomainName.equals(theirSubdomainName)) {
            // we don't care if mapped to another subdomain
            continue;
        }
        String incompatibleStructure = findMappingBoundaryConflict(ours, theirs);
        if (incompatibleStructure != null) {
            if (incompatibilityFound) {
                incompatibilityList += ", ";
            }
            incompatibilityList += incompatibleStructure;
            incompatibilityFound = true;
        }
    }
    if (!incompatibilityList.isEmpty()) {
        // TODO: modify StructureMappingTableRenderer to customize the way issues are being rendered
        String message = "Subdomain '" + ourSubdomainName + "' boundary conditions (e.g. for X-, X+...) must match.";
        String tooltip = "Can't mix Flux and Value on the same column (e.g. X-, X+...) for multiple Structures mapped to the same Subdomain.";
        issueVector.add(new Issue(ours, issueContext, IssueCategory.SubVolumeVerificationError, message, tooltip, Issue.Severity.ERROR));
    }
}
Also used : SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Issue(org.vcell.util.Issue)

Example 48 with Issue

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

the class SurfaceRegionObject method gatherIssues.

@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
    if (simulationContext.getGeometry().getGeometrySurfaceDescription() != null) {
        GeometricRegion[] regions = simulationContext.getGeometry().getGeometrySurfaceDescription().getGeometricRegions();
        boolean bFound = false;
        if (regions != null) {
            for (GeometricRegion region : regions) {
                if (region instanceof SurfaceGeometricRegion) {
                    SurfaceGeometricRegion sr = (SurfaceGeometricRegion) region;
                    if (sr.getAdjacentGeometricRegions() != null && sr.getAdjacentGeometricRegions().length == 2) {
                        VolumeGeometricRegion vr1 = (VolumeGeometricRegion) sr.getAdjacentGeometricRegions()[0];
                        VolumeGeometricRegion vr2 = (VolumeGeometricRegion) sr.getAdjacentGeometricRegions()[1];
                        if (vr1.getSubVolume() == insideSubVolume && vr1.getRegionID() == insideRegionID && vr2.getSubVolume() == outsideSubVolume && vr2.getRegionID() == outsideRegionID) {
                            bFound = true;
                        }
                        if (vr1.getSubVolume() == outsideSubVolume && vr1.getRegionID() == outsideRegionID && vr2.getSubVolume() == insideSubVolume && vr2.getRegionID() == insideRegionID) {
                            bFound = true;
                        }
                    }
                }
            }
        }
        if (!bFound) {
            issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "could not find corresponding surface region in geometry", Issue.Severity.ERROR));
        }
    }
}
Also used : Issue(org.vcell.util.Issue) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion)

Example 49 with Issue

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

the class MathMapping_4_8 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, StructureMapping structureMapping) 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);
    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, structureMapping);
            if (!newName.equals(symbols[i])) {
                newExp.substituteInPlace(new Expression(symbols[i]), new Expression(newName));
            }
        }
    }
    return newExp;
}
Also used : VCUnitException(cbit.vcell.units.VCUnitException) VCUnitEvaluator(cbit.vcell.parser.VCUnitEvaluator) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Issue(org.vcell.util.Issue) Expression(cbit.vcell.parser.Expression) 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) MappingException(cbit.vcell.mapping.MappingException) MathException(cbit.vcell.math.MathException)

Example 50 with Issue

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

the class GeometryContext method gatherIssues.

/**
 * Insert the method's description here.
 * Creation date: (11/1/2005 9:48:55 AM)
 * @param issueList java.util.Vector
 */
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
    issueContext = issueContext.newChildContext(ContextType.Geometry, getGeometry());
    GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
    if (geometrySpec != null) {
        geometrySpec.gatherIssues(issueContext, getGeometry(), issueList);
    }
    for (int i = 0; fieldStructureMappings != null && i < fieldStructureMappings.length; i++) {
        fieldStructureMappings[i].gatherIssues(issueContext, issueList);
    }
    for (GeometryClass gc : fieldGeometry.getGeometryClasses()) {
        Structure[] structuresFromGeometryClass = getStructuresFromGeometryClass(gc);
        if (structuresFromGeometryClass == null || structuresFromGeometryClass.length == 0) {
            UnmappedGeometryClass unmappedGeometryClass = new UnmappedGeometryClass(gc);
            Issue issue = new Issue(unmappedGeometryClass, issueContext, IssueCategory.GeometryClassNotMapped, "Subdomain '" + gc.getName() + "' is not mapped to any physiological structure.", Issue.SEVERITY_WARNING);
            issueList.add(issue);
        }
    }
    if (getSimulationContext().isStoch() && getGeometry().getDimension() != 0 && getGeometry().getDimension() != 3) {
        Issue issue = new Issue(this, issueContext, IssueCategory.Smoldyn_Geometry_3DWarning, "VCell spatial stochastic models only support 3D geometry.", Issue.SEVERITY_ERROR);
        issueList.add(issue);
    }
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec) GeometryClass(cbit.vcell.geometry.GeometryClass) Issue(org.vcell.util.Issue) Structure(cbit.vcell.model.Structure)

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