Search in sources :

Example 1 with CellularLocationVocabularyProxy

use of org.vcell.pathway.persistence.BiopaxProxy.CellularLocationVocabularyProxy 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 CellularLocationVocabularyProxy

use of org.vcell.pathway.persistence.BiopaxProxy.CellularLocationVocabularyProxy in project vcell by virtualcell.

the class PathwayReaderBiopax3 method addObjectCellularLocationVocabulary.

private CellularLocationVocabulary addObjectCellularLocationVocabulary(Element element) {
    if (element.getChildren().size() == 0) {
        CellularLocationVocabularyProxy proxy = new CellularLocationVocabularyProxy();
        addAttributes(proxy, element);
        pathwayModel.add(proxy);
        return proxy;
    }
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (childElement.getName().equals("CellularLocationVocabulary")) {
                CellularLocationVocabulary thingie = addObjectCellularLocationVocabulary(childElement);
                pathwayModel.add(thingie);
                return thingie;
            }
        }
    }
    CellularLocationVocabulary cellularLocationVocabulary = new CellularLocationVocabulary();
    addAttributes(cellularLocationVocabulary, element);
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (!addContentControlledVocabulary(cellularLocationVocabulary, element, childElement)) {
                showUnexpected(childElement);
            }
        }
    }
    pathwayModel.add(cellularLocationVocabulary);
    return cellularLocationVocabulary;
}
Also used : CellularLocationVocabularyProxy(org.vcell.pathway.persistence.BiopaxProxy.CellularLocationVocabularyProxy) Element(org.jdom.Element) CellularLocationVocabulary(org.vcell.pathway.CellularLocationVocabulary) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Aggregations

Element (org.jdom.Element)2 CellularLocationVocabularyProxy (org.vcell.pathway.persistence.BiopaxProxy.CellularLocationVocabularyProxy)2 BioPaxObject (org.vcell.pathway.BioPaxObject)1 CellularLocationVocabulary (org.vcell.pathway.CellularLocationVocabulary)1 GroupObject (org.vcell.pathway.GroupObject)1 PhysicalEntity (org.vcell.pathway.PhysicalEntity)1 Stoichiometry (org.vcell.pathway.Stoichiometry)1 PhysicalEntityProxy (org.vcell.pathway.persistence.BiopaxProxy.PhysicalEntityProxy)1