Search in sources :

Example 56 with Feature

use of cbit.vcell.model.Feature in project vcell by virtualcell.

the class XmlReader method getFeature.

/**
 * This method returns a Feature object (Structure) from a XML representation.
 * Creation date: (3/15/2001 6:12:36 PM)
 * @return cbit.vcell.model.Structure
 * @param param org.jdom.Element
 */
private Structure getFeature(Element param) throws XmlParseException {
    Feature newfeature = null;
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // retrieve the key if there is one
    KeyValue key = null;
    String keystring = param.getAttributeValue(XMLTags.KeyValueAttrTag);
    if (keystring != null && keystring.length() > 0 && this.readKeysFlag) {
        key = new KeyValue(keystring);
    }
    // ---Create the new feature---
    try {
        newfeature = new Feature(key, name);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("An error occurred while creating the feature " + param.getAttributeValue(XMLTags.NameAttrTag), e);
    }
    return newfeature;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) KeyValue(org.vcell.util.document.KeyValue) Feature(cbit.vcell.model.Feature)

Example 57 with Feature

use of cbit.vcell.model.Feature in project vcell by virtualcell.

the class XmlReader method getFeatureMapping.

/**
 * This method retuns a FeatureMapping object from a XML representation.
 * Creation date: (5/7/2001 4:12:03 PM)
 * @return cbit.vcell.mapping.FeatureMapping
 * @param param org.jdom.Element
 */
private FeatureMapping getFeatureMapping(Element param, SimulationContext simulationContext) throws XmlParseException {
    // Retrieve attributes
    String featurename = unMangle(param.getAttributeValue(XMLTags.FeatureAttrTag));
    String geometryClassName = param.getAttributeValue(XMLTags.SubVolumeAttrTag);
    if (geometryClassName != null) {
        geometryClassName = unMangle(geometryClassName);
    } else {
        geometryClassName = param.getAttributeValue(XMLTags.GeometryClassAttrTag);
        if (geometryClassName != null) {
            geometryClassName = unMangle(geometryClassName);
        }
    }
    Feature featureref = (Feature) simulationContext.getModel().getStructure(featurename);
    if (featureref == null) {
        throw new XmlParseException("The Feature " + featurename + " could not be resolved!");
    }
    // *** Create new Feature Mapping ****
    FeatureMapping feamap = new FeatureMapping(featureref, simulationContext, simulationContext.getModel().getUnitSystem());
    // Set Size
    if (param.getAttributeValue(XMLTags.SizeTag) != null) {
        String size = unMangle(param.getAttributeValue(XMLTags.SizeTag));
        try {
            feamap.getSizeParameter().setExpression(unMangleExpression(size));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("An expressionException was fired when setting the size Expression " + size + " to a featureMapping!", e);
        }
    } else {
        try {
            feamap.getSizeParameter().setExpression(null);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("unexpected exception while setting structure size: " + e.getMessage());
        }
    }
    // Set Volume/unit_area if it exists
    if (param.getAttributeValue(XMLTags.VolumePerUnitAreaTag) != null) {
        String volPerUnitArea = unMangle(param.getAttributeValue(XMLTags.VolumePerUnitAreaTag));
        try {
            feamap.getVolumePerUnitAreaParameter().setExpression(unMangleExpression(volPerUnitArea));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("An expressionException was fired when setting the VolumePerUnitArea Expression " + volPerUnitArea + " to a featureMapping!", e);
        }
    }
    // Set Volume/unitVol if it exists
    if (param.getAttributeValue(XMLTags.VolumePerUnitVolumeTag) != null) {
        String volPerUnitVol = unMangle(param.getAttributeValue(XMLTags.VolumePerUnitVolumeTag));
        try {
            feamap.getVolumePerUnitVolumeParameter().setExpression(unMangleExpression(volPerUnitVol));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("An expressionException was fired when setting the size Expression " + volPerUnitVol + " to a featureMapping!", e);
        }
    }
    if (geometryClassName != null) {
        GeometryClass[] geometryClasses = simulationContext.getGeometry().getGeometryClasses();
        for (int i = 0; i < geometryClasses.length; i++) {
            if (geometryClasses[i].getName().equals(geometryClassName)) {
                try {
                    feamap.setGeometryClass(geometryClasses[i]);
                } catch (PropertyVetoException e) {
                    e.printStackTrace(System.out);
                    throw new XmlParseException("A propertyVetoException was fired when trying to set the subvolume or surface " + geometryClassName + " to a MembraneMapping!", e);
                }
            }
        }
    }
    // Set Boundary conditions
    Element tempElement = param.getChild(XMLTags.BoundariesTypesTag, vcNamespace);
    // Xm
    String temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueXm);
    BoundaryConditionType bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeXm(bct);
    // Xp
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueXp);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeXp(bct);
    // Ym
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueYm);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeYm(bct);
    // Yp
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueYp);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeYp(bct);
    // Zm
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueZm);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeZm(bct);
    // Zp
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueZp);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeZp(bct);
    return feamap;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) Element(org.jdom.Element) BoundaryConditionType(cbit.vcell.math.BoundaryConditionType) Feature(cbit.vcell.model.Feature) ExpressionException(cbit.vcell.parser.ExpressionException) GeometryException(cbit.vcell.geometry.GeometryException) MathFormatException(cbit.vcell.math.MathFormatException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ModelException(cbit.vcell.model.ModelException) DataConversionException(org.jdom.DataConversionException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) PropertyVetoException(java.beans.PropertyVetoException) FeatureMapping(cbit.vcell.mapping.FeatureMapping)

Example 58 with Feature

use of cbit.vcell.model.Feature in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * Outputs a XML version of a Model object
 * Creation date: (2/15/2001 11:39:27 AM)
 * @return Element
 * @param param cbit.vcell.model.Model
 */
private Element getXML(Model param) throws XmlParseException /*, cbit.vcell.parser.ExpressionException */
{
    Element modelnode = new Element(XMLTags.ModelTag);
    String versionName = (param.getName() != null) ? mangle(param.getName()) : "unnamed_model";
    // get Attributes
    modelnode.setAttribute(XMLTags.NameAttrTag, versionName);
    // modelnode.setAttribute(XMLTags.AnnotationAttrTag, this.mangle(param.getDescription()));
    if (param.getDescription() != null && param.getDescription().length() > 0) {
        Element annotationElem = new Element(XMLTags.AnnotationTag);
        annotationElem.setText(mangle(param.getDescription()));
        modelnode.addContent(annotationElem);
    }
    // get global parameters
    ModelParameter[] modelGlobals = param.getModelParameters();
    if (modelGlobals != null && modelGlobals.length > 0) {
        modelnode.addContent(getXML(modelGlobals));
    }
    // Get Species
    Species[] array = param.getSpecies();
    for (int i = 0; i < array.length; i++) {
        modelnode.addContent(getXML(array[i]));
    }
    // Get Structures(Features and Membranes). Add them in an ordered fashion, but it does not matter who comes first.
    try {
        ArrayList<Element> list = new ArrayList<Element>();
        Structure[] structarray = param.getStructures();
        for (int i = 0; i < structarray.length; i++) {
            Element structure = getXML(structarray[i], param);
            if (structarray[i] instanceof Feature)
                modelnode.addContent(structure);
            else
                list.add(structure);
        }
        for (int i = 0; i < list.size(); i++) {
            modelnode.addContent((Element) list.get(i));
        }
    } catch (XmlParseException e) {
        e.printStackTrace();
        throw new XmlParseException("An error occurred while procesing a Structure for the model " + versionName, e);
    }
    // Process SpeciesContexts
    SpeciesContext[] specarray = param.getSpeciesContexts();
    for (int i = 0; i < specarray.length; i++) {
        modelnode.addContent(getXML(specarray[i]));
    }
    // Get reaction Steps(Simple Reactions and Fluxtep)
    ReactionStep[] reactarray = param.getReactionSteps();
    for (int i = 0; i < reactarray.length; i++) {
        modelnode.addContent(getXML(reactarray[i]));
    }
    // add the rbmModelContainer elements
    RbmModelContainer rbmModelContainer = param.getRbmModelContainer();
    if (rbmModelContainer != null && !rbmModelContainer.isEmpty()) {
        Element rbmModelContainerElement = getXML(rbmModelContainer);
        {
            // for testing purposes only
            Document doc = new Document();
            Element clone = (Element) rbmModelContainerElement.clone();
            doc.setRootElement(clone);
            String xmlString = XmlUtil.xmlToString(doc, false);
            System.out.println(xmlString);
        }
        modelnode.addContent(rbmModelContainerElement);
    }
    // // Add rate rules
    // if (param.getRateRuleVariables()!=null && param.getRateRuleVariables().length>0){
    // modelnode.addContent( getXML(param.getRateRuleVariables()) );
    // }
    // Get Diagrams
    Diagram[] diagarray = param.getDiagrams();
    for (int i = 0; i < diagarray.length; i++) {
        modelnode.addContent(getXML(diagarray[i]));
    }
    // Add Metadata information
    if (param.getVersion() != null) {
        modelnode.addContent(getXML(param.getVersion(), param));
    }
    // add model UnitSystem
    ModelUnitSystem unitSystem = param.getUnitSystem();
    if (unitSystem != null) {
        modelnode.addContent(getXML(unitSystem));
    }
    return modelnode;
}
Also used : Element(org.jdom.Element) ArrayList(java.util.ArrayList) SpeciesContext(cbit.vcell.model.SpeciesContext) Document(org.jdom.Document) Feature(cbit.vcell.model.Feature) Diagram(cbit.vcell.model.Diagram) ModelParameter(cbit.vcell.model.Model.ModelParameter) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) ReactionStep(cbit.vcell.model.ReactionStep) Structure(cbit.vcell.model.Structure) DBFormalSpecies(cbit.vcell.model.DBFormalSpecies) Species(cbit.vcell.model.Species) DBSpecies(cbit.vcell.model.DBSpecies) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Example 59 with Feature

use of cbit.vcell.model.Feature in project vcell by virtualcell.

the class XmlReader method getElectrode.

/**
 * This method returns an Electrode object from a XML representation.
 * Creation date: (6/6/2002 4:22:55 PM)
 * @return cbit.vcell.mapping.Electrode
 */
private Electrode getElectrode(org.jdom.Element elem, SimulationContext currentSimulationContext) {
    // retrieve feature
    String featureName = unMangle(elem.getAttributeValue(XMLTags.FeatureAttrTag));
    Feature feature = (Feature) currentSimulationContext.getModel().getStructure(featureName);
    // retrieve position
    Coordinate position = getCoordinate(elem.getChild(XMLTags.CoordinateTag, vcNamespace));
    Electrode newElect = new Electrode(feature, position);
    return newElect;
}
Also used : Electrode(cbit.vcell.mapping.Electrode) Coordinate(org.vcell.util.Coordinate) Feature(cbit.vcell.model.Feature)

Example 60 with Feature

use of cbit.vcell.model.Feature in project vcell by virtualcell.

the class StructurePropertiesPanel method getExplanationText.

private String getExplanationText() {
    if (structure instanceof Membrane) {
        Membrane membrane = (Membrane) structure;
        String voltageName = membrane.getMembraneVoltage().getName();
        Feature posFeature = fieldModel.getElectricalTopology().getPositiveFeature(membrane);
        Feature negFeature = fieldModel.getElectricalTopology().getNegativeFeature(membrane);
        String posCompName = (posFeature != null) ? posFeature.getName() : "inside (+) compartment";
        String negCompName = (negFeature != null) ? negFeature.getName() : "outside (-) compartment";
        return "<html><b>membrane voltage</i>:</b> <font color=\"blue\">\"" + voltageName + "\"</font> = voltage(<font color=\"blue\">" + posCompName + "</font>) - voltage(<font color=\"blue\">" + negCompName + "</font>)</i><br/>" + "<b>inward currents:</b> from compartment <font color=\"blue\">\"" + negCompName + "\"</font> into compartment <font color=\"blue\">\"" + posCompName + "\"</font>" + "<font color=\"red\"><i><br/>Note: VCell reactions and fluxes specify inward currents (- to +) rather than conventional currents (+ to -).</i></font>" + "</html>";
    } else {
        return "";
    }
}
Also used : Membrane(cbit.vcell.model.Membrane) Feature(cbit.vcell.model.Feature)

Aggregations

Feature (cbit.vcell.model.Feature)71 Membrane (cbit.vcell.model.Membrane)50 Structure (cbit.vcell.model.Structure)36 Expression (cbit.vcell.parser.Expression)29 SpeciesContext (cbit.vcell.model.SpeciesContext)25 PropertyVetoException (java.beans.PropertyVetoException)18 Model (cbit.vcell.model.Model)16 StructureTopology (cbit.vcell.model.Model.StructureTopology)16 SimpleReaction (cbit.vcell.model.SimpleReaction)15 SubVolume (cbit.vcell.geometry.SubVolume)14 MembraneMapping (cbit.vcell.mapping.MembraneMapping)14 SurfaceClass (cbit.vcell.geometry.SurfaceClass)13 FeatureMapping (cbit.vcell.mapping.FeatureMapping)13 ExpressionException (cbit.vcell.parser.ExpressionException)13 FluxReaction (cbit.vcell.model.FluxReaction)12 ReactionStep (cbit.vcell.model.ReactionStep)12 KeyValue (org.vcell.util.document.KeyValue)12 BioModel (cbit.vcell.biomodel.BioModel)11 StructureMapping (cbit.vcell.mapping.StructureMapping)11 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)11