Search in sources :

Example 6 with RateLawType

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;
}
Also used : RateLawType(cbit.vcell.model.RbmKineticLaw.RateLawType) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Aggregations

RateLawType (cbit.vcell.model.RbmKineticLaw.RateLawType)6 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)5 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)3 Expression (cbit.vcell.parser.Expression)3 RbmKineticLaw (cbit.vcell.model.RbmKineticLaw)2 ReactionRule (cbit.vcell.model.ReactionRule)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 PropertyVetoException (java.beans.PropertyVetoException)2 HashSet (java.util.HashSet)2 ParameterContext (cbit.vcell.mapping.ParameterContext)1 LocalProxyParameter (cbit.vcell.mapping.ParameterContext.LocalProxyParameter)1 ParameterRoleEnum (cbit.vcell.mapping.ParameterContext.ParameterRoleEnum)1 Kinetics (cbit.vcell.model.Kinetics)1 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)1 MassActionKinetics (cbit.vcell.model.MassActionKinetics)1 Model (cbit.vcell.model.Model)1 ModelParameter (cbit.vcell.model.Model.ModelParameter)1 ModelException (cbit.vcell.model.ModelException)1 Product (cbit.vcell.model.Product)1 ProductPattern (cbit.vcell.model.ProductPattern)1