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