use of cbit.vcell.math.VolumeParticleObservable in project vcell by virtualcell.
the class XmlReader method getVolumeParticleObservable.
private VolumeParticleObservable getVolumeParticleObservable(Element param, VariableHash varHash) throws XmlParseException {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String domainStr = unMangle(param.getAttributeValue(XMLTags.DomainAttrTag));
Domain domain = null;
if (domainStr != null) {
domain = new Domain(domainStr);
}
String molecularTypeString = unMangle(param.getAttributeValue(XMLTags.ParticleMolecularTypePatternTag));
ObservableType observableType = ObservableType.fromString(molecularTypeString);
VolumeParticleObservable var = new VolumeParticleObservable(name, domain, observableType);
String sequenceAttr = param.getAttributeValue(XMLTags.ParticleObservableSequenceTypeAttrTag);
if (sequenceAttr != null) {
Sequence sequence = Sequence.fromString(sequenceAttr);
String sequenceLength = param.getAttributeValue(XMLTags.ParticleObservableSequenceLengthAttrTag);
var.setSequence(sequence);
if (sequence != Sequence.Multimolecular) {
var.setQuantity(Integer.parseInt(sequenceLength));
}
} else {
var.setSequence(Sequence.Multimolecular);
}
Element volumeParticleSpeciesPatternsElement = param.getChild(XMLTags.VolumeParticleSpeciesPatternsTag, vcNamespace);
List<Element> volumeParticleSpeciesPatternList = volumeParticleSpeciesPatternsElement.getChildren(XMLTags.VolumeParticleSpeciesPatternTag, vcNamespace);
for (Element volumeParticleSpeciesPattern : volumeParticleSpeciesPatternList) {
String volumeParticleSpeciesPatternName = unMangle(volumeParticleSpeciesPattern.getAttributeValue(XMLTags.NameAttrTag));
Variable v = varHash.getVariable(volumeParticleSpeciesPatternName);
if (v == null) {
throw new XmlParseException("failed to find VolumeParticleSpeciesPattern named " + volumeParticleSpeciesPatternName);
}
if (v instanceof ParticleSpeciesPattern) {
var.addParticleSpeciesPattern((ParticleSpeciesPattern) v);
} else {
throw new XmlParseException("Variable " + volumeParticleSpeciesPatternName + " is not a ParticleSpeciesPattern");
}
}
return var;
}
use of cbit.vcell.math.VolumeParticleObservable 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;
}
use of cbit.vcell.math.VolumeParticleObservable in project vcell by virtualcell.
the class Xmlproducer method getXML.
private Element getXML(ParticleObservable param) {
Element e = null;
if (param instanceof VolumeParticleObservable) {
e = new org.jdom.Element(XMLTags.VolumeParticleObservableTag);
} else {
e = new org.jdom.Element(XMLTags.ParticleObservableTag);
}
e.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
if (param.getDomain() != null) {
e.setAttribute(XMLTags.DomainAttrTag, mangle(param.getDomain().getName()));
}
e.setAttribute(XMLTags.ParticleMolecularTypePatternTag, mangle(param.getType().name()));
e.setAttribute(XMLTags.ParticleObservableSequenceTypeAttrTag, mangle(param.getSequence().name()));
if (param.getSequence() == Sequence.PolymerLengthEqual || param.getSequence() == Sequence.PolymerLengthGreater) {
e.setAttribute(XMLTags.ParticleObservableSequenceLengthAttrTag, param.getQuantity().toString());
}
e.addContent(getVolumeParticleSpeciesPatternList(param));
return e;
}
Aggregations