Search in sources :

Example 11 with DistributedKinetics

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;
}
Also used : DistributedKinetics(cbit.vcell.model.DistributedKinetics) LumpedKinetics(cbit.vcell.model.LumpedKinetics) Element(org.jdom.Element) FluxReaction(cbit.vcell.model.FluxReaction)

Example 12 with DistributedKinetics

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());
}
Also used : DistributedKinetics(cbit.vcell.model.DistributedKinetics) LumpedKinetics(cbit.vcell.model.LumpedKinetics)

Aggregations

DistributedKinetics (cbit.vcell.model.DistributedKinetics)12 LumpedKinetics (cbit.vcell.model.LumpedKinetics)12 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)7 Expression (cbit.vcell.parser.Expression)7 ReactionStep (cbit.vcell.model.ReactionStep)6 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)5 Feature (cbit.vcell.model.Feature)4 Kinetics (cbit.vcell.model.Kinetics)4 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)4 ReactionParticipant (cbit.vcell.model.ReactionParticipant)4 ReactionSpec (cbit.vcell.mapping.ReactionSpec)3 FluxReaction (cbit.vcell.model.FluxReaction)3 SubVolume (cbit.vcell.geometry.SubVolume)2 MembraneMapping (cbit.vcell.mapping.MembraneMapping)2 StructureMappingParameter (cbit.vcell.mapping.StructureMapping.StructureMappingParameter)2 Catalyst (cbit.vcell.model.Catalyst)2 Parameter (cbit.vcell.model.Parameter)2 Product (cbit.vcell.model.Product)2 Reactant (cbit.vcell.model.Reactant)2 SimpleReaction (cbit.vcell.model.SimpleReaction)2