Search in sources :

Example 11 with StructureMappingParameter

use of cbit.vcell.mapping.StructureMapping.StructureMappingParameter 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

StructureMappingParameter (cbit.vcell.mapping.StructureMapping.StructureMappingParameter)11 Expression (cbit.vcell.parser.Expression)9 SpeciesContext (cbit.vcell.model.SpeciesContext)6 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)6 SubVolume (cbit.vcell.geometry.SubVolume)5 MembraneMapping (cbit.vcell.mapping.MembraneMapping)5 SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)5 Feature (cbit.vcell.model.Feature)5 Membrane (cbit.vcell.model.Membrane)5 ModelParameter (cbit.vcell.model.Model.ModelParameter)5 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)5 SurfaceClass (cbit.vcell.geometry.SurfaceClass)4 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)4 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)4 Model (cbit.vcell.model.Model)4 ArrayList (java.util.ArrayList)4 GeometryClass (cbit.vcell.geometry.GeometryClass)3 SpeciesContextSpecProxyParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecProxyParameter)3 StructureMapping (cbit.vcell.mapping.StructureMapping)3 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)3