Search in sources :

Example 11 with SimulationContextParameter

use of cbit.vcell.mapping.SimulationContext.SimulationContextParameter in project vcell by virtualcell.

the class XmlReader method getSimulationContextParams.

public SimulationContextParameter[] getSimulationContextParams(Element appParams, SimulationContext simContext) throws XmlParseException {
    Iterator<Element> appParamIterator = appParams.getChildren(XMLTags.ParameterTag, vcNamespace).iterator();
    ArrayList<SimulationContextParameter> appParamsList = new ArrayList<SimulationContextParameter>();
    while (appParamIterator.hasNext()) {
        org.jdom.Element paramElement = (Element) appParamIterator.next();
        appParamsList.add(getSimulationContextParameter(paramElement, simContext));
    }
    return appParamsList.toArray(new SimulationContextParameter[0]);
}
Also used : Element(org.jdom.Element) ArrayList(java.util.ArrayList) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) Element(org.jdom.Element)

Example 12 with SimulationContextParameter

use of cbit.vcell.mapping.SimulationContext.SimulationContextParameter in project vcell by virtualcell.

the class SimContextTable method getAppComponentsForDatabase.

/**
 * getXMLStringForDatabase : this returns the XML string for the container element <AppComponents> for application-related protocols
 * and other extra specifications. For now, BioEvents falls under this category, so the BioEvents element (list of bioevents)
 * is obtained from the simContext (via the XMLProducer) and added as content to <AppComponents> element. The <AppComponents>
 * element is converted to XML string which is the return value of this method. This string is stored in the database in the
 * SimContextTable. Instead of creating new fields for each possible application component, it is convenient to store them
 * all under a blanket XML element <AppComponents>.
 * @param simContext
 * @return
 */
public static String getAppComponentsForDatabase(SimulationContext simContext) {
    Element appComponentsElement = new Element(XMLTags.ApplicationComponents);
    // for now, create the element only if application is stochastic. Can change it later.
    if (simContext.isStoch()) {
        // add 'randomizeInitCondition' flag only if simContext is non-spatial
        if (simContext.getGeometry().getDimension() == 0) {
            Element appRelatedFlagsElement = new Element(XMLTags.ApplicationSpecificFlagsTag);
            if (simContext.isRandomizeInitCondition()) {
                appRelatedFlagsElement.setAttribute(XMLTags.RandomizeInitConditionTag, "true");
            } else {
                appRelatedFlagsElement.setAttribute(XMLTags.RandomizeInitConditionTag, "false");
            }
            appComponentsElement.addContent(appRelatedFlagsElement);
        }
    }
    if (simContext.isInsufficientIterations()) {
        appComponentsElement.setAttribute(XMLTags.InsufficientIterationsTag, "true");
    } else {
        appComponentsElement.setAttribute(XMLTags.InsufficientIterationsTag, "false");
    }
    if (simContext.isInsufficientMaxMolecules()) {
        appComponentsElement.setAttribute(XMLTags.InsufficientMaxMoleculesTag, "true");
    } else {
        appComponentsElement.setAttribute(XMLTags.InsufficientMaxMoleculesTag, "false");
    }
    Xmlproducer xmlProducer = new Xmlproducer(false);
    NetworkConstraints constraints = simContext.getNetworkConstraints();
    if (constraints != null) {
        appComponentsElement.addContent(xmlProducer.getXML(constraints));
    }
    // first fill in bioevents from simContext
    BioEvent[] bioEvents = simContext.getBioEvents();
    if (bioEvents != null && bioEvents.length > 0) {
        try {
            Element bioEventsElement = xmlProducer.getXML(bioEvents);
            appComponentsElement.addContent(bioEventsElement);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error generating XML for bioevents : " + e.getMessage());
        }
    }
    SimulationContextParameter[] appParams = simContext.getSimulationContextParameters();
    if (appParams != null && appParams.length > 0) {
        try {
            Element appParamsElement = xmlProducer.getXML(appParams);
            appComponentsElement.addContent(appParamsElement);
        } catch (Exception e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error generating XML for application parameters : " + e.getMessage());
        }
    }
    SpatialObject[] spatialObjects = simContext.getSpatialObjects();
    if (spatialObjects != null && spatialObjects.length > 0) {
        try {
            Element spatialObjectsElement = xmlProducer.getXML(spatialObjects);
            appComponentsElement.addContent(spatialObjectsElement);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error generating XML for spatialObjects : " + e.getMessage());
        }
    }
    SpatialProcess[] spatialProcesses = simContext.getSpatialProcesses();
    if (spatialProcesses != null && spatialProcesses.length > 0) {
        try {
            Element spatialProcessesElement = xmlProducer.getXML(spatialProcesses);
            appComponentsElement.addContent(spatialProcessesElement);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error generating XML for spatialProcesses : " + e.getMessage());
        }
    }
    // microscope measurements
    Element element = xmlProducer.getXML(simContext.getMicroscopeMeasurement());
    appComponentsElement.addContent(element);
    // rate rules
    RateRule[] rateRules = simContext.getRateRules();
    if (rateRules != null && rateRules.length > 0) {
        try {
            Element rateRulesElement = xmlProducer.getXML(rateRules);
            appComponentsElement.addContent(rateRulesElement);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error generating XML for bioevents : " + e.getMessage());
        }
    }
    // ReactionRuleSpecs
    ReactionRuleSpec[] reactionRuleSpecs = simContext.getReactionContext().getReactionRuleSpecs();
    if (reactionRuleSpecs != null && reactionRuleSpecs.length > 0) {
        Element reactionRuleSpecsElement = xmlProducer.getXML(reactionRuleSpecs);
        appComponentsElement.addContent(reactionRuleSpecsElement);
    }
    String appComponentsXMLStr = null;
    if (appComponentsElement.getContent() != null) {
        appComponentsXMLStr = XmlUtil.xmlToString(appComponentsElement);
    }
    return appComponentsXMLStr;
}
Also used : Xmlproducer(cbit.vcell.xml.Xmlproducer) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) Element(org.jdom.Element) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) RateRule(cbit.vcell.mapping.RateRule) BioEvent(cbit.vcell.mapping.BioEvent) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Aggregations

SimulationContextParameter (cbit.vcell.mapping.SimulationContext.SimulationContextParameter)12 SimulationContext (cbit.vcell.mapping.SimulationContext)6 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)6 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)6 ModelParameter (cbit.vcell.model.Model.ModelParameter)5 Element (org.jdom.Element)5 BioEvent (cbit.vcell.mapping.BioEvent)4 RateRule (cbit.vcell.mapping.RateRule)4 EditableSymbolTableEntry (cbit.vcell.model.EditableSymbolTableEntry)4 ArrayList (java.util.ArrayList)4 NetworkConstraints (org.vcell.model.rbm.NetworkConstraints)4 ElectricalStimulus (cbit.vcell.mapping.ElectricalStimulus)3 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)3 ReactionRuleSpec (cbit.vcell.mapping.ReactionRuleSpec)3 StructureMapping (cbit.vcell.mapping.StructureMapping)3 ReactionStep (cbit.vcell.model.ReactionStep)3 SpeciesContext (cbit.vcell.model.SpeciesContext)3 PropertyVetoException (java.beans.PropertyVetoException)3 DataSymbol (cbit.vcell.data.DataSymbol)2 FieldDataSymbol (cbit.vcell.data.FieldDataSymbol)2