use of cbit.vcell.model.RbmKineticLaw.RateLawType in project vcell by virtualcell.
the class ReactionRule method duplicate.
public static ReactionRule duplicate(ReactionRule oldRule, Structure s) throws ExpressionBindingException {
Model m = oldRule.getModel();
boolean bR = oldRule.isReversible();
String newName = ReactionRule.deriveReactionName(oldRule);
ReactionRule newRule = new ReactionRule(m, newName, s, bR);
RateLawType rateLawType = oldRule.getKineticLaw().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 kineticLaw = new RbmKineticLaw(newRule, rateLawType);
RbmKineticLaw.duplicate(kineticLaw, oldRule);
for (ReactantPattern oldrp : oldRule.getReactantPatterns()) {
SpeciesPattern newsp = new SpeciesPattern(m, oldrp.getSpeciesPattern());
ReactantPattern newrp = new ReactantPattern(newsp, oldrp.getStructure());
// don't try to resolve matches or bonds, we want to mirror whatever is in the old rule
newRule.addReactant(newrp, false, false);
}
for (ProductPattern oldpp : oldRule.getProductPatterns()) {
SpeciesPattern newsp = new SpeciesPattern(m, oldpp.getSpeciesPattern());
ProductPattern newpp = new ProductPattern(newsp, oldpp.getStructure());
newRule.addProduct(newpp, false, false);
}
newRule.setKineticLaw(kineticLaw);
kineticLaw.bind(newRule);
return newRule;
}
Aggregations