Package org.gvt.model.biopaxl2

Examples of org.gvt.model.biopaxl2.Conversion


    calculateAverageNodeDegree();
  }

  private void calculateAverageNodeDegree()
  {
    BioPAXGraph graph = main.getRootGraph();

    int totalDegree = 0;
    int nodeCounted = 0;

    for (Object o : graph.getNodes())
    {
      NodeModel node = (NodeModel) o;

      if (node instanceof ComplexMember ||
        node instanceof Compartment ||
View Full Code Here


    this.main = main;
  }

  public void run()
  {
    BioPAXGraph graph = main.getPathwayGraph();

    if (graph == null)
    {
      MessageDialog.openError(main.getShell(), "Error!", "No BioPAX pathway.");
      return;
    }

    if (!graph.isMechanistic())
    {
      MessageDialog.openError(main.getShell(), "Not Supported!",
        "Cropping is supported only for mechanistic views.");

      return;
    }

    Set<GraphObject> cropto = new HashSet<GraphObject>();

    for (Object o : graph.getNodes())
    {
      NodeModel node = (NodeModel) o;
      if (node.isHighlight())
      {
        cropto.add((GraphObject) node);
      }
    }

    for (Object o : graph.getEdges())
    {
      EdgeModel edge = (EdgeModel) o;
      if (edge.isHighlight())
      {
        cropto.add((GraphObject) edge);
      }
    }

    if (cropto.isEmpty())
    {
      MessageDialog.openError(main.getShell(), "Error!",
        "Nothing is highlighted.");
      return;     
    }

    BioPAXGraph excised = graph.excise(cropto, true);
    excised.setName(graph.getName() + " cropped");

    main.createNewTab(excised);
    new CoSELayoutAction(main).run();
    excised.recordLayout();
  }
View Full Code Here

    if (main.getViewer() == null)
    {
      return;
    }

    BioPAXGraph graph = main.getPathwayGraph();

    if (graph == null)
    {
      MessageDialog.openError(main.getShell(), "Not applicable!",
        "This feature works only for process views.");
View Full Code Here

    CompoundModel root = (CompoundModel) viewer.getContents().getModel();

    if (root instanceof BioPAXGraph)
    {
      BioPAXGraph graph = (BioPAXGraph) root;

      if (graph.isMechanistic())
      {
        graph.forgetLayout();
        Model model = graph.getBiopaxModel();
        pathway p = graph.getPathway();
        model.remove(p);

        main.getAllPathwayNames().remove(p.getNAME());
      }
    }
View Full Code Here

  }

  // Replace graph
  private void updateViewerContent(ScrollingGraphicalViewer viewer)
  {
    BioPAXGraph graph = (BioPAXGraph) viewer.getContents().getModel();

    // Updating is supported only for mechanistic views
    if (!graph.isMechanistic()) return;

    // Remember highlighted object's original nodes (members of chisio root graph)

    Map<Integer, Color> highlightMap = new HashMap<Integer, Color>();

    for (Object o : graph.getNodes())
    {
      IBioPAXNode node = (IBioPAXNode) o;
      if (node.isHighlighted())
      {
        highlightMap.put(node.getIDHash(), node.getHighlightColor());
      }
    }

    for (Object o : graph.getEdges())
    {
      BioPAXEdge edge = (BioPAXEdge) o;
      if (edge.isHighlighted())
      {
        highlightMap.put(edge.getIDHash(), edge.getHighlightColor());
      }
    }

    // Reset highlight

    HighlightLayer hLayer = (HighlightLayer)
      ((ChsScalableRootEditPart) viewer.getRootEditPart()).getLayer(
        HighlightLayer.HIGHLIGHT_LAYER);

    hLayer.removeAll();
    hLayer.highlighted.clear();

    viewer.deselectAll();

    // Record layout
    graph.recordLayout();

    // Create updated graph
    pathway p = graph.getPathway();
    BioPAXGraph newGraph = main.getRootGraph().excise(p);
    newGraph.setName(p.getNAME());
    newGraph.setAsRoot();

    // Replace the graph
    viewer.setContents(newGraph);

    // Use same layout
    boolean layedout = newGraph.fetchLayout();

    if (!layedout)
    {
      new CoSELayoutAction(main).run();
    }

    viewer.deselectAll();
    GraphAnimation.run(viewer);

    // Recover highlights

    for (Object o : newGraph.getNodes())
    {
      IBioPAXNode node = (IBioPAXNode) o;
      if (highlightMap.containsKey(node.getIDHash()))
      {
        node.setHighlightColor(highlightMap.get(node.getIDHash()));
        node.setHighlight(true);
      }
    }

    for (Object o : newGraph.getEdges())
    {
      BioPAXEdge edge = (BioPAXEdge) o;
      if (highlightMap.containsKey(edge.getIDHash()))
      {
        edge.setHighlightColor(highlightMap.get(edge.getIDHash()));
View Full Code Here

    }
  }

  private void updateRoot()
  {
    BioPAXGraph root = (BioPAXGraph) new BioPAXReader(main.getOwlModel()).readXMLFile(null);
    main.setRootGraph(root);
  }
View Full Code Here

      main.lockWithMessage("Saving ...");

      // Record layout of all views
      for (ScrollingGraphicalViewer viewer : main.getTabToViewerMap().values())
      {
        BioPAXGraph graph = (BioPAXGraph) viewer.getContents().getModel();
        if (graph.isMechanistic())
        {
          graph.recordLayout();
        }
      }

      JenaIOHandler jenaIOHandler = main.getJenaIOHandler();
View Full Code Here

      result = main.getPathwayGraph().getCorrespMember(result);
    }
    //if result should be viewed in New View
    else
    {
      BioPAXGraph pathwayGraph = main.getRootGraph().excise(result);
      pathwayGraph.setName(query);
      main.createNewTab(pathwayGraph);
      new CoSELayoutAction(main).run();

      result = pathwayGraph.getCorrespMember(result);
    }

    //highlight result GraphObjects
    for (GraphObject go : result)
    {
View Full Code Here

    }
  }

  private void calculateAverageNodeDegree()
  {
    BioPAXGraph graph = main.getRootGraph();

    int totalDegree = 0;
    int nodeCounted = 0;

    for (Object o : graph.getNodes())
    {
      NodeModel node = (NodeModel) o;

      if (node instanceof ComplexMember ||
        node instanceof Compartment ||
View Full Code Here

      try
      {
        main.lockWithMessage("Loading BioPAX model ...");

        BioPAXGraph root = this.graph;

        if (root == null)
        {
          File xmlfile = filename == null ? null : new File(filename);
          BioPAXReader reader = model == null ?
            new BioPAXReader(main.getJenaIOHandler()): new BioPAXReader(model);
          root = (BioPAXGraph) reader.readXMLFile(xmlfile);
        }

        if (root != null)
        {
          if (!root.modelConstainsPathway())
          {
            String name = pathwayName == null ? filename : pathwayName;

            if (name != null)
            {
              if (name.contains("\\"))
              {
                name = name.substring(name.lastIndexOf("\\") + 1);
              }
              else if (name.contains("/"))
              {
                name = name.substring(name.lastIndexOf("/") + 1);
              }

              if (name.contains("."))
              {
                name = name.substring(0, name.lastIndexOf("."));
              }
            }
            else
            {
              name = "Auto-created Pathway";
            }
            root.createGlobalPathway(name);
            pathwayName = name;
            main.getAllPathwayNames().add(pathwayName);
          }

          main.closeAllTabs(false);
View Full Code Here

TOP

Related Classes of org.gvt.model.biopaxl2.Conversion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.