Search in sources :

Example 1 with VolumeParticleObservable

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;
}
Also used : FilamentVariable(cbit.vcell.math.FilamentVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) StochVolVariable(cbit.vcell.math.StochVolVariable) RandomVariable(cbit.vcell.math.RandomVariable) VolumeRandomVariable(cbit.vcell.math.VolumeRandomVariable) VolumeParticleVariable(cbit.vcell.math.VolumeParticleVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) InsideVariable(cbit.vcell.math.InsideVariable) VolVariable(cbit.vcell.math.VolVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) PointVariable(cbit.vcell.math.PointVariable) MembraneRandomVariable(cbit.vcell.math.MembraneRandomVariable) MembraneParticleVariable(cbit.vcell.math.MembraneParticleVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) MemVariable(cbit.vcell.math.MemVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) ObservableType(cbit.vcell.math.ParticleObservable.ObservableType) Element(org.jdom.Element) ParticleSpeciesPattern(cbit.vcell.math.ParticleSpeciesPattern) VolumeParticleSpeciesPattern(cbit.vcell.math.VolumeParticleSpeciesPattern) Sequence(cbit.vcell.math.ParticleObservable.Sequence) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain) VolumeParticleObservable(cbit.vcell.math.VolumeParticleObservable)

Example 2 with VolumeParticleObservable

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;
}
Also used : RbmObservable(cbit.vcell.model.RbmObservable) ArrayList(java.util.ArrayList) VolumeParticleSpeciesPattern(cbit.vcell.math.VolumeParticleSpeciesPattern) VolumeParticleObservable(cbit.vcell.math.VolumeParticleObservable) ParticleObservable(cbit.vcell.math.ParticleObservable) VolumeParticleObservable(cbit.vcell.math.VolumeParticleObservable) VolumeParticleSpeciesPattern(cbit.vcell.math.VolumeParticleSpeciesPattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 3 with VolumeParticleObservable

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;
}
Also used : Element(org.jdom.Element) Element(org.jdom.Element) VolumeParticleObservable(cbit.vcell.math.VolumeParticleObservable)

Aggregations

VolumeParticleObservable (cbit.vcell.math.VolumeParticleObservable)3 VolumeParticleSpeciesPattern (cbit.vcell.math.VolumeParticleSpeciesPattern)2 Element (org.jdom.Element)2 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)1 FilamentRegionVariable (cbit.vcell.math.FilamentRegionVariable)1 FilamentSubDomain (cbit.vcell.math.FilamentSubDomain)1 FilamentVariable (cbit.vcell.math.FilamentVariable)1 InsideVariable (cbit.vcell.math.InsideVariable)1 MemVariable (cbit.vcell.math.MemVariable)1 MembraneParticleVariable (cbit.vcell.math.MembraneParticleVariable)1 MembraneRandomVariable (cbit.vcell.math.MembraneRandomVariable)1 MembraneRegionVariable (cbit.vcell.math.MembraneRegionVariable)1 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)1 OutsideVariable (cbit.vcell.math.OutsideVariable)1 ParticleObservable (cbit.vcell.math.ParticleObservable)1 ObservableType (cbit.vcell.math.ParticleObservable.ObservableType)1 Sequence (cbit.vcell.math.ParticleObservable.Sequence)1 ParticleSpeciesPattern (cbit.vcell.math.ParticleSpeciesPattern)1 ParticleVariable (cbit.vcell.math.ParticleVariable)1 PointSubDomain (cbit.vcell.math.PointSubDomain)1