Search in sources :

Example 26 with PhysicalEntity

use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.

the class PathwayMapping method generateSpeciesPattern.

private SpeciesPattern generateSpeciesPattern(BioModel bioModel, PhysicalEntity bioPaxObject, boolean addSubunits) {
    SpeciesPattern sp = new SpeciesPattern();
    if (bioPaxObject instanceof Complex) {
        Complex c = (Complex) bioPaxObject;
        for (PhysicalEntity pc : c.getComponents()) {
            MolecularType mt = createMolecularTypeFromBioPaxObject(bioModel, pc, addSubunits);
            MolecularTypePattern mtp = new MolecularTypePattern(mt);
            sp.addMolecularTypePattern(mtp);
        }
        return sp;
    } else {
        // else if(!(bioPaxObject instanceof Complex))
        MolecularType mt = createMolecularTypeFromBioPaxObject(bioModel, bioPaxObject, addSubunits);
        MolecularTypePattern mtp = new MolecularTypePattern(mt);
        sp.addMolecularTypePattern(mtp);
        return sp;
    }
// return null;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) PhysicalEntity(org.vcell.pathway.PhysicalEntity) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) Complex(org.vcell.pathway.Complex)

Example 27 with PhysicalEntity

use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.

the class PathwayMapping method createReactionStep.

/*
	 * 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 createReactionStep(BioModel bioModel, Process process, ReactionStep reactionStep, RelationshipObject relationshipObject, ArrayList<ConversionTableRow> participants, boolean addSubunits) throws Exception {
    if (reactionStep == null || bioModel == null || bioModel.getRelationshipModel() == null || participants.size() < 1) {
        return;
    }
    ArrayList<ReactionParticipant> rplist = new ArrayList<ReactionParticipant>();
    // create and add reaction participants to list
    for (ConversionTableRow ctr : participants) {
        if (ctr.getBioPaxObject() instanceof Conversion)
            continue;
        int stoich = ctr.stoich().intValue();
        String safeId = getSafetyName(ctr.id());
        // get speciesContext object based on its name
        // if the speciesContext is not existed, create a new one
        createSpeciesContextFromTableRow(bioModel, (PhysicalEntity) ctr.getBioPaxObject(), ctr.stoich(), ctr.id(), ctr.location(), addSubunits);
        // add the existed speciesContext objects or new speciesContext objects to reaction participant list
        if (ctr.participantType().equals("Reactant")) {
            if (reactionStep instanceof SimpleReaction || reactionStep instanceof FluxReaction) {
                rplist.add(new Reactant(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId), stoich));
            }
        } else if (ctr.participantType().equals("Product")) {
            if (reactionStep instanceof SimpleReaction || reactionStep instanceof FluxReaction) {
                rplist.add(new Product(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId), stoich));
            }
        }
    // we do not add catalysts
    }
    ReactionParticipant[] rpArray = rplist.toArray(new ReactionParticipant[0]);
    reactionStep.setReactionParticipants(rpArray);
    // add Controls to the reaction
    Set<PhysicalEntity> controllers = process.getControllers();
    for (ConversionTableRow ctr : participants) {
        if (controllers.contains(ctr.getBioPaxObject())) {
            if (ctr.participantType().equals("Catalyst")) {
                String safeId = getSafetyName(ctr.id());
                /* 
					 * using addCatalyst() to create catalyst in reaction: 
					 * this function cannot allow an object to be catalyst and (reactant/product) in the same reaction
					 */
                // reactionStep.addCatalyst(bioModel.getModel().getSpeciesContext(safeId));
                /* However, in pathway interaction object, an physicalEntity can be catalyst and (reactant/product) in the same reaction
					 * So we just call create catalyst for the reaction no matter what rolls the object is playing in the reaction
					 * Switch back to the addCatalyst() function when it is necessary, but exceptions make be reported for some reactions
					 */
                reactionStep.addReactionParticipant(new Catalyst(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId)));
            } else if (ctr.participantType().equals("Control")) {
                String safeId = getSafetyName(ctr.id());
                // reactionStep.addCatalyst(bioModel.getModel().getSpeciesContext(safeId));
                reactionStep.addReactionParticipant(new Catalyst(null, reactionStep, bioModel.getModel().getSpeciesContext(safeId)));
            }
        }
    }
}
Also used : SimpleReaction(cbit.vcell.model.SimpleReaction) ArrayList(java.util.ArrayList) Product(cbit.vcell.model.Product) FluxReaction(cbit.vcell.model.FluxReaction) Conversion(org.vcell.pathway.Conversion) Reactant(cbit.vcell.model.Reactant) PhysicalEntity(org.vcell.pathway.PhysicalEntity) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Aggregations

PhysicalEntity (org.vcell.pathway.PhysicalEntity)27 BioPaxObject (org.vcell.pathway.BioPaxObject)15 ArrayList (java.util.ArrayList)10 Conversion (org.vcell.pathway.Conversion)9 Element (org.jdom.Element)8 Complex (org.vcell.pathway.Complex)8 HashSet (java.util.HashSet)7 Control (org.vcell.pathway.Control)7 GroupObject (org.vcell.pathway.GroupObject)6 SmallMolecule (org.vcell.pathway.SmallMolecule)5 MolecularType (org.vcell.model.rbm.MolecularType)4 Protein (org.vcell.pathway.Protein)4 RelationshipObject (org.vcell.relationship.RelationshipObject)4 EdgeShape (cbit.gui.graph.EdgeShape)3 Shape (cbit.gui.graph.Shape)3 SpeciesContext (cbit.vcell.model.SpeciesContext)3 Dna (org.vcell.pathway.Dna)3 Entity (org.vcell.pathway.Entity)3 InteractionParticipant (org.vcell.pathway.InteractionParticipant)3 Rna (org.vcell.pathway.Rna)3