Search in sources :

Example 11 with Conversion

use of org.vcell.pathway.Conversion 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)

Example 12 with Conversion

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

the class PathwayReaderBiopax3 method addObjectConversion.

private Conversion addObjectConversion(Element conversionElement) {
    if (conversionElement.getChildren().size() == 0) {
        ConversionProxy proxy = new ConversionProxy();
        addAttributes(proxy, conversionElement);
        pathwayModel.add(proxy);
        return proxy;
    }
    Conversion conversion = new ConversionImpl();
    addAttributes(conversion, conversionElement);
    for (Object child : conversionElement.getChildren()) {
        if (child instanceof Element) {
            if (!addContentConversion(conversion, conversionElement, (Element) child)) {
                showUnexpected((Element) child);
            }
        }
    }
    pathwayModel.add(conversion);
    return conversion;
}
Also used : Element(org.jdom.Element) ConversionImpl(org.vcell.pathway.ConversionImpl) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject) ConversionProxy(org.vcell.pathway.persistence.BiopaxProxy.ConversionProxy) Conversion(org.vcell.pathway.Conversion)

Example 13 with Conversion

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

the class PathwayProducerBiopax3 method addContentConversion.

// right 						PhysicalEntity 	multiple
// participantStoichiometry 	Stoichiometry 	multiple
// left 						PhysicalEntity 	multiple
// spontaneous 				Boolean 		single
// conversionDirection 		String 			single
private Element addContentConversion(BioPaxObject bpObject, Element element) {
    element = addContentInteraction(bpObject, element);
    Conversion ob = (Conversion) bpObject;
    Element tmpElement = null;
    if (ob.getLeft() != null && ob.getLeft().size() > 0) {
        List<PhysicalEntity> list = ob.getLeft();
        for (PhysicalEntity item : list) {
            tmpElement = new Element("left", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getRight() != null && ob.getRight().size() > 0) {
        List<PhysicalEntity> list = ob.getRight();
        for (PhysicalEntity item : list) {
            tmpElement = new Element("right", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getParticipantStoichiometry() != null && ob.getParticipantStoichiometry().size() > 0) {
        List<Stoichiometry> list = ob.getParticipantStoichiometry();
        for (Stoichiometry item : list) {
            tmpElement = new Element("participantStoichiometry", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getSpontaneous() != null) {
        tmpElement = new Element("spontaneous", bp);
        tmpElement.setAttribute("datatype", schemaBoolean, rdf);
        tmpElement.setText(ob.getSpontaneous().toString());
        element.addContent(tmpElement);
    }
    if (ob.getConversionDirection() != null && ob.getConversionDirection().length() > 0) {
        tmpElement = new Element("conversionDirection", bp);
        tmpElement.setAttribute("datatype", schemaString, rdf);
        tmpElement.setText(ob.getConversionDirection());
        element.addContent(tmpElement);
    }
    return element;
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Element(org.jdom.Element) Conversion(org.vcell.pathway.Conversion)

Aggregations

Conversion (org.vcell.pathway.Conversion)13 BioPaxObject (org.vcell.pathway.BioPaxObject)10 PhysicalEntity (org.vcell.pathway.PhysicalEntity)9 ArrayList (java.util.ArrayList)7 GroupObject (org.vcell.pathway.GroupObject)6 SpeciesContext (cbit.vcell.model.SpeciesContext)4 RelationshipObject (org.vcell.relationship.RelationshipObject)4 HashSet (java.util.HashSet)3 Control (org.vcell.pathway.Control)3 InteractionParticipant (org.vcell.pathway.InteractionParticipant)3 MolecularInteraction (org.vcell.pathway.MolecularInteraction)3 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)2 Catalyst (cbit.vcell.model.Catalyst)2 Product (cbit.vcell.model.Product)2 Reactant (cbit.vcell.model.Reactant)2 ReactionParticipant (cbit.vcell.model.ReactionParticipant)2 ReactionRule (cbit.vcell.model.ReactionRule)2 ReactionStep (cbit.vcell.model.ReactionStep)2 Dimension (java.awt.Dimension)2 Element (org.jdom.Element)2