Search in sources :

Example 1 with PathwayModel

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

the class PathwayReaderBiopax3 method main.

public static void main(String[] args) {
    try {
        // usual testing pathway
        Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\Reactome3_189445.owl"));
        // infinite recursion between pathway steps
        // http://www.pathwaycommons.org/pc/webservice.do?cmd=get_record_by_cpath_id&version=2.0&q=826249&output=biopax
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\recursive.owl"));
        PathwayReaderBiopax3 pathwayReader = new PathwayReaderBiopax3(new RDFXMLContext());
        System.out.println("starting parsing");
        PathwayModel pathwayModel = pathwayReader.parse(document.getRootElement(), true);
        System.out.println("ending parsing");
        pathwayModel.reconcileReferences(null);
        System.out.println(pathwayModel.show(false));
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Document(org.jdom.Document) PathwayModel(org.vcell.pathway.PathwayModel) File(java.io.File)

Example 2 with PathwayModel

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

the class PathwayBiopax3Test method main.

public static void main(String[] args) {
    try {
        // sbpax: http://www.signaling-gateway.org/molecule/query?afcsid=A000037&type=sbPAXExport
        // items within items
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\sbpax3fullexample.xml"));
        // biopax with URI-like IDs and resources
        // http://www.pathwaycommons.org/pc2/get?uri=HTTP:%2F%2FWWW.REACTOME.ORG%2FBIOPAX/48887%23PATHWAY1076_1_9606
        // sbpax3_uri_id.xml
        Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\biopax3_no_id.xml"));
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\SBPax3.owl"));
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\Reactome3_189445.owl"));
        PathwayReaderBiopax3 pathwayReader = new PathwayReaderBiopax3(new RDFXMLContext());
        PathwayModel pathwayModel = pathwayReader.parse(document.getRootElement(), true);
        // System.out.print(pathwayModel.show(true));
        pathwayModel.reconcileReferences(null);
        bioModelToXML(pathwayModel);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Document(org.jdom.Document) PathwayModel(org.vcell.pathway.PathwayModel) File(java.io.File) XmlParseException(cbit.vcell.xml.XmlParseException)

Example 3 with PathwayModel

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

the class BioModelEditorPathwayDiagramPanel method refreshInterface.

private void refreshInterface() {
    if (bioModel == null) {
        sourceTextArea.setText("");
        biopaxTree.setModel(BioPAXTreeMaker.makeEmptyTree());
    } else {
        try {
            PathwayModel pathwayModel = bioModel.getPathwayModel();
            sourceTextArea.setText("======Summary View========\n\n" + pathwayModel.show(false) + "\n" + "======Detailed View========\n\n" + pathwayModel.show(true) + "\n");
            biopaxTree.setModel(BioPAXTreeMaker.makeTree(pathwayModel));
            pathwayModel.populateDiagramObjects();
        } catch (Exception ex) {
            ex.printStackTrace();
            DialogUtils.showErrorDialog(this, ex.getMessage());
        }
    }
}
Also used : PathwayModel(org.vcell.pathway.PathwayModel) ZoomRangeException(cbit.gui.graph.GraphResizeManager.ZoomRangeException) UtilCancelException(org.vcell.util.UtilCancelException)

Example 4 with PathwayModel

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

the class BioModelEditorPathwayPanel method importPathway.

public void importPathway(boolean addComplexes, boolean addComponents, boolean addInteractions) {
    ArrayList<BioPaxObject> selectedBioPaxObjects = new ArrayList<BioPaxObject>();
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length == 0) {
        return;
    }
    for (int row : rows) {
        BioPaxObject bioPaxObject = tableModel.getValueAt(row);
        selectedBioPaxObjects.add(bioPaxObject);
    }
    PathwaySelectionExpander selectionExpander = new PathwaySelectionExpander();
    PathwayModel rawPathwayModel = pathwayData.getPathwayModel();
    if (addComplexes) {
        selectionExpander.forPhysicalEntitiesAddComplexes(rawPathwayModel, selectedBioPaxObjects);
    }
    if (addComponents) {
        selectionExpander.forComplexesAddComponents(rawPathwayModel, selectedBioPaxObjects);
    }
    if (addInteractions) {
        selectionExpander.forPhysicalEntitiesAddInteractions(rawPathwayModel, selectedBioPaxObjects);
    }
    selectionExpander.forInteractionsAddControls(rawPathwayModel, selectedBioPaxObjects);
    selectionExpander.forInteractionsAddParticipants(rawPathwayModel, selectedBioPaxObjects);
    PathwayModel selectedPathwayModel = new PathwayModel();
    HashSet<BioPaxObject> objectsToDelete = new HashSet<BioPaxObject>();
    for (BioPaxObject candidateObject : selectedBioPaxObjects) {
        // is the object in the current pathwayModel already?
        BioPaxObject keeperObject = bioModel.getPathwayModel().find(candidateObject);
        if (keeperObject == null) {
            // not found in the current pathwayModel, add it
            selectedPathwayModel.add(candidateObject);
        } else {
            // make a list with the objects we don't bring in because of duplication
            objectsToDelete.add(candidateObject);
        }
    }
    // we replace references to those objects within selectedPathwayModel with the real thing
    for (BioPaxObject bpObject : selectedPathwayModel.getBiopaxObjects()) {
        if (bpObject == null) {
            System.out.println("PathwayModel: null BioPaxObject.");
            continue;
        }
        for (BioPaxObject objectToDelete : objectsToDelete) {
            BioPaxObject keeperObject = bioModel.getPathwayModel().find(objectToDelete);
            // for now we only implemented this for InteractionParticipant entities of Conversions
            bpObject.replace(keeperObject);
        }
    }
    // we bring proteins, small molecules, etc that are components of a Complex
    ArrayList<PhysicalEntity> addList = new ArrayList<>();
    for (BioPaxObject bpo : selectedPathwayModel.getBiopaxObjects()) {
        if (bpo instanceof Complex) {
            Complex complex = (Complex) bpo;
            addComplexComponents(complex, addList, 0);
        }
    }
    for (PhysicalEntity pe : addList) {
        if (selectedPathwayModel.find(pe) == null) {
            selectedPathwayModel.add(pe);
        }
    }
    bioModel.getPathwayModel().merge(selectedPathwayModel);
    // jump the view to pathway diagram panel
    if (selectionManager != null) {
        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), selectedPathwayModel.getBiopaxObjects().toArray());
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) PathwayModel(org.vcell.pathway.PathwayModel) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) Complex(org.vcell.pathway.Complex) PhysicalEntity(org.vcell.pathway.PhysicalEntity) PathwaySelectionExpander(org.vcell.pathway.PathwaySelectionExpander) HashSet(java.util.HashSet)

Example 5 with PathwayModel

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

the class BioModelEditorSabioPanel method treeSelectionChanged.

public void treeSelectionChanged() {
    System.out.println("treeSelectionChanged");
    final SBEntity kineticLaw = computeSelectedKineticLaw();
    if (kineticLaw == null) {
        return;
    }
    String kineticLawID = kineticLaw.getID();
    final String kls = new String("kineticLaw");
    if (!kineticLawID.contains(kls)) {
        return;
    }
    kineticLawID = kineticLawID.substring(kineticLawID.lastIndexOf(kls) + kls.length());
    command = "EntryID:" + kineticLawID;
    AsynchClientTask task1 = new AsynchClientTask("Importing Kinetic Laws", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(final Hashtable<String, Object> hashTable) throws Exception {
            final URL url = new URL("http://sabiork.h-its.org/sabioRestWebServices/searchKineticLaws/biopax?q=" + command);
            // final URL url = new URL("http://sabiork.h-its.org/sabioRestWebServices/searchKineticLaws/biopax?q=EntryID:33107");
            System.out.println(url.toString());
            String ERROR_CODE_TAG = "error_code";
            Document jdomDocument = XmlUtil.getJDOMDocument(url, getClientTaskStatusSupport());
            Element rootElement = jdomDocument.getRootElement();
            String errorCode = rootElement.getChildText(ERROR_CODE_TAG);
            if (errorCode != null) {
                throw new RuntimeException("Failed to access " + url + " \n\nPlease try again.");
            }
            PathwayModel pathwayModel = PathwayIOUtil.extractPathwayFromJDOM(jdomDocument, new RDFXMLContext(), getClientTaskStatusSupport());
            PathwayData pathwayData = new PathwayData("Sabio Kinetic Laws", pathwayModel);
            hashTable.put("pathwayData", pathwayData);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("showing", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            PathwayData pathwayData = (PathwayData) hashTable.get("pathwayData");
            if (pathwayData != null) {
                setSelectedObjects(new Object[] { pathwayData });
            }
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, true, true, null);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) Hashtable(java.util.Hashtable) Element(org.jdom.Element) PathwayData(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayData) Document(org.jdom.Document) PathwayModel(org.vcell.pathway.PathwayModel) SBEntity(org.vcell.pathway.sbpax.SBEntity) URL(java.net.URL) PathwayStringObject(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayStringObject)

Aggregations

PathwayModel (org.vcell.pathway.PathwayModel)11 Document (org.jdom.Document)5 Element (org.jdom.Element)4 RDFXMLContext (org.vcell.pathway.persistence.RDFXMLContext)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 File (java.io.File)3 URL (java.net.URL)3 Hashtable (java.util.Hashtable)3 PathwayData (cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayData)2 PathwayStringObject (cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayStringObject)2 ZoomRangeException (cbit.gui.graph.GraphResizeManager.ZoomRangeException)1 BioModel (cbit.vcell.biomodel.BioModel)1 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 MathModel (cbit.vcell.mathmodel.MathModel)1 Model (cbit.vcell.model.Model)1 RedistributionVersion (cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion)1 XmlParseException (cbit.vcell.xml.XmlParseException)1 PropertyVetoException (java.beans.PropertyVetoException)1 ArrayList (java.util.ArrayList)1