Search in sources :

Example 6 with ParticleComponentStateDefinition

use of cbit.vcell.math.ParticleComponentStateDefinition in project vcell by virtualcell.

the class XmlReader method getParticleMolecularComponentPattern.

private ParticleMolecularComponentPattern getParticleMolecularComponentPattern(Element param, ParticleMolecularType particleMolecularType) throws XmlParseException {
    String molecularComponentName = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    ParticleMolecularComponent particleMolecularComponent = particleMolecularType.getMolecularComponent(molecularComponentName);
    if (particleMolecularComponent != null) {
        ParticleMolecularComponentPattern var = new ParticleMolecularComponentPattern(particleMolecularComponent);
        ParticleComponentStatePattern pcsp = null;
        String componentStateName = unMangle(param.getAttributeValue(XMLTags.StateAttrTag));
        if (componentStateName.equals("*")) {
            pcsp = new ParticleComponentStatePattern();
        } else {
            // ParticleComponentStateDefinition pcsd = new ParticleComponentStateDefinition(componentStateName);		// bad??
            ParticleComponentStateDefinition pcsd = particleMolecularComponent.getComponentStateDefinition(componentStateName);
            if (pcsd == null) {
                throw new XmlParseException("failed to find ParticleComponentStateDefinition named " + molecularComponentName);
            }
            pcsp = new ParticleComponentStatePattern(pcsd);
        }
        var.setComponentStatePattern(pcsp);
        String bondString = unMangle(param.getAttributeValue(XMLTags.BondAttrTag));
        ParticleBondType bondType = ParticleBondType.fromSymbol(bondString);
        if (bondType == ParticleBondType.Specified) {
            int bondId = Integer.parseInt(bondString);
            var.setBondId(bondId);
        }
        var.setBondType(bondType);
        return var;
    } else {
        throw new XmlParseException("failed to find ParticleMolecularComponent named " + molecularComponentName);
    }
}
Also used : ParticleComponentStatePattern(cbit.vcell.math.ParticleComponentStatePattern) ParticleMolecularComponentPattern(cbit.vcell.math.ParticleMolecularComponentPattern) ParticleComponentStateDefinition(cbit.vcell.math.ParticleComponentStateDefinition) ParticleBondType(cbit.vcell.math.ParticleMolecularComponentPattern.ParticleBondType) ParticleMolecularComponent(cbit.vcell.math.ParticleMolecularComponent)

Example 7 with ParticleComponentStateDefinition

use of cbit.vcell.math.ParticleComponentStateDefinition in project vcell by virtualcell.

the class NFsimXMLWriter method getListOfAllowedStates.

private static Element getListOfAllowedStates(ParticleMolecularComponent molecularComponent) {
    if (molecularComponent.getComponentStateDefinitions().isEmpty()) {
        return null;
    }
    Element listOfAllowedStates = new Element("ListOfAllowedStates");
    for (ParticleComponentStateDefinition componentStateDefinition : molecularComponent.getComponentStateDefinitions()) {
        Element allowedStateElement = new Element("AllowedState");
        allowedStateElement.setAttribute("id", componentStateDefinition.getName());
        listOfAllowedStates.addContent(allowedStateElement);
    }
    return listOfAllowedStates;
}
Also used : ParticleComponentStateDefinition(cbit.vcell.math.ParticleComponentStateDefinition) Element(org.jdom.Element)

Example 8 with ParticleComponentStateDefinition

use of cbit.vcell.math.ParticleComponentStateDefinition in project vcell by virtualcell.

the class NFsimXMLWriter method getListOfComponents1.

private static Element getListOfComponents1(String reactionRuleID, String patternID, String moleculeID, ParticleSpeciesPattern speciesPattern, ParticleMolecularTypePattern particleMolecularTypePattern, ArrayList<ComponentOfMolecularTypeOfReactionParticipant> currentComponentOfParticipant, HashMap<Bond, BondSites> bondSitesMap) throws SolverException {
    // while traversing Components of a MolecularTypePattern, it populates bondSiteMapping
    Element listOfComponentsElement = new Element("ListOfComponents");
    for (int componentId = 0; componentId < particleMolecularTypePattern.getMolecularComponentPatternList().size(); componentId++) {
        ParticleMolecularComponentPattern particleMolecularComponentPattern = particleMolecularTypePattern.getMolecularComponentPatternList().get(componentId);
        Element componentElement = new Element("Component");
        ParticleMolecularComponent particleMolecularComponent = particleMolecularComponentPattern.getMolecularComponent();
        // componentElement.setAttribute("id", particleMolecularComponent.getId());
        String elementID = "C" + (componentId + 1);
        String componentID = reactionRuleID + "_" + patternID + "_" + moleculeID + "_" + elementID;
        componentElement.setAttribute("id", componentID);
        componentElement.setAttribute("name", particleMolecularComponent.getName());
        ParticleComponentStatePattern componentStatePattern = particleMolecularComponentPattern.getComponentStatePattern();
        ParticleComponentStateDefinition pcsd = componentStatePattern.getParticleComponentStateDefinition();
        String state = "";
        boolean ignoreFlagState = false;
        if (componentStatePattern.isAny()) {
            state = "*";
            ignoreFlagState = true;
        } else if (pcsd != null) {
            state = pcsd.getName();
            componentElement.setAttribute("state", state);
        } else {
            throw new RuntimeException("Invalid state for ParticleComponentStatePattern.");
        }
        // ParticleComponentState componentState = particleMolecularComponentPattern.getComponentState();
        // String state = "";
        // if (componentState!=null){
        // state = componentState.getName();
        // if(!state.equals("*")) {
        // componentElement.setAttribute("state", state);
        // }
        // }
        ComponentOfMolecularTypeOfReactionParticipant cper = new ComponentOfMolecularTypeOfReactionParticipant(particleMolecularTypePattern.getMolecularType().getName(), particleMolecularTypePattern.getMatchLabel(), particleMolecularComponent.getName(), componentID, state);
        // number of bonds is 0 or 1 for species (concrete species).  the bonds are listed later in the list of bonds
        ParticleBondType bondType = particleMolecularComponentPattern.getBondType();
        boolean ignoreFlagBond = false;
        switch(bondType) {
            case Exists:
                {
                    componentElement.setAttribute("numberOfBonds", bondType.symbol);
                    break;
                }
            case None:
                {
                    componentElement.setAttribute("numberOfBonds", "0");
                    break;
                }
            case Possible:
                {
                    componentElement.setAttribute("numberOfBonds", bondType.symbol);
                    ignoreFlagBond = true;
                    break;
                }
            case Specified:
                {
                    if (particleMolecularComponentPattern.getBondId() >= 0) {
                        componentElement.setAttribute("numberOfBonds", "1");
                        String bondID = reactionRuleID + "_" + patternID + "_B" + particleMolecularComponentPattern.getBondId();
                        Bond bond = new Bond(bondID, speciesPattern);
                        BondSites bondSites = bondSitesMap.get(bond);
                        if (bondSites == null) {
                            BondSites newBondSite = new BondSites();
                            newBondSite.component1 = componentID;
                            bondSitesMap.put(bond, newBondSite);
                        } else {
                            if (bondSites.component1.equals(componentID) || bondSites.component2.equals(componentID)) {
                                throw new SolverException("this molecularComponentPattern already set in bondSites");
                            }
                            if (bondSites.component2.equals("")) {
                                bondSites.component2 = componentID;
                            } else {
                                throw new SolverException("two other molecularComponentPatterns already set in bondSites");
                            }
                        }
                    } else {
                        componentElement.setAttribute("numberOfBonds", "0");
                    }
                    break;
                }
        }
        if (ignoreFlagState == false || ignoreFlagBond == false) {
            currentComponentOfParticipant.add(cper);
            listOfComponentsElement.addContent(componentElement);
        }
    }
    return listOfComponentsElement;
}
Also used : ParticleComponentStatePattern(cbit.vcell.math.ParticleComponentStatePattern) Element(org.jdom.Element) ParticleBondType(cbit.vcell.math.ParticleMolecularComponentPattern.ParticleBondType) ParticleMolecularComponent(cbit.vcell.math.ParticleMolecularComponent) ParticleMolecularComponentPattern(cbit.vcell.math.ParticleMolecularComponentPattern) ParticleComponentStateDefinition(cbit.vcell.math.ParticleComponentStateDefinition) SolverException(cbit.vcell.solver.SolverException)

Aggregations

ParticleComponentStateDefinition (cbit.vcell.math.ParticleComponentStateDefinition)8 ParticleMolecularComponent (cbit.vcell.math.ParticleMolecularComponent)6 Element (org.jdom.Element)6 ParticleComponentStatePattern (cbit.vcell.math.ParticleComponentStatePattern)5 ParticleMolecularComponentPattern (cbit.vcell.math.ParticleMolecularComponentPattern)5 ParticleBondType (cbit.vcell.math.ParticleMolecularComponentPattern.ParticleBondType)3 SolverException (cbit.vcell.solver.SolverException)3 ParticleMolecularType (cbit.vcell.math.ParticleMolecularType)2 ParticleMolecularTypePattern (cbit.vcell.math.ParticleMolecularTypePattern)2 VolumeParticleSpeciesPattern (cbit.vcell.math.VolumeParticleSpeciesPattern)2 ArrayList (java.util.ArrayList)2 Action (cbit.vcell.math.Action)1 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)1 JumpProcessRateDefinition (cbit.vcell.math.JumpProcessRateDefinition)1 MacroscopicRateConstant (cbit.vcell.math.MacroscopicRateConstant)1 MathDescription (cbit.vcell.math.MathDescription)1 MathException (cbit.vcell.math.MathException)1 MathRuleFactory (cbit.vcell.math.MathRuleFactory)1 MathRuleEntry (cbit.vcell.math.MathRuleFactory.MathRuleEntry)1 ParticleJumpProcess (cbit.vcell.math.ParticleJumpProcess)1