use of cbit.vcell.math.ParticleObservable in project vcell by virtualcell.
the class RulebasedMathMapping method refreshMathDescription.
/**
* This method was created in VisualAge.
*/
@Override
protected void refreshMathDescription() throws MappingException, MatrixException, MathException, ExpressionException, ModelException {
// use local variable instead of using getter all the time.
SimulationContext simContext = getSimulationContext();
GeometryClass geometryClass = simContext.getGeometry().getGeometrySpec().getSubVolumes()[0];
Domain domain = new Domain(geometryClass);
// local structure mapping list
StructureMapping[] structureMappings = simContext.getGeometryContext().getStructureMappings();
// We have to check if all the reactions are able to transform to stochastic jump processes before generating the math.
String stochChkMsg = simContext.getModel().isValidForStochApp();
if (!(stochChkMsg.equals(""))) {
throw new ModelException("Problem updating math description: " + simContext.getName() + "\n" + stochChkMsg);
}
simContext.checkValidity();
//
if (simContext.getGeometry().getDimension() > 0) {
throw new MappingException("rule-based particle math mapping not implemented for spatial geometry - dimension >= 1");
}
//
for (int i = 0; i < structureMappings.length; i++) {
if (structureMappings[i] instanceof MembraneMapping) {
if (((MembraneMapping) structureMappings[i]).getCalculateVoltage()) {
throw new MappingException("electric potential not yet supported for particle models");
}
}
}
//
// fail if any events
//
BioEvent[] bioEvents = simContext.getBioEvents();
if (bioEvents != null && bioEvents.length > 0) {
throw new MappingException("events not yet supported for particle-based models");
}
//
// verify that all structures are mapped to subvolumes and all subvolumes are mapped to a structure
//
Structure[] structures = simContext.getGeometryContext().getModel().getStructures();
for (int i = 0; i < structures.length; i++) {
StructureMapping sm = simContext.getGeometryContext().getStructureMapping(structures[i]);
if (sm == null || (sm instanceof FeatureMapping && ((FeatureMapping) sm).getGeometryClass() == null)) {
throw new MappingException("model structure '" + structures[i].getName() + "' not mapped to a geometry subVolume");
}
if (sm != null && (sm instanceof MembraneMapping) && ((MembraneMapping) sm).getVolumeFractionParameter() != null) {
Expression volFractExp = ((MembraneMapping) sm).getVolumeFractionParameter().getExpression();
try {
if (volFractExp != null) {
double volFract = volFractExp.evaluateConstant();
if (volFract >= 1.0) {
throw new MappingException("model structure '" + (getSimulationContext().getModel().getStructureTopology().getInsideFeature(((MembraneMapping) sm).getMembrane()).getName() + "' has volume fraction >= 1.0"));
}
}
} catch (ExpressionException e) {
e.printStackTrace(System.out);
}
}
}
SubVolume[] subVolumes = simContext.getGeometryContext().getGeometry().getGeometrySpec().getSubVolumes();
for (int i = 0; i < subVolumes.length; i++) {
Structure[] mappedStructures = simContext.getGeometryContext().getStructuresFromGeometryClass(subVolumes[i]);
if (mappedStructures == null || mappedStructures.length == 0) {
throw new MappingException("geometry subVolume '" + subVolumes[i].getName() + "' not mapped from a model structure");
}
}
//
// gather only those reactionRules that are not "excluded"
//
ArrayList<ReactionRule> rrList = new ArrayList<ReactionRule>();
for (ReactionRuleSpec reactionRuleSpec : simContext.getReactionContext().getReactionRuleSpecs()) {
if (!reactionRuleSpec.isExcluded()) {
rrList.add(reactionRuleSpec.getReactionRule());
}
}
//
for (ReactionRule reactionRule : rrList) {
UnresolvedParameter[] unresolvedParameters = reactionRule.getKineticLaw().getUnresolvedParameters();
if (unresolvedParameters != null && unresolvedParameters.length > 0) {
StringBuffer buffer = new StringBuffer();
for (int j = 0; j < unresolvedParameters.length; j++) {
if (j > 0) {
buffer.append(", ");
}
buffer.append(unresolvedParameters[j].getName());
}
throw new MappingException("In Application '" + simContext.getName() + "', " + reactionRule.getDisplayType() + " '" + reactionRule.getName() + "' contains unresolved identifier(s): " + buffer);
}
}
//
// create new MathDescription (based on simContext's previous MathDescription if possible)
//
MathDescription oldMathDesc = simContext.getMathDescription();
mathDesc = null;
if (oldMathDesc != null) {
if (oldMathDesc.getVersion() != null) {
mathDesc = new MathDescription(oldMathDesc.getVersion());
} else {
mathDesc = new MathDescription(oldMathDesc.getName());
}
} else {
mathDesc = new MathDescription(simContext.getName() + "_generated");
}
//
// temporarily place all variables in a hashtable (before binding) and discarding duplicates
//
VariableHash varHash = new VariableHash();
//
// conversion factors
//
Model model = simContext.getModel();
varHash.addVariable(new Constant(getMathSymbol(model.getKMOLE(), null), getIdentifierSubstitutions(model.getKMOLE().getExpression(), model.getKMOLE().getUnitDefinition(), null)));
varHash.addVariable(new Constant(getMathSymbol(model.getN_PMOLE(), null), getIdentifierSubstitutions(model.getN_PMOLE().getExpression(), model.getN_PMOLE().getUnitDefinition(), null)));
varHash.addVariable(new Constant(getMathSymbol(model.getPI_CONSTANT(), null), getIdentifierSubstitutions(model.getPI_CONSTANT().getExpression(), model.getPI_CONSTANT().getUnitDefinition(), null)));
varHash.addVariable(new Constant(getMathSymbol(model.getFARADAY_CONSTANT(), null), getIdentifierSubstitutions(model.getFARADAY_CONSTANT().getExpression(), model.getFARADAY_CONSTANT().getUnitDefinition(), null)));
varHash.addVariable(new Constant(getMathSymbol(model.getFARADAY_CONSTANT_NMOLE(), null), getIdentifierSubstitutions(model.getFARADAY_CONSTANT_NMOLE().getExpression(), model.getFARADAY_CONSTANT_NMOLE().getUnitDefinition(), null)));
varHash.addVariable(new Constant(getMathSymbol(model.getGAS_CONSTANT(), null), getIdentifierSubstitutions(model.getGAS_CONSTANT().getExpression(), model.getGAS_CONSTANT().getUnitDefinition(), null)));
varHash.addVariable(new Constant(getMathSymbol(model.getTEMPERATURE(), null), getIdentifierSubstitutions(new Expression(simContext.getTemperatureKelvin()), model.getTEMPERATURE().getUnitDefinition(), null)));
Enumeration<SpeciesContextMapping> enum1 = getSpeciesContextMappings();
while (enum1.hasMoreElements()) {
SpeciesContextMapping scm = enum1.nextElement();
if (scm.getVariable() instanceof StochVolVariable) {
varHash.addVariable(scm.getVariable());
}
}
// deals with model parameters
ModelParameter[] modelParameters = simContext.getModel().getModelParameters();
for (int j = 0; j < modelParameters.length; j++) {
Expression expr = getSubstitutedExpr(modelParameters[j].getExpression(), true, false);
expr = getIdentifierSubstitutions(expr, modelParameters[j].getUnitDefinition(), geometryClass);
varHash.addVariable(newFunctionOrConstant(getMathSymbol(modelParameters[j], geometryClass), expr, geometryClass));
}
// added July 2009, ElectricalStimulusParameter electric mapping tab
ElectricalStimulus[] elecStimulus = simContext.getElectricalStimuli();
if (elecStimulus.length > 0) {
throw new MappingException("Modles with electrophysiology are not supported for stochastic applications.");
}
for (int j = 0; j < structureMappings.length; j++) {
if (structureMappings[j] instanceof MembraneMapping) {
MembraneMapping memMapping = (MembraneMapping) structureMappings[j];
Parameter initialVoltageParm = memMapping.getInitialVoltageParameter();
try {
Expression exp = initialVoltageParm.getExpression();
exp.evaluateConstant();
varHash.addVariable(newFunctionOrConstant(getMathSymbol(memMapping.getMembrane().getMembraneVoltage(), memMapping.getGeometryClass()), getIdentifierSubstitutions(memMapping.getInitialVoltageParameter().getExpression(), memMapping.getInitialVoltageParameter().getUnitDefinition(), memMapping.getGeometryClass()), memMapping.getGeometryClass()));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new MappingException("Membrane initial voltage: " + initialVoltageParm.getName() + " cannot be evaluated as constant.");
}
}
}
//
for (ReactionRule reactionRule : rrList) {
// if (reactionRule.getKineticLaw() instanceof LumpedKinetics){
// throw new RuntimeException("Lumped Kinetics not yet supported for RuleBased Modeling");
// }
LocalParameter[] parameters = reactionRule.getKineticLaw().getLocalParameters();
for (LocalParameter parameter : parameters) {
//
if ((parameter.getRole() == RbmKineticLawParameterType.RuleRate)) {
continue;
}
//
if (!reactionRule.isReversible() && parameter.getRole() == RbmKineticLawParameterType.MassActionReverseRate) {
continue;
}
Expression expr = getSubstitutedExpr(parameter.getExpression(), true, false);
varHash.addVariable(newFunctionOrConstant(getMathSymbol(parameter, geometryClass), getIdentifierSubstitutions(expr, parameter.getUnitDefinition(), geometryClass), geometryClass));
}
}
// the parameter "Size" is already put into mathsymbolmapping in refreshSpeciesContextMapping()
for (int i = 0; i < structureMappings.length; i++) {
StructureMapping sm = structureMappings[i];
StructureMapping.StructureMappingParameter parm = sm.getParameterFromRole(StructureMapping.ROLE_Size);
if (parm.getExpression() != null) {
try {
double value = parm.getExpression().evaluateConstant();
varHash.addVariable(new Constant(getMathSymbol(parm, sm.getGeometryClass()), new Expression(value)));
} catch (ExpressionException e) {
// varHash.addVariable(new Function(getMathSymbol0(parm,sm),getIdentifierSubstitutions(parm.getExpression(),parm.getUnitDefinition(),sm)));
e.printStackTrace(System.out);
throw new MappingException("Size of structure:" + sm.getNameScope().getName() + " cannot be evaluated as constant.");
}
}
}
SpeciesContextSpec[] speciesContextSpecs = getSimulationContext().getReactionContext().getSpeciesContextSpecs();
addInitialConditions(domain, speciesContextSpecs, varHash);
//
if (simContext.getGeometryContext().getGeometry() != null) {
try {
mathDesc.setGeometry(simContext.getGeometryContext().getGeometry());
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
throw new MappingException("failure setting geometry " + e.getMessage());
}
} else {
throw new MappingException("Geometry must be defined in Application " + simContext.getName());
}
//
// create subDomains
//
SubVolume subVolume = simContext.getGeometry().getGeometrySpec().getSubVolumes()[0];
SubDomain subDomain = new CompartmentSubDomain(subVolume.getName(), 0);
mathDesc.addSubDomain(subDomain);
//
// define all molecules and unique species patterns (add molecules to mathDesc and speciesPatterns to varHash).
//
HashMap<SpeciesPattern, VolumeParticleSpeciesPattern> speciesPatternMap = addSpeciesPatterns(domain, rrList);
HashSet<VolumeParticleSpeciesPattern> uniqueParticleSpeciesPatterns = new HashSet<>(speciesPatternMap.values());
for (VolumeParticleSpeciesPattern volumeParticleSpeciesPattern : uniqueParticleSpeciesPatterns) {
varHash.addVariable(volumeParticleSpeciesPattern);
}
//
// define observables (those explicitly declared and those corresponding to seed species.
//
List<ParticleObservable> observables = addObservables(geometryClass, domain, speciesPatternMap);
for (ParticleObservable particleObservable : observables) {
varHash.addVariable(particleObservable);
}
try {
addParticleJumpProcesses(varHash, geometryClass, subDomain, speciesPatternMap);
} catch (PropertyVetoException e1) {
e1.printStackTrace();
throw new MappingException(e1.getMessage(), e1);
}
//
for (int i = 0; i < fieldMathMappingParameters.length; i++) {
if (fieldMathMappingParameters[i] instanceof UnitFactorParameter || fieldMathMappingParameters[i] instanceof ObservableConcentrationParameter) {
varHash.addVariable(newFunctionOrConstant(getMathSymbol(fieldMathMappingParameters[i], geometryClass), getIdentifierSubstitutions(fieldMathMappingParameters[i].getExpression(), fieldMathMappingParameters[i].getUnitDefinition(), geometryClass), fieldMathMappingParameters[i].getGeometryClass()));
}
}
//
// set Variables to MathDescription all at once with the order resolved by "VariableHash"
//
mathDesc.setAllVariables(varHash.getAlphabeticallyOrderedVariables());
//
for (SpeciesContext sc : model.getSpeciesContexts()) {
if (!sc.hasSpeciesPattern()) {
throw new MappingException("species " + sc.getName() + " has no molecular pattern");
}
VolumeParticleSpeciesPattern volumeParticleSpeciesPattern = speciesPatternMap.get(sc.getSpeciesPattern());
ArrayList<ParticleInitialCondition> particleInitialConditions = new ArrayList<ParticleProperties.ParticleInitialCondition>();
// initial conditions from scs
SpeciesContextSpec scs = simContext.getReactionContext().getSpeciesContextSpec(sc);
Parameter initialCountParameter = scs.getInitialCountParameter();
Expression e = getIdentifierSubstitutions(new Expression(initialCountParameter, getNameScope()), initialCountParameter.getUnitDefinition(), geometryClass);
particleInitialConditions.add(new ParticleInitialConditionCount(e, new Expression(0.0), new Expression(0.0), new Expression(0.0)));
ParticleProperties particleProperies = new ParticleProperties(volumeParticleSpeciesPattern, new Expression(0.0), new Expression(0.0), new Expression(0.0), new Expression(0.0), particleInitialConditions);
subDomain.addParticleProperties(particleProperies);
}
//
for (int i = 0; i < fieldMathMappingParameters.length; i++) {
if (fieldMathMappingParameters[i] instanceof UnitFactorParameter) {
Variable variable = newFunctionOrConstant(getMathSymbol(fieldMathMappingParameters[i], geometryClass), getIdentifierSubstitutions(fieldMathMappingParameters[i].getExpression(), fieldMathMappingParameters[i].getUnitDefinition(), geometryClass), fieldMathMappingParameters[i].getGeometryClass());
if (mathDesc.getVariable(variable.getName()) == null) {
mathDesc.addVariable(variable);
}
}
if (fieldMathMappingParameters[i] instanceof ObservableConcentrationParameter) {
Variable variable = newFunctionOrConstant(getMathSymbol(fieldMathMappingParameters[i], geometryClass), getIdentifierSubstitutions(fieldMathMappingParameters[i].getExpression(), fieldMathMappingParameters[i].getUnitDefinition(), geometryClass), fieldMathMappingParameters[i].getGeometryClass());
if (mathDesc.getVariable(variable.getName()) == null) {
mathDesc.addVariable(variable);
}
}
}
if (!mathDesc.isValid()) {
System.out.println(mathDesc.getVCML_database());
throw new MappingException("generated an invalid mathDescription: " + mathDesc.getWarning());
}
}
use of cbit.vcell.math.ParticleObservable in project vcell by virtualcell.
the class NFsimXMLWriter method getListOfObservables.
private static Element getListOfObservables(MathDescription mathDesc) throws SolverException {
Element listOfObservablesElement = new Element("ListOfObservables");
int observableIndex = 0;
Enumeration<Variable> enum1 = mathDesc.getVariables();
while (enum1.hasMoreElements()) {
Variable var = enum1.nextElement();
if (var instanceof ParticleObservable) {
ParticleObservable particleObservable = (ParticleObservable) var;
Element observableElement = new Element("Observable");
String observableId = "O" + (observableIndex + 1);
observableElement.setAttribute("id", observableId);
observableElement.setAttribute("name", particleObservable.getName());
observableElement.setAttribute("type", particleObservable.getType().getText());
Element listOfPatterns = getParticleSpeciesPatternList(observableId, particleObservable);
observableElement.addContent(listOfPatterns);
listOfObservablesElement.addContent(observableElement);
observableIndex++;
}
}
Format format = Format.getPrettyFormat();
XMLOutputter outp = new XMLOutputter(format);
String sOurs = outp.outputString(listOfObservablesElement);
return listOfObservablesElement;
}
use of cbit.vcell.math.ParticleObservable in project vcell by virtualcell.
the class NFsimXMLWriter method getListOfFunctions.
private static Element getListOfFunctions(MathDescription mathDesc, SimulationSymbolTable simulationSymbolTable) throws SolverException {
Element listOfParametersElement = new Element("ListOfFunctions");
for (Variable var : simulationSymbolTable.getVariables()) {
Double value = null;
if (var instanceof Constant || var instanceof Function) {
Expression valExpression = var.getExpression();
Expression substitutedValExpr = null;
try {
substitutedValExpr = simulationSymbolTable.substituteFunctions(valExpression);
} catch (Exception e) {
e.printStackTrace(System.out);
throw new SolverException("Constant or Function " + var.getName() + " substitution failed : exp = \"" + var.getExpression().infix() + "\": " + e.getMessage());
}
try {
value = substitutedValExpr.evaluateConstant();
} catch (ExpressionException e) {
System.out.println("constant or function " + var.getName() + " = " + substitutedValExpr.infix() + " does not have a constant value");
}
Element functionElement = new Element("Function");
functionElement.setAttribute("id", var.getName());
if (value != null) {
// parameter, see getListOfParameters() above
continue;
} else {
Element listOfReferencesElement = new Element("ListOfReferences");
String[] references = valExpression.getSymbols();
for (int i = 0; i < references.length; i++) {
String reference = references[i];
Element referenceElement = new Element("Reference");
referenceElement.setAttribute("name", reference);
Variable referenceVariable = simulationSymbolTable.getVariable(reference);
Double referenceValue = null;
Expression referenceExpression = referenceVariable.getExpression();
Expression substitutedReferenceExpression = null;
if (referenceExpression != null) {
try {
substitutedReferenceExpression = simulationSymbolTable.substituteFunctions(referenceExpression);
} catch (Exception e) {
e.printStackTrace(System.out);
throw new SolverException("Constant or Function " + var.getName() + " substitution failed : exp = \"" + var.getExpression().infix() + "\": " + e.getMessage());
}
try {
referenceValue = substitutedReferenceExpression.evaluateConstant();
} catch (ExpressionException e) {
System.out.println("constant or function " + var.getName() + " = " + substitutedValExpr.infix() + " does not have a constant value");
}
}
if (referenceVariable instanceof ParticleObservable) {
referenceElement.setAttribute("type", "Observable");
} else if (referenceVariable instanceof Function) {
if (referenceValue != null) {
referenceElement.setAttribute("type", "ConstantExpression");
} else {
referenceElement.setAttribute("type", "Function");
}
} else {
// constant
referenceElement.setAttribute("type", "ConstantExpression");
}
listOfReferencesElement.addContent(referenceElement);
}
functionElement.addContent(listOfReferencesElement);
Element expressionElement = new Element("Expression");
String functionExpression = valExpression.infix();
expressionElement.setText(functionExpression);
functionElement.addContent(expressionElement);
}
listOfParametersElement.addContent(functionElement);
}
}
return listOfParametersElement;
}
use of cbit.vcell.math.ParticleObservable in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a MathDescription object.
* Creation date: (3/2/2001 10:57:25 AM)
* @return Element
* @param mathdes cbit.vcell.math.MathDescription
*/
Element getXML(MathDescription mathdes) throws XmlParseException {
Element math = new Element(XMLTags.MathDescriptionTag);
// Add attributes
math.setAttribute(XMLTags.NameAttrTag, mangle(mathdes.getName()));
// Add annotation
if (mathdes.getDescription() != null && mathdes.getDescription().length() > 0) {
Element annotationElem = new Element(XMLTags.AnnotationTag);
annotationElem.setText(mangle(mathdes.getDescription()));
math.addContent(annotationElem);
}
List<ParticleMolecularType> particleMolecularTypes = mathdes.getParticleMolecularTypes();
for (ParticleMolecularType particleMolecularType : particleMolecularTypes) {
math.addContent(getXML(particleMolecularType));
}
// Add Constant subelements
Enumeration<Variable> enum1 = mathdes.getVariables();
/*java.util.Iterator k;
try {
VariableHash varHash = new VariableHash();
while (enum1.hasMoreElements())
varHash.addVariable((Variable)enum1.nextElement());
Variable vars [] = varHash.getReorderedVariables();
k = new ArrayList(java.util.Arrays.asList(vars)).iterator();
} catch (cbit.vcell.mapping.MappingException e) {
e.printStackTrace();
return null;
}*/
while (enum1.hasMoreElements()) {
Variable var = enum1.nextElement();
Element element = null;
if (var instanceof Constant) {
element = getXML((Constant) var);
} else if (var instanceof FilamentRegionVariable) {
element = getXML((FilamentRegionVariable) var);
} else if (var instanceof FilamentVariable) {
element = getXML((FilamentVariable) var);
} else if (var instanceof PointVariable) {
element = getXML((PointVariable) var);
} else if (var instanceof Function) {
element = getXML((Function) var);
} else if (var instanceof RandomVariable) {
element = getXML((RandomVariable) var);
} else if (var instanceof InsideVariable) {
// *** for internal use! Ignore it ***
continue;
} else if (var instanceof MembraneRegionVariable) {
element = getXML((MembraneRegionVariable) var);
} else if (var instanceof MemVariable) {
element = getXML((MemVariable) var);
} else if (var instanceof OutsideVariable) {
// *** for internal use! Ignore it ****
continue;
} else if (var instanceof VolumeRegionVariable) {
element = getXML((VolumeRegionVariable) var);
} else if (var instanceof VolVariable) {
element = getXML((VolVariable) var);
} else if (var instanceof StochVolVariable) {
// added for stochastic volumn variables
element = getXML((StochVolVariable) var);
} else if (var instanceof ParticleVariable) {
element = getXML((ParticleVariable) var);
} else if (var instanceof ParticleObservable) {
element = getXML((ParticleObservable) var);
} else {
throw new XmlParseException("An unknown variable type " + var.getClass().getName() + " was found when parsing the mathdescription " + mathdes.getName() + "!");
}
transcribeComments(var, element);
math.addContent(element);
}
// this was moved to the simspec!
/* buffer.append("\n");
if (geometry != null){
buffer.append(geometry.getXML());
}
buffer.append("\n");*/
// Add subdomains
Enumeration<SubDomain> enum2 = mathdes.getSubDomains();
while (enum2.hasMoreElements()) {
SubDomain subDomain = enum2.nextElement();
math.addContent(getXML(subDomain));
}
// Add Metadata (Version) if there is!
if (mathdes.getVersion() != null) {
math.addContent(getXML(mathdes.getVersion(), mathdes));
}
Iterator<Event> iter = mathdes.getEvents();
while (iter.hasNext()) {
math.addContent(getXML(iter.next()));
}
PostProcessingBlock postProcessingBlock = mathdes.getPostProcessingBlock();
if (postProcessingBlock.getNumDataGenerators() > 0) {
math.addContent(getXML(postProcessingBlock));
}
return math;
}
use of cbit.vcell.math.ParticleObservable in project vcell by virtualcell.
the class RulebasedMathMapping method addObservables.
private List<ParticleObservable> addObservables(GeometryClass geometryClass, Domain domain, HashMap<SpeciesPattern, VolumeParticleSpeciesPattern> speciesPatternMap) throws MappingException, MathException {
ArrayList<ParticleObservable> observables = new ArrayList<>();
//
for (MathMappingParameter mathMappingParameter : getMathMappingParameters()) {
if (mathMappingParameter instanceof ObservableCountParameter) {
ObservableCountParameter observableCountParameter = (ObservableCountParameter) mathMappingParameter;
RbmObservable rbmObservable = observableCountParameter.getObservable();
ParticleObservable.ObservableType particleObservableType = null;
if (rbmObservable.getType() == RbmObservable.ObservableType.Molecules) {
particleObservableType = ParticleObservable.ObservableType.Molecules;
} else {
particleObservableType = ParticleObservable.ObservableType.Species;
}
ParticleObservable particleObservable = new VolumeParticleObservable(getMathSymbol(observableCountParameter, geometryClass), domain, particleObservableType);
switch(rbmObservable.getSequence()) {
case Multimolecular:
{
particleObservable.setSequence(Sequence.Multimolecular);
break;
}
case PolymerLengthEqual:
{
particleObservable.setSequence(Sequence.PolymerLengthEqual);
particleObservable.setQuantity(rbmObservable.getSequenceLength());
break;
}
case PolymerLengthGreater:
{
particleObservable.setSequence(Sequence.PolymerLengthGreater);
particleObservable.setQuantity(rbmObservable.getSequenceLength());
break;
}
default:
{
throw new RuntimeException("unexpected sequence " + rbmObservable.getSequence());
}
}
for (SpeciesPattern speciesPattern : rbmObservable.getSpeciesPatternList()) {
VolumeParticleSpeciesPattern vpsp = speciesPatternMap.get(speciesPattern);
particleObservable.addParticleSpeciesPattern(vpsp);
}
observables.add(particleObservable);
}
if (mathMappingParameter instanceof SpeciesCountParameter) {
SpeciesCountParameter speciesCountParameter = (SpeciesCountParameter) mathMappingParameter;
ParticleObservable.ObservableType particleObservableType = ParticleObservable.ObservableType.Species;
ParticleObservable particleObservable = new VolumeParticleObservable(getMathSymbol(speciesCountParameter, geometryClass), domain, particleObservableType);
particleObservable.setSequence(Sequence.Multimolecular);
SpeciesPattern speciesPattern = speciesCountParameter.getSpeciesContext().getSpeciesPattern();
VolumeParticleSpeciesPattern vpsp = speciesPatternMap.get(speciesPattern);
particleObservable.addParticleSpeciesPattern(vpsp);
observables.add(particleObservable);
}
}
return observables;
}
Aggregations