Search in sources :

Example 1 with Catalyst

use of cbit.vcell.model.Catalyst in project vcell by virtualcell.

the class PathwayMapping method createReactionStepFromPathway.

/*
	 * for reaction:
	 * 1. annotate the selected vcell object using linked pathway conversion
	 * 2. add non-existing speciesContexts from linked pathway conversion
	 * 3. add links between relative vcell objects and pathway objects
	 * Questions:
	 * - how to deal with the case that the reaction is existing in the model?
	 * 		+ add it in no matter what? 
	 * 				(this is the version we have now: 
	 * 					add the duplicated reactions in without name changing, 
	 * 				 	all duplicated reactions share the same participant objects)
	 *      + just modify the existing one?
	 */
private void createReactionStepFromPathway(BioModel bioModel, Process process, ReactionStep reactionStep, RelationshipObject relationshipObject, boolean addSubunits) throws Exception {
    // annotate the selected vcell object using linked pathway object
    // add non-existing speciesContexts from linked pathway conversion
    ReactionParticipant[] rpArray = parseReaction(reactionStep, bioModel, relationshipObject);
    // create a hashtable for interaction Participants
    Hashtable<String, BioPaxObject> participantTable = new Hashtable<String, BioPaxObject>();
    for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getLeft()) {
        if (((PhysicalEntity) bpObject).getName().size() == 0) {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
        } else {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
        }
    }
    for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getRight()) {
        if (((PhysicalEntity) bpObject).getName().size() == 0) {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
        } else {
            participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
        }
    }
    for (ReactionParticipant rp : rpArray) {
        SpeciesContext speciesContext = rp.getSpeciesContext();
        if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
            // if the speciesContext is not existed, then add it to the bioModel and link it to the corresponding pathway object
            if (bioModel.getModel().getSpecies(speciesContext.getName()) == null) {
                bioModel.getModel().addSpecies(speciesContext.getSpecies());
            }
            bioModel.getModel().addSpeciesContext(speciesContext);
            RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
            bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
        } else {
            // if it is in the bioModel, then check whether it links to pathway object or not
            HashSet<RelationshipObject> linkedReObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModel.getModel().getSpeciesContext(speciesContext.getName()));
            if (linkedReObjects != null) {
                boolean isLinked = false;
                for (RelationshipObject reObject : linkedReObjects) {
                    if (reObject.getBioPaxObject() == participantTable.get(speciesContext.getName())) {
                        isLinked = true;
                        break;
                    }
                }
                if (!isLinked) {
                    RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
                    bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
                }
            } else {
                RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
                bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
            }
        }
    }
    (reactionStep).setReactionParticipants(rpArray);
    // add Control to the reaction
    if (process.getControl() != null) {
        for (InteractionParticipant pe : process.getControl().getParticipants()) {
            SpeciesContext newSpeciescontext = createSpeciesContextFromBioPaxObject(bioModel, pe.getPhysicalEntity(), addSubunits);
            (reactionStep).addReactionParticipant(new Catalyst(null, reactionStep, newSpeciescontext));
        }
    }
    addKinetics(reactionStep, process);
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) Hashtable(java.util.Hashtable) SpeciesContext(cbit.vcell.model.SpeciesContext) Conversion(org.vcell.pathway.Conversion) PhysicalEntity(org.vcell.pathway.PhysicalEntity) InteractionParticipant(org.vcell.pathway.InteractionParticipant) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Example 2 with Catalyst

use of cbit.vcell.model.Catalyst in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns the XML represntation of a Simple reaction object.
 * Creation date: (2/27/2001 2:27:28 PM)
 * @return Element
 * @param param cbit.vcell.model.SimpleReaction
 */
private Element getXML(SimpleReaction param) throws XmlParseException {
    Element simplereaction = new Element(XMLTags.SimpleReactionTag);
    // Add attribute
    String nameStr = (param.getName() != null) ? (mangle(param.getName())) : "unnamed_SimpleReaction";
    simplereaction.setAttribute(XMLTags.StructureAttrTag, mangle(param.getStructure().getName()));
    simplereaction.setAttribute(XMLTags.NameAttrTag, nameStr);
    simplereaction.setAttribute(XMLTags.ReversibleAttrTag, mangle(Boolean.valueOf(param.isReversible()).toString()));
    if (param.getPhysicsOptions() == SimpleReaction.PHYSICS_ELECTRICAL_ONLY) {
        simplereaction.setAttribute(XMLTags.FluxOptionAttrTag, XMLTags.FluxOptionElectricalOnly);
    } else if (param.getPhysicsOptions() == SimpleReaction.PHYSICS_MOLECULAR_AND_ELECTRICAL) {
        simplereaction.setAttribute(XMLTags.FluxOptionAttrTag, XMLTags.FluxOptionMolecularAndElectrical);
    } else if (param.getPhysicsOptions() == SimpleReaction.PHYSICS_MOLECULAR_ONLY) {
        simplereaction.setAttribute(XMLTags.FluxOptionAttrTag, XMLTags.FluxOptionMolecularOnly);
    }
    // If keyFlag is on print the Keyvalue
    if (param.getKey() != null && this.printKeysFlag) {
        simplereaction.setAttribute(XMLTags.KeyValueAttrTag, param.getKey().toString());
    }
    // Add subelements: Reactants/Products/Catalysts
    // separate the order of the reactants, products, and modifiers.
    ReactionParticipant[] rpArray = param.getReactionParticipants();
    ArrayList<Element> products = new ArrayList<Element>();
    ArrayList<Element> modifiers = new ArrayList<Element>();
    for (int i = 0; i < rpArray.length; i++) {
        Element rp = getXML(rpArray[i]);
        if (rp != null) {
            if (rpArray[i] instanceof Reactant)
                simplereaction.addContent(rp);
            else if (rpArray[i] instanceof Product)
                products.add(rp);
            else if (rpArray[i] instanceof Catalyst)
                modifiers.add(rp);
        }
    }
    for (int i = 0; i < products.size(); i++) simplereaction.addContent((Element) products.get(i));
    for (int i = 0; i < modifiers.size(); i++) simplereaction.addContent((Element) modifiers.get(i));
    // Add kinetics
    simplereaction.addContent(getXML(param.getKinetics()));
    return simplereaction;
}
Also used : Element(org.jdom.Element) ArrayList(java.util.ArrayList) Product(cbit.vcell.model.Product) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Reactant(cbit.vcell.model.Reactant) Catalyst(cbit.vcell.model.Catalyst)

Example 3 with Catalyst

use of cbit.vcell.model.Catalyst in project vcell by virtualcell.

the class XmlReader method getCatalyst.

/**
 * This method returns a Catalyst object from a XML representation.
 * Creation date: (5/4/2001 2:22:56 PM)
 * @return cbit.vcell.model.Product
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private Catalyst getCatalyst(Element param, ReactionStep reaction, Model model) throws XmlParseException {
    // retrieve the key if there is one
    KeyValue key = null;
    String keystring = param.getAttributeValue(XMLTags.KeyValueAttrTag);
    if (keystring != null && keystring.length() > 0 && this.readKeysFlag) {
        key = new KeyValue(keystring);
    }
    String speccontref = unMangle(param.getAttributeValue(XMLTags.SpeciesContextRefAttrTag));
    SpeciesContext speccont = model.getSpeciesContext(speccontref);
    if (speccont == null) {
        throw new XmlParseException("The reference to the SpecieContext " + speccontref + " for a Catalyst could not be resolved!");
    }
    return new Catalyst(key, reaction, speccont);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SpeciesContext(cbit.vcell.model.SpeciesContext) Catalyst(cbit.vcell.model.Catalyst)

Example 4 with Catalyst

use of cbit.vcell.model.Catalyst in project vcell by virtualcell.

the class SBPAXHMMIrrevLawBuilder method addKinetics.

public void addKinetics(KineticContext context) {
    try {
        ReactionStep reaction = context.getReaction();
        HMM_IRRKinetics kinetics = new HMM_IRRKinetics((SimpleReaction) reaction);
        NameScope modelScope = reaction.getModel().getNameScope();
        ModelParameter kMichaelis = context.getParameter(SBOList.MICHAELIS_CONST_FORW);
        if (kMichaelis != null) {
            KineticsParameter kmParameter = kinetics.getKmParameter();
            kmParameter.setExpression(new Expression(kMichaelis, modelScope));
            kmParameter.setUnitDefinition(kMichaelis.getUnitDefinition());
        }
        ModelParameter kcat = context.getParameter(SBOList.CATALYTIC_RATE_CONST_FORW);
        if (kcat != null && context.getCatalysts().size() == 1) {
            KineticsParameter vmaxParameter = kinetics.getVmaxParameter();
            Catalyst catalyst = context.getCatalysts().iterator().next();
            vmaxParameter.setExpression(Expression.mult(new Expression(kcat, modelScope), new Expression(catalyst.getSpeciesContext(), modelScope)));
        // vmaxParameter.setUnitDefinition(vMax.getUnitDefinition());
        } else {
            ModelParameter vMax = context.getParameter(SBOList.MAXIMAL_VELOCITY_FORW);
            if (vMax != null) {
                KineticsParameter vmaxParameter = kinetics.getVmaxParameter();
                vmaxParameter.setExpression(new Expression(vMax, modelScope));
                vmaxParameter.setUnitDefinition(vMax.getUnitDefinition());
            }
        }
    } catch (ExpressionException e) {
        e.printStackTrace();
    }
}
Also used : ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) NameScope(cbit.vcell.parser.NameScope) Expression(cbit.vcell.parser.Expression) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) ReactionStep(cbit.vcell.model.ReactionStep) Catalyst(cbit.vcell.model.Catalyst) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 5 with Catalyst

use of cbit.vcell.model.Catalyst in project vcell by virtualcell.

the class StructureAnalyzer method getCorrectedRateExpression.

public Expression getCorrectedRateExpression(ReactionStep reactionStep, ReactionParticipant reactionParticipant, RateType rateType) throws Exception {
    if (reactionParticipant instanceof Catalyst) {
        throw new Exception("Catalyst " + reactionParticipant + " doesn't have a rate for this reaction");
    // return new Expression(0.0);
    }
    double stoich = reactionStep.getStoichiometry(reactionParticipant.getSpeciesContext());
    if (stoich == 0.0) {
        return new Expression(0.0);
    }
    // 
    // make distributed rate with correct stoichiometry for this participant
    // 
    VCUnitDefinition correctedReactionRateUnit = null;
    Expression distribRate = null;
    if (reactionStep.getKinetics() instanceof DistributedKinetics) {
        DistributedKinetics distributedKinetics = (DistributedKinetics) reactionStep.getKinetics();
        KineticsParameter distribReactionRateParameter = distributedKinetics.getReactionRateParameter();
        distribRate = new Expression(distribReactionRateParameter, mathMapping.getNameScope());
        correctedReactionRateUnit = distribReactionRateParameter.getUnitDefinition();
    } else if (reactionStep.getKinetics() instanceof LumpedKinetics) {
        // 
        // need to put this into concentration/time with respect to structure for reaction.
        // 
        Structure.StructureSize structureSize = reactionStep.getStructure().getStructureSize();
        LumpedKinetics lumpedKinetics = (LumpedKinetics) reactionStep.getKinetics();
        KineticsParameter lumpedReactionRateParameter = lumpedKinetics.getLumpedReactionRateParameter();
        Expression lumpedReactionRateExp = new Expression(lumpedReactionRateParameter, mathMapping.getNameScope());
        distribRate = Expression.div(lumpedReactionRateExp, new Expression(structureSize, mathMapping.getNameScope()));
        ;
        correctedReactionRateUnit = lumpedReactionRateParameter.getUnitDefinition().divideBy(structureSize.getUnitDefinition());
    }
    // correct for stoichiometry
    Expression distribRateWithStoich = distribRate;
    if (stoich != 1) {
        distribRateWithStoich = Expression.mult(new Expression(stoich), distribRateWithStoich);
    }
    // flux correction if reaction and reactionParticipant are in different compartments. (not necessarily dimensionless, use KFlux parameter).
    Expression distribRateWithStoichFlux = distribRateWithStoich;
    if (reactionStep.getStructure() != reactionParticipant.getStructure()) {
        StructureMapping reactionSM = mathMapping.getSimulationContext().getGeometryContext().getStructureMapping(reactionStep.getStructure());
        StructureMapping speciesSM = mathMapping.getSimulationContext().getGeometryContext().getStructureMapping(reactionParticipant.getStructure());
        Parameter fluxCorrectionParameter = mathMapping.getFluxCorrectionParameter(reactionSM, speciesSM);
        Expression fluxCorrection = new Expression(fluxCorrectionParameter, mathMapping.getNameScope());
        distribRateWithStoichFlux = Expression.mult(fluxCorrection, distribRateWithStoichFlux);
        correctedReactionRateUnit = correctedReactionRateUnit.multiplyBy(fluxCorrectionParameter.getUnitDefinition());
    }
    // apply unit factor for difference substance
    ModelUnitSystem unitSystem = mathMapping.getSimulationContext().getModel().getUnitSystem();
    VCUnitDefinition timeUnit = unitSystem.getTimeUnit();
    VCUnitDefinition speciesConcUnit = reactionParticipant.getSpeciesContext().getUnitDefinition();
    VCUnitDefinition speciesConcRateUnit = speciesConcUnit.divideBy(timeUnit);
    Expression unitFactor = null;
    if (rateType == RateType.ConcentrationRate) {
        unitFactor = mathMapping.getUnitFactor(speciesConcRateUnit.divideBy(correctedReactionRateUnit));
    } else if (rateType == RateType.ResolvedFluxRate) {
        unitFactor = mathMapping.getUnitFactor(speciesConcRateUnit.multiplyBy(unitSystem.getLengthUnit()).divideBy(correctedReactionRateUnit));
    }
    return Expression.mult(unitFactor, distribRateWithStoichFlux).flatten();
}
Also used : DistributedKinetics(cbit.vcell.model.DistributedKinetics) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) LumpedKinetics(cbit.vcell.model.LumpedKinetics) Expression(cbit.vcell.parser.Expression) MathMappingParameter(cbit.vcell.mapping.AbstractMathMapping.MathMappingParameter) Parameter(cbit.vcell.model.Parameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) Catalyst(cbit.vcell.model.Catalyst) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Aggregations

Catalyst (cbit.vcell.model.Catalyst)19 ReactionParticipant (cbit.vcell.model.ReactionParticipant)14 Product (cbit.vcell.model.Product)10 Reactant (cbit.vcell.model.Reactant)10 ReactionStep (cbit.vcell.model.ReactionStep)9 FluxReaction (cbit.vcell.model.FluxReaction)7 SimpleReaction (cbit.vcell.model.SimpleReaction)7 SpeciesContext (cbit.vcell.model.SpeciesContext)7 Expression (cbit.vcell.parser.Expression)6 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)5 Structure (cbit.vcell.model.Structure)5 Shape (cbit.gui.graph.Shape)4 Feature (cbit.vcell.model.Feature)4 Membrane (cbit.vcell.model.Membrane)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 ModelParameter (cbit.vcell.model.Model.ModelParameter)3 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)3 UserCancelException (org.vcell.util.UserCancelException)3