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;
}
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;
}
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;
}
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;
}
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 "";
}
}
Aggregations