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));
}
}
}
}
}
}
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;
}
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));
}
}
}
}
}
}
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;
}
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;
}
Aggregations