Search in sources :

Example 16 with SpeciesContextSpecParameter

use of cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter in project vcell by virtualcell.

the class SEDMLExporter method getTargetAttributeXPath.

private XPathTarget getTargetAttributeXPath(SymbolTableEntry ste, Map<Pair<String, String>, String> l2gMap) {
    // to get Xpath string for variables.
    SBMLSupport sbmlSupport = new SBMLSupport();
    XPathTarget targetXpath = null;
    if (ste instanceof SpeciesContext || ste instanceof SpeciesContextSpecParameter) {
        String speciesId = ste.getName();
        // can change species initial concentration or amount
        String speciesAttr = "";
        if (ste instanceof SpeciesContextSpecParameter) {
            SpeciesContextSpecParameter scsp = (SpeciesContextSpecParameter) ste;
            speciesId = (scsp).getSpeciesContext().getName();
            if (scsp.getRole() == SpeciesContextSpec.ROLE_InitialConcentration) {
                speciesAttr = scsp.getName();
            }
            if (scsp.getRole() == SpeciesContextSpec.ROLE_InitialCount) {
                speciesAttr = scsp.getName();
            }
        }
        if (speciesAttr.length() < 1) {
            targetXpath = new XPathTarget(sbmlSupport.getXPathForCompartment(speciesId));
        } else if (speciesAttr.equalsIgnoreCase("initialConcentration") || speciesAttr.equalsIgnoreCase("initConc")) {
            targetXpath = new XPathTarget(sbmlSupport.getXPathForSpecies(speciesId, SpeciesAttribute.initialConcentration));
        } else if (speciesAttr.equalsIgnoreCase("initialCount")) {
            targetXpath = new XPathTarget(sbmlSupport.getXPathForSpecies(speciesId, SpeciesAttribute.initialAmount));
        } else {
            throw new RuntimeException("Unknown species attribute '" + speciesAttr + "'; cannot get xpath target for species '" + speciesId + "'.");
        }
        targetXpath = new XPathTarget(sbmlSupport.getXPathForSpecies(speciesId));
    } else if (ste instanceof ModelParameter) {
        // can only change parameter value.
        targetXpath = new XPathTarget(sbmlSupport.getXPathForGlobalParameter(ste.getName(), ParameterAttribute.value));
    } else if (ste instanceof Structure || ste instanceof Structure.StructureSize || (ste instanceof StructureMappingParameter && ((StructureMappingParameter) ste).getRole() == StructureMapping.ROLE_Size)) {
        String compartmentId = ste.getName();
        // can change compartment size or spatial dimension, but in vcell, we cannot change compartment dimension.
        String compartmentAttr = "";
        if (ste instanceof Structure.StructureSize) {
            compartmentId = ((StructureSize) ste).getStructure().getName();
            compartmentAttr = ((StructureSize) ste).getName();
        }
        if (ste instanceof StructureMappingParameter) {
            StructureMappingParameter smp = (StructureMappingParameter) ste;
            compartmentId = smp.getStructure().getName();
            if (smp.getRole() == StructureMapping.ROLE_Size) {
                compartmentAttr = smp.getName();
            }
        }
        if (compartmentAttr.length() < 1) {
            targetXpath = new XPathTarget(sbmlSupport.getXPathForCompartment(compartmentId));
        } else if (compartmentAttr.equalsIgnoreCase("size")) {
            targetXpath = new XPathTarget(sbmlSupport.getXPathForCompartment(compartmentId, CompartmentAttribute.size));
        } else {
            throw new RuntimeException("Unknown compartment attribute '" + compartmentAttr + "'; cannot get xpath target for compartment '" + compartmentId + "'.");
        }
    } else if (ste instanceof KineticsParameter) {
        KineticsParameter kp = (KineticsParameter) ste;
        String reactionID = kp.getKinetics().getReactionStep().getName();
        String parameterID = kp.getName();
        Pair<String, String> key = new Pair(reactionID, parameterID);
        String value = l2gMap.get(key);
        if (value == null) {
            // stays as local parameter
            targetXpath = new XPathTarget(sbmlSupport.getXPathForKineticLawParameter(reactionID, parameterID, ParameterAttribute.value));
        } else {
            // became a global in SBML, we need to refer to that global
            targetXpath = new XPathTarget(sbmlSupport.getXPathForGlobalParameter(value, ParameterAttribute.value));
        }
    } else {
        System.err.println("Entity should be SpeciesContext, Structure, ModelParameter : " + ste.getClass());
        throw new RuntimeException("Unknown entity in SBML model");
    }
    return targetXpath;
}
Also used : ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) SpeciesContext(cbit.vcell.model.SpeciesContext) StructureMappingParameter(cbit.vcell.mapping.StructureMapping.StructureMappingParameter) XPathTarget(org.jlibsedml.XPathTarget) Structure(cbit.vcell.model.Structure) StructureSize(cbit.vcell.model.Structure.StructureSize) SBMLSupport(org.jlibsedml.modelsupport.SBMLSupport) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) Pair(org.vcell.util.Pair)

Aggregations

SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)16 Expression (cbit.vcell.parser.Expression)10 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)9 ModelParameter (cbit.vcell.model.Model.ModelParameter)8 SpeciesContext (cbit.vcell.model.SpeciesContext)8 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)7 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)7 StructureMappingParameter (cbit.vcell.mapping.StructureMapping.StructureMappingParameter)6 Model (cbit.vcell.model.Model)6 Parameter (cbit.vcell.model.Parameter)6 Structure (cbit.vcell.model.Structure)6 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)4 MathDescription (cbit.vcell.math.MathDescription)4 Variable (cbit.vcell.math.Variable)4 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)4 ReactionStep (cbit.vcell.model.ReactionStep)4 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)4 ArrayList (java.util.ArrayList)4 ScopedExpression (cbit.gui.ScopedExpression)3 GeometryClass (cbit.vcell.geometry.GeometryClass)3