Search in sources :

Example 1 with Stoichiometry

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

the class PathwayReader method addContentConversion.

private boolean addContentConversion(Conversion conversion, Element element, Element childElement) {
    if (addContentInteraction(conversion, element, childElement)) {
        return true;
    }
    /**
     * String getConversionDirection();
     * ArrayList<PhysicalEntity> getLeftSide();
     * ArrayList<Stoichiometry> getParticipantStoichiometry();
     * ArrayList<PhysicalEntity> getRightSide();
     * Boolean getSpontaneous();
     */
    if (childElement.getName().equals("LEFT") || childElement.getName().equals("RIGHT")) {
        Element physicalEntityParticipantElement = childElement.getChild("physicalEntityParticipant", bp);
        if (physicalEntityParticipantElement != null) {
            boolean found = false;
            PhysicalEntity thePhysicalEntity = null;
            Element physicalEntityPropertyElement = physicalEntityParticipantElement.getChild("PHYSICAL-ENTITY", bp);
            // always create a proxy, the real PhysicalEntity (if present) is not ready to be inserted as is because it is incomplete
            // the reason is that PhysicalEntity object is a "species" in v2 but becomes a "species context" in v3
            PhysicalEntityProxy physicalEntityProxy = null;
            if (physicalEntityPropertyElement != null) {
                found = true;
                physicalEntityProxy = new PhysicalEntityProxy();
                addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
                pathwayModel.add(physicalEntityProxy);
                if (childElement.getName().equals("LEFT")) {
                    conversion.addLeft(physicalEntityProxy);
                } else {
                    conversion.addRight(physicalEntityProxy);
                }
                if (physicalEntityPropertyElement.getChildren().size() > 0) {
                    thePhysicalEntity = addObjectPhysicalEntity(physicalEntityPropertyElement);
                }
            }
            Element cellularLocationElement = physicalEntityParticipantElement.getChild("CELLULAR-LOCATION", bp);
            if (cellularLocationElement != null && found == true) {
                Element controlledVocabularyElement = cellularLocationElement.getChild("openControlledVocabulary", bp);
                if (controlledVocabularyElement != null) {
                    CellularLocationVocabularyProxy cellularLocationVocabularyProxy = new CellularLocationVocabularyProxy();
                    addAttributes(cellularLocationVocabularyProxy, controlledVocabularyElement);
                    pathwayModel.add(cellularLocationVocabularyProxy);
                    if (controlledVocabularyElement.getChildren().size() == 0) {
                        physicalEntityProxy.setCellularLocation(cellularLocationVocabularyProxy);
                    } else {
                        physicalEntityProxy.setCellularLocation(addObjectCellularLocationVocabulary(controlledVocabularyElement));
                    }
                // System.out.println(" -          " + controlledVocabularyElement.getName());
                // we'll use the extra info in this proxy during reconciliation phase to reconstruct a complete PhysicalEntity
                }
            }
            Element stoichiometricCoefficientElement = physicalEntityParticipantElement.getChild("STOICHIOMETRIC-COEFFICIENT", bp);
            if (stoichiometricCoefficientElement != null && found == true) {
                // System.out.println(" -          " + stoichiometricCoefficientElement.getTextTrim());
                // Create a Stoichiometry object from the stoichiometricCoefficient and from PhysicalEntity object
                Stoichiometry stoichiometry = new Stoichiometry();
                stoichiometry.setID(generateInstanceID());
                stoichiometry.setStoichiometricCoefficient(Double.valueOf(stoichiometricCoefficientElement.getTextTrim()));
                if (physicalEntityProxy == null) {
                    // reuse the proxy if we created one already
                    physicalEntityProxy = new PhysicalEntityProxy();
                    String uri = context.unRelativizeURI(physicalEntityPropertyElement, generateResourceID(physicalEntityPropertyElement));
                    physicalEntityProxy.setID(uri);
                    pathwayModel.add(physicalEntityProxy);
                }
                stoichiometry.setPhysicalEntity(physicalEntityProxy);
                // Add the Stoichiometry object to the participantStoichiometry property of the conversion
                conversion.getParticipantStoichiometry().add(stoichiometry);
                // add the Stoichiometry object to the pathway model
                pathwayModel.add(stoichiometry);
                found = true;
            }
            return found;
        }
        Element sequenceParticipantElement = childElement.getChild("sequenceParticipant", bp);
        if (sequenceParticipantElement != null) {
            boolean found = false;
            PhysicalEntity thePhysicalEntity = null;
            Element physicalEntityPropertyElement = sequenceParticipantElement.getChild("PHYSICAL-ENTITY", bp);
            PhysicalEntityProxy physicalEntityProxy = null;
            if (physicalEntityPropertyElement != null) {
                found = true;
                if (physicalEntityPropertyElement.getChildren().size() == 0) {
                    physicalEntityProxy = new PhysicalEntityProxy();
                    addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
                    pathwayModel.add(physicalEntityProxy);
                    if (childElement.getName().equals("LEFT")) {
                        conversion.addLeft(physicalEntityProxy);
                    } else {
                        conversion.addRight(physicalEntityProxy);
                    }
                // return true;
                } else {
                    thePhysicalEntity = addObjectPhysicalEntity(physicalEntityPropertyElement);
                }
                Element cellularLocationElement = sequenceParticipantElement.getChild("CELLULAR-LOCATION", bp);
                if (cellularLocationElement != null && found == true) {
                    Element controlledVocabularyElement = cellularLocationElement.getChild("openControlledVocabulary", bp);
                    if (controlledVocabularyElement != null) {
                        CellularLocationVocabularyProxy cellularLocationVocabularyProxy = new CellularLocationVocabularyProxy();
                        addAttributes(cellularLocationVocabularyProxy, controlledVocabularyElement);
                        pathwayModel.add(cellularLocationVocabularyProxy);
                        if (controlledVocabularyElement.getChildren().size() == 0) {
                            physicalEntityProxy.setCellularLocation(cellularLocationVocabularyProxy);
                        } else {
                            physicalEntityProxy.setCellularLocation(addObjectCellularLocationVocabulary(controlledVocabularyElement));
                        }
                    // System.out.println(" -          " + controlledVocabularyElement.getName());
                    // we'll use the extra info in this proxy during reconciliation phase to reconstruct a complete PhysicalEntity
                    }
                }
            }
            return found;
        }
        if (childElement.getChildren().size() == 0) {
            // PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
            // addAttributes(physicalEntityProxy, childElement);
            // pathwayModel.add(physicalEntityProxy);
            // if (childElement.getName().equals("LEFT")){
            // conversion.getLeftSide().add(physicalEntityProxy);
            // }else{
            // conversion.getRightSide().add(physicalEntityProxy);
            // }
            showIgnored(childElement, "conversion/LEFT or conversion/RIGHT assuming redundant sequenceParticipant or physicalEntityParticipant", conversion);
            return true;
        }
        return false;
    // }else if(childElement.getName().equals("participantStoichiometry")) {
    // conversion.getParticipantStoichiometry().add(addObjectStoichiometry(childElement));
    // return true;
    } else {
        return false;
    }
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Element(org.jdom.Element) CellularLocationVocabularyProxy(org.vcell.pathway.persistence.BiopaxProxy.CellularLocationVocabularyProxy) PhysicalEntityProxy(org.vcell.pathway.persistence.BiopaxProxy.PhysicalEntityProxy)

Example 2 with Stoichiometry

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

the class PathwayProducerBiopax3 method addContentStoichiometry.

// physicalEntity 				PhysicalEntity 	single
// stoichiometricCoefficient 	Float 			single
private Element addContentStoichiometry(BioPaxObject bpObject, Element element) {
    element = addContentUtilityClass(bpObject, element);
    Stoichiometry ob = (Stoichiometry) bpObject;
    Element tmpElement = null;
    if (ob.getPhysicalEntity() != null) {
        tmpElement = new Element("physicalEntity", bp);
        addIDToProperty(tmpElement, ob.getPhysicalEntity());
        mustPrintObject(ob.getPhysicalEntity());
        element.addContent(tmpElement);
    }
    if (ob.getStoichiometricCoefficient() != null) {
        tmpElement = new Element("stoichiometricCoefficient", bp);
        tmpElement.setAttribute("datatype", schemaDouble, rdf);
        tmpElement.setText(ob.getStoichiometricCoefficient().toString());
        element.addContent(tmpElement);
    }
    return element;
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) Element(org.jdom.Element)

Example 3 with Stoichiometry

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

the class BioModelEditorConversionTableModel method refreshData.

private void refreshData() {
    if (bioModel == null || bioModel.getPathwayModel() == null || bioPaxObjects == null) {
        setData(null);
        return;
    }
    // function I :: get selected objects only
    // create ConversionTableRow objects
    allPathwayObjectList = new ArrayList<ConversionTableRow>();
    convertedBPObjects = new HashSet<BioPaxObject>();
    printObjects(bioPaxObjects);
    BioModel.printBpModelObjects(bioModel.getPathwayModel().getBiopaxObjects());
    // BioModel.printBpRelationshipObjects(bioModel.getRelationshipModel().getBioPaxObjects());	// derived; the bpObjects that are part of a relationship
    BioModel.printRelationships(bioModel.getRelationshipModel().getRelationshipObjects());
    System.out.println("----------------------------------------------------------------------");
    for (BioPaxObject bpo : bioPaxObjects) {
        if (bpo instanceof Conversion) {
            if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                Conversion conversion = (Conversion) bpo;
                ArrayList<String> nameList = conversion.getName();
                String interactionId = conversion.getID();
                String interactionLabel = nameList.isEmpty() ? conversion.getIDShort() : nameList.get(0);
                ConversionTableRow newConversionTableRow = createTableRow(conversion, interactionId, interactionLabel, "Conversion", 1.0, null);
                allPathwayObjectList.add(newConversionTableRow);
                convertedBPObjects.add(bpo);
                ArrayList<Stoichiometry> stoichiometryList = conversion.getParticipantStoichiometry();
                // stoichiometryMap problem:
                // how to deal with the case that the same object occurs on both left and right sides
                HashMap<PhysicalEntity, Double> stoichiometryMap = createStoichiometryMap(stoichiometryList);
                // reactant
                for (BioPaxObject bpObject1 : conversion.getLeft()) {
                    Double stoich = 1.0;
                    if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
                        stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
                    }
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
                    } else {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(bpObject1);
                }
                // product
                for (BioPaxObject bpObject1 : conversion.getRight()) {
                    Double stoich = 1.0;
                    if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
                        stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
                    }
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
                    } else {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(bpObject1);
                }
                // control
                for (BioPaxObject bpObject : bioModel.getPathwayModel().getBiopaxObjects()) {
                    if (bpObject instanceof Control) {
                        Control control = (Control) bpObject;
                        if (control instanceof Catalysis) {
                            // catalysis
                            if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
                                for (PhysicalEntity pe : ((Catalysis) control).getPhysicalControllers()) {
                                    ConversionTableRow conversionTableRow;
                                    if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, null);
                                    } else {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
                                    }
                                    allPathwayObjectList.add(conversionTableRow);
                                    convertedBPObjects.add(pe);
                                }
                            }
                        } else {
                            // other control types
                            if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
                                for (PhysicalEntity pe : control.getPhysicalControllers()) {
                                    ConversionTableRow conversionTableRow;
                                    if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, null);
                                    } else {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
                                    }
                                    allPathwayObjectList.add(conversionTableRow);
                                    convertedBPObjects.add(pe);
                                }
                            }
                        }
                    }
                }
            }
        } else if (bpo instanceof Catalysis) {
            for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
                if (!convertedBPObjects.contains(pe)) {
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
                        conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, null);
                    } else {
                        conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(pe);
                }
            }
            for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
            // TODO
            }
        } else if (bpo instanceof Control) {
            for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
                if (!convertedBPObjects.contains(pe)) {
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
                        conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, null);
                    } else {
                        conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(pe);
                }
            }
            for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
            // TODO
            }
        }
    }
    // 2nd pass - entities selected as themselves
    for (BioPaxObject bpo : bioPaxObjects) {
        if (bpo instanceof PhysicalEntity) {
            if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                PhysicalEntity physicalEntityObject = (PhysicalEntity) bpo;
                // we add standalone selected entities, only if they were not already added as part of any reaction
                if (!convertedBPObjects.contains(physicalEntityObject)) {
                    ConversionTableRow conversionTableRow = createTableRow(physicalEntityObject, "", "", "", 1.0, null);
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(physicalEntityObject);
                }
            }
        }
    }
    // apply text search function for particular columns
    ArrayList<ConversionTableRow> pathwayObjectList = new ArrayList<ConversionTableRow>();
    if (searchText == null || searchText.length() == 0) {
        pathwayObjectList.addAll(allPathwayObjectList);
    } else {
        String lowerCaseSearchText = searchText.toLowerCase();
        for (ConversionTableRow rs : allPathwayObjectList) {
            BioPaxObject bpObject = rs.getBioPaxObject();
            if (rs.interactionLabel().toLowerCase().contains(lowerCaseSearchText) || rs.participantType().toLowerCase().contains(lowerCaseSearchText) || getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
                pathwayObjectList.add(rs);
            }
        }
    }
    setData(pathwayObjectList);
    GuiUtils.flexResizeTableColumns(ownerTable);
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) BioPaxObject(org.vcell.pathway.BioPaxObject) Pathway(org.vcell.pathway.Pathway) ArrayList(java.util.ArrayList) Conversion(org.vcell.pathway.Conversion) Control(org.vcell.pathway.Control) PhysicalEntity(org.vcell.pathway.PhysicalEntity) ConversionTableRow(org.vcell.relationship.ConversionTableRow) Catalysis(org.vcell.pathway.Catalysis) Transport(org.vcell.pathway.Transport)

Example 4 with Stoichiometry

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

the class PathwayReaderBiopax3 method addObjectStoichiometry.

private Stoichiometry addObjectStoichiometry(Element element) {
    if (element.getChildren().size() == 0) {
        // if there are no children it must be a resource inside another object
        StoichiometryProxy proxy = new StoichiometryProxy();
        addAttributes(proxy, element);
        pathwayModel.add(proxy);
        return proxy;
    }
    Stoichiometry stoichiometry = new Stoichiometry();
    addAttributes(stoichiometry, element);
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (!addContentStoichiometry(stoichiometry, element, childElement)) {
                showUnexpected(childElement);
            }
        }
    }
    pathwayModel.add(stoichiometry);
    return stoichiometry;
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) StoichiometryProxy(org.vcell.pathway.persistence.BiopaxProxy.StoichiometryProxy) Element(org.jdom.Element) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 5 with Stoichiometry

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

the class PathwayProducerBiopax3 method addContentComplex.

// componentStoichiometry 	Stoichiometry 		multiple
// component 				PhysicalEntity 		multiple
private Element addContentComplex(BioPaxObject bpObject, Element element) {
    element = addContentPhysicalEntity(bpObject, element);
    Complex ob = (Complex) bpObject;
    Element tmpElement = null;
    if (ob.getComponentStoichiometry() != null && ob.getComponentStoichiometry().size() > 0) {
        List<Stoichiometry> list = ob.getComponentStoichiometry();
        for (Stoichiometry item : list) {
            tmpElement = new Element("componentStoichiometry", bp);
            // if(item instanceof RdfObjectProxy) {
            // tmpElement.setAttribute("resource", ((RdfObjectProxy)item).getResource(), rdf);
            // } else {
            // tmpElement.setAttribute("resource", item.resourceFromID(), rdf);
            // }
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getComponents() != null && ob.getComponents().size() > 0) {
        List<PhysicalEntity> list = ob.getComponents();
        for (PhysicalEntity item : list) {
            tmpElement = new Element("component", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    return element;
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Element(org.jdom.Element) Complex(org.vcell.pathway.Complex)

Aggregations

Stoichiometry (org.vcell.pathway.Stoichiometry)7 Element (org.jdom.Element)6 PhysicalEntity (org.vcell.pathway.PhysicalEntity)4 BioPaxObject (org.vcell.pathway.BioPaxObject)3 Conversion (org.vcell.pathway.Conversion)2 ArrayList (java.util.ArrayList)1 Catalysis (org.vcell.pathway.Catalysis)1 Complex (org.vcell.pathway.Complex)1 Control (org.vcell.pathway.Control)1 GroupObject (org.vcell.pathway.GroupObject)1 Pathway (org.vcell.pathway.Pathway)1 Transport (org.vcell.pathway.Transport)1 CellularLocationVocabularyProxy (org.vcell.pathway.persistence.BiopaxProxy.CellularLocationVocabularyProxy)1 PhysicalEntityProxy (org.vcell.pathway.persistence.BiopaxProxy.PhysicalEntityProxy)1 StoichiometryProxy (org.vcell.pathway.persistence.BiopaxProxy.StoichiometryProxy)1 ConversionTableRow (org.vcell.relationship.ConversionTableRow)1