use of cbit.vcell.model.DistributedKinetics in project vcell by virtualcell.
the class SBMLExporter method getAnnotationElement.
/**
* getAnnotationElement :
* For a flux reaction, we need to add an annotation specifying the structure, flux carrier, carrier valence and fluxOption.
* For a simple reaction, we need to add a annotation specifying the structure (useful for import)
* Using XML JDOM elements, so that it is convenient for libSBML setAnnotation (requires the annotation to be provided as an xml string).
*/
private Element getAnnotationElement(ReactionStep reactionStep) throws cbit.vcell.xml.XmlParseException {
Element sbmlImportRelatedElement = new Element(XMLTags.VCellRelatedInfoTag, sbml_vcml_ns);
Element rxnElement = null;
if (reactionStep instanceof FluxReaction) {
FluxReaction fluxRxn = (FluxReaction) reactionStep;
// Element for flux reaction. Write out the structure and flux carrier name.
rxnElement = new Element(XMLTags.FluxStepTag, sbml_vcml_ns);
rxnElement.setAttribute(XMLTags.StructureAttrTag, fluxRxn.getStructure().getName());
// Get the physics option value.
if (fluxRxn.getPhysicsOptions() == ReactionStep.PHYSICS_ELECTRICAL_ONLY) {
rxnElement.setAttribute(XMLTags.FluxOptionAttrTag, XMLTags.FluxOptionElectricalOnly);
} else if (fluxRxn.getPhysicsOptions() == ReactionStep.PHYSICS_MOLECULAR_AND_ELECTRICAL) {
rxnElement.setAttribute(XMLTags.FluxOptionAttrTag, XMLTags.FluxOptionMolecularAndElectrical);
} else if (fluxRxn.getPhysicsOptions() == ReactionStep.PHYSICS_MOLECULAR_ONLY) {
rxnElement.setAttribute(XMLTags.FluxOptionAttrTag, XMLTags.FluxOptionMolecularOnly);
}
} else if (reactionStep instanceof cbit.vcell.model.SimpleReaction) {
// Element for a simple reaction - just store structure name - will be useful while importing.
cbit.vcell.model.SimpleReaction simpleRxn = (cbit.vcell.model.SimpleReaction) reactionStep;
rxnElement = new org.jdom.Element(cbit.vcell.xml.XMLTags.SimpleReactionTag, sbml_vcml_ns);
rxnElement.setAttribute(cbit.vcell.xml.XMLTags.StructureAttrTag, simpleRxn.getStructure().getName());
}
// Add rate name as an element of annotation - this is especially useful when roundtripping VCell models, when the reaction
// rate parameters have been renamed by user.
Element rateElement = new Element(XMLTags.ReactionRateTag, sbml_vcml_ns);
if (reactionStep.getKinetics() instanceof DistributedKinetics) {
rateElement.setAttribute(XMLTags.NameAttrTag, ((DistributedKinetics) reactionStep.getKinetics()).getReactionRateParameter().getName());
} else if (reactionStep.getKinetics() instanceof LumpedKinetics) {
rateElement.setAttribute(XMLTags.NameAttrTag, ((LumpedKinetics) reactionStep.getKinetics()).getLumpedReactionRateParameter().getName());
} else {
throw new RuntimeException("unexpected kinetic type " + reactionStep.getKinetics().getClass().getName());
}
sbmlImportRelatedElement.addContent(rxnElement);
sbmlImportRelatedElement.addContent(rateElement);
return sbmlImportRelatedElement;
}
use of cbit.vcell.model.DistributedKinetics in project vcell by virtualcell.
the class KineticsAdapter method create.
/**
* @param k not null
* @return adapter for type
* @throws SbmlException if type not recognized
* @throws {@link NullPointerException} if k null
*/
public static KineticsAdapter create(Kinetics k) throws SbmlException {
DistributedKinetics dk = BeanUtils.downcast(DistributedKinetics.class, k);
if (dk != null) {
return new Distributed(dk);
}
LumpedKinetics lk = BeanUtils.downcast(LumpedKinetics.class, k);
if (lk != null) {
return new Lumped(lk);
}
throw new SbmlException("Unknown Kinetics subclass " + k.getClass().getName());
}
Aggregations