Search in sources :

Example 81 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class RbmObservable method findComponentUsage.

public void findComponentUsage(MolecularType mt, MolecularComponent mc, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    for (SpeciesPattern sp : getSpeciesPatternList()) {
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        // we don't care about these
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        // found mc in use
                        String key = sp.getDisplayName();
                        key = getDisplayType() + getDisplayName() + key;
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 82 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class RbmObservable method duplicate.

public static RbmObservable duplicate(RbmObservable oldObservable, Structure s, Model m) throws ExpressionBindingException, PropertyVetoException, ModelException {
    String newName = RbmObservable.deriveObservableName(oldObservable, m);
    RbmObservable newObservable = new RbmObservable(m, newName, s, oldObservable.getType());
    for (SpeciesPattern oldsp : oldObservable.getSpeciesPatternList()) {
        SpeciesPattern newsp = new SpeciesPattern(m, oldsp);
        newObservable.addSpeciesPattern(newsp);
    }
    newObservable.setSequenceLength(Sequence.PolymerLengthEqual, oldObservable.getSequenceLength(Sequence.PolymerLengthEqual));
    newObservable.setSequenceLength(Sequence.PolymerLengthGreater, oldObservable.getSequenceLength(Sequence.PolymerLengthGreater));
    newObservable.setSequence(oldObservable.getSequence());
    m.getRbmModelContainer().addObservable(newObservable);
    return newObservable;
}
Also used : SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 83 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class ReactionRule method findComponentUsage.

// TODO: almost identical to findStateUsage() below - pay attention to keep both in sync
public void findComponentUsage(MolecularType mt, MolecularComponent mc, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    for (ProductPattern pp : getProductPatterns()) {
        SpeciesPattern sp = pp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        // we don't care about these
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        // found mc in use
                        String key = getDisplayType() + getDisplayName() + sp.getDisplayName();
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
    for (ReactantPattern rp : getReactantPatterns()) {
        SpeciesPattern sp = rp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (MolecularComponentPattern mcp : componentPatterns) {
                    if (mcp.isImplied()) {
                        continue;
                    }
                    if (mcp.getMolecularComponent() == mc) {
                        String key = getDisplayType() + getDisplayName() + sp.getDisplayName();
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 84 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class ReactionRule method deriveInverseRule.

// returns a new rule consisting of the "inverse" part of the reversible old rule
public static ReactionRule deriveInverseRule(ReactionRule oldRule) throws ExpressionBindingException, PropertyVetoException {
    Model m = oldRule.getModel();
    Structure s = oldRule.getStructure();
    boolean bR = false;
    String newName = oldRule.getDisplayName() + InverseHalf;
    ReactionRule newRule = new ReactionRule(m, newName, s, bR);
    RbmKineticLaw oldLaw = oldRule.getKineticLaw();
    RateLawType rateLawType = oldLaw.getRateLawType();
    if (rateLawType != RateLawType.MassAction) {
        throw new RuntimeException("Only Mass Action Kinetics supported at this time, " + ReactionRule.typeName + " \"" + oldRule.getName() + "\" uses kinetic law type \"" + rateLawType.toString() + "\"");
    }
    RbmKineticLaw newLaw = new RbmKineticLaw(newRule, rateLawType);
    newRule.setKineticLaw(newLaw);
    LocalParameter oldfr = oldLaw.getLocalParameter(RbmKineticLawParameterType.MassActionReverseRate);
    Expression exp = oldfr.getExpression();
    newLaw.setLocalParameterValue(RbmKineticLawParameterType.MassActionForwardRate, exp);
    for (ReactantPattern oldrp : oldRule.getReactantPatterns()) {
        SpeciesPattern newsp = new SpeciesPattern(m, oldrp.getSpeciesPattern());
        ProductPattern newrp = new ProductPattern(newsp, oldrp.getStructure());
        newRule.addProduct(newrp, false, false);
    }
    for (ProductPattern oldpp : oldRule.getProductPatterns()) {
        SpeciesPattern newsp = new SpeciesPattern(m, oldpp.getSpeciesPattern());
        ReactantPattern newpp = new ReactantPattern(newsp, oldpp.getStructure());
        newRule.addReactant(newpp, false, false);
    }
    newLaw.bind(newRule);
    return newRule;
}
Also used : SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) Expression(cbit.vcell.parser.Expression) RateLawType(cbit.vcell.model.RbmKineticLaw.RateLawType)

Example 85 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class ReactionRule method deleteComponentFromPatterns.

public boolean deleteComponentFromPatterns(MolecularType mt, MolecularComponent mc) {
    for (ProductPattern pp : getProductPatterns()) {
        SpeciesPattern sp = pp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (Iterator<MolecularComponentPattern> iterator = componentPatterns.iterator(); iterator.hasNext(); ) {
                    MolecularComponentPattern mcp = iterator.next();
                    if (mcp.getMolecularComponent() == mc) {
                        iterator.remove();
                    }
                }
            }
        }
        sp.resolveBonds();
    }
    for (ReactantPattern rp : getReactantPatterns()) {
        SpeciesPattern sp = rp.getSpeciesPattern();
        for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
            if (mtp.getMolecularType() == mt) {
                List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
                for (Iterator<MolecularComponentPattern> iterator = componentPatterns.iterator(); iterator.hasNext(); ) {
                    MolecularComponentPattern mcp = iterator.next();
                    if (mcp.getMolecularComponent() == mc) {
                        iterator.remove();
                    }
                }
            }
        }
        sp.resolveBonds();
    }
    return true;
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Aggregations

SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)93 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)39 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)30 MolecularType (org.vcell.model.rbm.MolecularType)25 RbmObservable (cbit.vcell.model.RbmObservable)22 SpeciesContext (cbit.vcell.model.SpeciesContext)22 Structure (cbit.vcell.model.Structure)22 Point (java.awt.Point)18 ReactionRule (cbit.vcell.model.ReactionRule)16 ArrayList (java.util.ArrayList)16 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)16 Graphics (java.awt.Graphics)13 PropertyVetoException (java.beans.PropertyVetoException)13 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)12 ProductPattern (cbit.vcell.model.ProductPattern)12 ReactantPattern (cbit.vcell.model.ReactantPattern)12 Dimension (java.awt.Dimension)12 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)12 Model (cbit.vcell.model.Model)11 ModelException (cbit.vcell.model.ModelException)11