Developing Cytoscape plugins cytoscape.org [email protected] 1 Developing Cytoscape plugins 1. 2. 3. 4. 5. 6. Cytoscape and plugins Documentation Basic Cytoscape architecture Plugins in Cytoscape Using an IDE Creating a plugin 1. 2. 3. 4. Extending CytoscapePluging Controlling the UI Creating and manipulating your network Additional topics 7. The future: Cytoscape 3.0 cytoscape.org [email protected] 2 1. Cytoscape and plugins 1. Setup of this part of the course 2. Overview of Cytoscape from a programmer’s point of view 3. Questions and feedback cytoscape.org [email protected] 3 1. Cytoscape and Plugins 1. Setup of this part of the course • Goal: build a functioning sample plugin – Controlling UI – Manipulating networks programmatically • First: ppt showing Cytoscape structure etc • Next: slides with codesamples working towards a plugin – – – – IDE of choice: Eclipse SamplePlugin project Including the functioning codesamples Micro assignments – code yourself – toy around! cytoscape.org [email protected] 4 1. Cytoscape and Plugins 2. Overview of Cytoscape from a programmer’s point of view • Java; >=1.5 • Object Oriented • Fully Open Source: LGP license – But please cite literature ref for funding purposes! • Cline ea Nature Protocols 2007 • Plugins: jars, loaded upon startup when in /plugins dir cytoscape.org [email protected] 5 1. Cytoscape and Plugins 3. Questions and feedback • Short intro on developer level: – What have you developed lately? – Familiarity with • Java? • Eclipse? • Cytoscape (plugin) development? – Special wishes? cytoscape.org [email protected] 6 2. Documentation 1. API 2. Wiki: the nugget pages 3. Community cytoscape.org [email protected] 7 2. Documentation 1. API • Through cytoscape.org: – http://chianti.ucsd.edu/Cyto-2_7_0/javadoc/ cytoscape.org [email protected] 8 2. Documentation 2. Wiki: the nugget pages • Developer home page: – http://cytoscape.wodaklab.org/wiki/Developer_Homepage • Plugin developer tutorial: – http://cytoscape.wodaklab.org/wiki/Cytoscape_Plugin_Tutorial • Developers cookbook: – http://cytoscape.wodaklab.org/wiki/plugin_developer_tutorial • Note: suffers from generic wikiproblem; container for all docs, some outdated some irrelevant... cytoscape.org [email protected] 9 2. Documentation 3. Community • General communication – – – – Cytoscape.org website Cytoscape wiki Cytoscape announce google mailing list Cytoscape discuss google mailing list • Internal communication (open to core Cytoscape developers) – Weekly conference call – Internal development mailing list • See here: http://cytoscape.wodaklab.org/wiki/Community_development_process cytoscape.org [email protected] 10 3. Basic Cytoscape architecture 1. Layers / Concepts 2. Graphs / Attributes 3. API cytoscape.org [email protected] 11 3. Basic Cytoscape architecture 1. Layers: Concepts • Graphs and Data Graphs (CyNetworks) Data (CyAttributes) VizMapper cytoscape.org [email protected] 12 3. Basic Cytoscape architecture 1. Layers: Concepts • Graphs and Data – Graphs and Networks • Root Graph: ONE graph to rule them all.... – All nodes and edges are part of the root graph • A network is a subset (projection) of the root graph • A network view is a visualization of a network • The Vizmapper maps attributes values to visual presentation – Attributes • Typed values that can be associated with CyNetworks, CyNodes, and CyEdges cytoscape.org [email protected] 13 3. Basic Cytoscape architecture 2. Graphs / Attributes RootGraph CyNetwork cytoscape.org [email protected] 14 3. Basic Cytoscape architecture 2. Graphs / Attributes – Attributes are not really "attributes" • Attributes are data values that might be associated with networks, nodes, and edges – You can read in attributes for nodes/edges you haven't created yet – Attributes are associated to nodes/edges by identifier (name) • Attributes are typed – Support for Integer, Double, Boolean, String, List, and Map (dictionaries) – Attributes are accessed by type, attribute name, object identifier (name) cytoscape.org [email protected] 15 3. Basic Cytoscape architecture 2. Graphs / Attributes Root Graph Implications • Two nodes with the same identifier in different networks are the same node – Once initialized with an id this will stay – They will have the same attributes – VizMap overrides (which are implemented as attributes) will effect all presentations of the node cytoscape.org [email protected] 16 3. Basic Cytoscape architecture 3. API: toplevel cytoscape.org [email protected] 17 3. Basic Cytoscape architecture 3. API: under the hood Cytoscape giny Cytoscape giny Implementatio n cytoscape.org [email protected] Model View CyNetwork CyNode CyEdge CyNetworkView CyNodeView CyEdgeView GraphPerspective Node Cytoscape API Edge fing FGraphPerspective FNode Edge GraphView NodeView EdgeView ding DGraphView DNodeView DEdgeView 18 3. Basic Cytoscape architecture 3. API • Graphs, Views, and Data (Attributes) – Views depend on Graphs – Data doesn't depend on anything • Graph – – – CyNetwork -> GraphPerspective (giny) -> FGraphPerspective (fing) CyNode -> Node (giny) -> FNode (fing) CyEdge -> Edge (giny) -> FEdge (fing) • View – – – CyNetworkView -> GraphView (giny) -> DGraphView (ding) CyNodeView -> NodeView (giny) -> DNodeView (ding) CyEdgeView -> EdgeView (giny) -> DEdgeView (ding) • Data – CyAttributes • Note: library dependencies introduce some peculiarities – Casts to specific types sometimes necessary – Use of lowlevel rootgraphindex – etc cytoscape.org [email protected] 19 3. Basic Cytoscape architecture 3. API • Navigating the Cytoscape API – Cytoscape class • Abstract static class • Starting point for most Cytoscape functionality • Contains factory methods for creating graph objects, views • Fires all events – Other useful classes • CyGroupManager: group-related information • CyLayouts: information about currently loaded layout algorithms cytoscape.org [email protected] 20 3. Basic Cytoscape architecture 3. API • Navigating the Cytoscape API – CyNetwork class • Collection of CyNodes (and CyEdges) • Unifies graph with data – CyNetworkView • Visualization of CyNetwork • Collection of CyNodeViews (and CyEdgeViews) – CytoscapeDesktop • Manages CyNetworkViews • Updates focus • Manages CytoPanels cytoscape.org [email protected] 21 3. Basic Cytoscape architecture 3. API • Navigating the Cytoscape API – CyAttributes • Three global sets associated with – Networks – Nodes – Edges • MultiHashMap datastructure cytoscape.org [email protected] 22 4. Plugins in Cytoscape 1. 2. 3. 4. cytoscape.org [email protected] Core and others Registering your plugin Pluginmanager Plugin communication 23 4. Plugins in Cytoscape 1. Core and others – It’s not all in cytoscape… • Cytoscape has four different groups of functionality: – cytoscape/: the core application – corelibs/: corelibs are parts of Cytoscape that are called by core routines, but never call any core routines. Much of the graph implementation is here. – coreplugins/: a significant piece of the Cytoscape functionality is “hidden” in the plugins that are delivered with cytoscape. As with any plugin, these are not directly available through the API. Including: » » » » » Layouts Data browser Editor Table import, SBML reader, and PSI-MI readers Filters – csplugins/: User-developed plugins add significant functionality. Many of those are available as source cytoscape.org [email protected] 24 4. Plugins in Cytoscape 1. Core and others cytoscape.org [email protected] 25 4. Plugins in Cytoscape 2. Registering your plugin • Define a plugin.props file for your plugin (based on sample) • Create a jar from your plugin including a manifest file ANT build tools exist... cytoscape.org [email protected] 26 4. Plugins in Cytoscape 3. Pluginmanager • Automated process to give users access to your plugin through Cytoscape itself 1. Check that your plugin conforms to the requirements on former slide (manifest and plugin.props files are required). 2. Go to http://chianti.ucsd.edu/cyto_web/plugins/pluginsubmittype.php and follow the instructions to submit your plugin. 3. Send an announcement to the announcement mailing list. cytoscape.org [email protected] 27 4. Plugins in Cytoscape 4. Plugin communication • Some rudimentary, but currently basically not possible – Call layout – Check if loaded • In 2.8 there will be a Command interface facilitating that • In 3.0 essentially everything will be plugin, communicating by default cytoscape.org [email protected] 28 5. Using an IDE Eclipse as an example…. • ANT: <= 2.7 • Maven: > 2.8 (and ANT) cytoscape.org [email protected] 29 5. Using an IDE • • • • Store the SamplePlugin dir in the workspace dir In Eclipse : Import>Existing project Set the libraries necessary Set the Run configuration • At home: use svn directly, use the Ant build config cytoscape.org [email protected] 30 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 31 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 32 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 33 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 34 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 35 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 36 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 37 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 38 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 39 5. Using an IDE: Eclipse (ANT) cytoscape.org [email protected] 40 5. Using an IDE: Eclipse (ANT) • …and run and debug! cytoscape.org [email protected] 41 5. Using an IDE: Eclipse (Maven) • Will become simpler with the plugin archetype • Default from 2.8 on • First upload takes a while… cytoscape.org [email protected] 42 5. Using an IDE: Eclipse (Maven) cytoscape.org [email protected] 43 5. Using an IDE: Eclipse (Maven) cytoscape.org [email protected] 44 5. Using an IDE: Eclipse (Maven) cytoscape.org [email protected] 45 5. Using an IDE: Eclipse (Maven) cytoscape.org [email protected] 46 5. Using an IDE: Eclipse (Maven) cytoscape.org [email protected] 47 5. Using an IDE: Eclipse (Maven) cytoscape.org [email protected] 48 5. Using an IDE: Eclipse (Maven) • Yet in beta; • Debugging etc in IDE (Eclipse) underway cytoscape.org [email protected] 49 5. Using an IDE: Eclipse • Check double check: – Everybody has a compiling and running project? cytoscape.org [email protected] 50 6. Creating a plugin 1. 2. 3. 4. cytoscape.org [email protected] Extending CytoscapePlugin Controlling the UI Generating and manipulating your network Additional topics 51 6. Creating a plugin: 1. Extending CytoscapePlugin cytoscape.org [email protected] 52 6. Creating a plugin: 1. Extending CytoscapePlugin • A class in your plugin should extend CytoscapePlugin – The constructor for this class will be called when your plugin is loaded • Store your jar in {cytoscape}/plugins • Plugin information is provided by a property file – Usually in resources/plugins.props cytoscape.org [email protected] 53 6. Creating a plugin: 2. Controlling the UI 1. Menu items 2. Cytopanels cytoscape.org [email protected] 54 6. Creating a plugin: 2. Controlling the UI 1. Menu items 1. Extend from CytoscapeAction 2. Attach to menu 2. Cytopanels 1. Get a panel from desktop 2. Add yourPanel extending JPanel cytoscape.org [email protected] 55 Plugin Lab Time Controlling the UI • Toy around with the existing tutorials (>tutorials>) – See what they do – Locate relevant code • Read – http://cytoscape.wodaklab.org/wiki/CytoPanel_Tutorial • MicroAssignment – Create your own button in the Menu – When clicked it writes to your panel cytoscape.org [email protected] 56 6. Creating a plugin: 3. Generating and manipulating your network 1. Creating nodes, edges, and networks 2. Mapping data: attributes 3. Link visually: Vizmapper cytoscape.org [email protected] 57 6.3 Generating and manipulating your network 1. Creating nodes, edges, and networks • Working with: – – – – Networks, Edges, Nodes Views of the above Creating, Selecting Library dependencies • Walk through of code of simple tutorials cytoscape.org [email protected] 58 Some peculiarities • cyNetwork.nodesList() Note, this returns a list of Nodes, not CyNodes. They can be safely cast • cyNetwork.edgesList() Note, this returns a list of Edges, not CyEdges. They can be safely cast • • • cyNode.getRootGraphIndex() cyEdge.getRootGraphIndex() cyNetwork.getAdjacentEdgeIndicesArray(int,true,true,true) Note, this takes root graph indices and returns and array of root graph indices, these methods tend to be faster, for large sets… • cyNetwork.getConnectingEdges(list) cytoscape.org [email protected] 59 6.3 Generating and manipulating your network 2. Mapping data: attributes Think of attributes as tables – 3 tables of attributes for the 3 graph objects – Cytoscape.getNetworkAttributes() – Cytoscape.getNodeAttributes() – Cytoscape.getEdgeAttributes() cytoscape.org [email protected] 60 And 6 Attribute Types • • • • • • TYPE_BOOLEAN (Boolean) TYPE_FLOATING (Double) TYPE_INTEGER (Integer) TYPE_STRING (String) TYPE_SIMPLE_LIST (List) TYPE_SIMPLE_MAP (Map) cytoscape.org [email protected] 61 Resulting API methods: Setting attributes cyAttributes.setAttribute(objectName,attrName,value) cyAttributes.setListAttribute(objectName,attrName,list) cyAttributes.setMapAttribute(objectName,attrName,map) Getting attributes cyAttributes.hasAttribute(objectName,attrName) cyAttributes.getBooleanAttribute(objectName,attrName) cyAttributes.getDoubleAttribute(objectName,attrName) cyAttributes.getIntegerAttribute(objectName,attrName) cyAttributes.getListAttribute(objectName,attrName) cyAttributes.getMapAttribute(objectName,attrName) …and some additional characteristics cyAttributes.setUserEditable(name,boolean) cyAttributes.setUserVisible(name,boolean) cytoscape.org [email protected] 62 Plugin Lab Time Creating networks - Adding data • Demo tutorials • Read – http://cytoscape.wodaklab.org/wiki/Concepts_Document – http://cytoscape.wodaklab.org/wiki/CytoscapeData • MicroAssignment – Create your own network – Add some data attributes – Set the positions of nodes based on values of the attributes cytoscape.org [email protected] 63 6.3 Generating and manipulating your network 3. Linking Visuals • Remember central idea: Graphs (CyNetworks) Data (CyAttributes) VizMapper cytoscape.org [email protected] 64 Linking Visuals: the Vizmapper • Summary: – Get the VisualMappingManager – Get the Catalog that keeps track of all mappingcalculators – Create your style • Create Node, Edge, and Global AppearanceCalculators • Construct a calculator for each VisualProperty • Create a PassThrough, Discrete, or Continuous mapper that maps an attribute to a VisualProperty • Set the calculator in the AppearanceCalculator • Create the style with all three AppearanceCalculators – Set your style in the NetworkView – Add your style to the catalog – Apply the style: applyStyle or redrawGraph cytoscape.org [email protected] 65 Plugin Lab Time Mapping visuals • Demo relevant tutorials • Read: http://cytoscape.wodaklab.org/wiki/Visual_Mapping_Syste m_Guide • Micro Assignment – Map visuals based on the network and data you created – Use a calculator to set values cytoscape.org [email protected] 66 6. Creating a plugin 4. Additional topics • Additional Topics • Walkthrough code: an example plugin – – – – Events TaskMonitor Tunables Layouts • Any additional ??? – Webstart? – Groups? cytoscape.org [email protected] 67 Events • Cytoscape and CytoscapeDesktop are event firing classes • Any event listener needs to implement java.beans.PropertyChangeListener • Add your listener to Cytoscape or CytoscapeDesktop Cytoscape.getSwingPropertyChangeSupport().addProperty ChangeListener(this); cytoscape.org [email protected] 68 Events Event Firing Class CYTOSCAPE_EXIT Cytoscape NETWORK_CREATED Cytoscape NETWORK_DESTROYED Cytoscape ATTRIBUTES_CHANGED Cytoscape NETWORK_VIEW_CREATED CytoscapeDesktop NETWORK_VIEW_DESTROYED CytoscapeDesktop NETWORK_VIEW_FOCUS CytoscapeDesktop NETWORK_VIEW_FOCUSED CytoscapeDesktop cytoscape.org [email protected] 69 Tunables • Tunables – Serves three purposes: • Persistence of values • Automatic UI generation • External access to plugin parameters – Tunables are typed cytoscape.org [email protected] 70 Tunables • Tunable objects take 7 arguments – – – – – – – name: the name of the tunable description: the description of the tunable type: the tunable type value: the initial value of the tunable lowerBound: the lower bound of the tunable upperBound: the upper bound of the tunable flag: flags to provide hints to the UI generators cytoscape.org [email protected] 71 Tunable Types • Types – – – – – – – – – INTEGER DOUBLE BOOLEAN STRING NODEATTRIBUTE EDGEATTRIBUTE LIST GROUP BUTTON cytoscape.org [email protected] 72 Tunable Bounds and Flags • Bounds and flags – Bounds provide: • upper/lower bounds of numeric quantities • The list for a List • An initial list for attributes (to allow alternative choices) – Flags provide hints for the UI • MULTISELECT to allow multiple selection in a list • USESLIDER to use a slider for numeric values (must also have bounds) • IMMUTABLE to display the value but not allow editing • COLLAPSABLE to implement collapsible groups • NOINPUT for internal parameters that aren't presented to the user • NUMERICATTRIBUTE to restrict attribute presentation to numeric values cytoscape.org [email protected] 73 Tunable Interaction • Interaction – BUTTON tunable • Lower bound is an ActionListener • Called when the button is pressed – A TunableValueListener • Can be added to any Tunable • Caller will be notified when a tunable value changes cytoscape.org [email protected] 74 LayoutProperties • Two functions – Collect all Tunables into a list – Generate a single JPanel with all of the Tunable interfaces • LayoutProperties handles GROUPing • Example: tunableSampler cytoscape.org [email protected] 75 Layouts • Layouts should all inherit from AbstractLayout • Registering layouts – CyLayout.addLayout(algorithm, menu) – Information about capabilities are determined through callbacks – Registered layouts can be "found" by plugins by calling CyLayout.getLayout(name) • Cytoscape's layout menu takes care of tasks – Use LayoutTask if you want to call a layout yourself on a separate thread: • LayoutTask(layout,view) • TaskManager.executeTask(layoutTask, LayoutTask.getDefaultTaskConfig()) cytoscape.org [email protected] 76 Layouts • Layout callbacks: – LayoutProperties getSettings(): • Return your list of Tunables – updateSettings(): • Update all of the Tunables values – revertSettings(): • Revert all Tunables values to the default – JPanel getSettingsPanel(): • Return the settings panel for this layout • Return from LayoutProperties.getTunablePanel() cytoscape.org [email protected] 77 Layouts • Using an existing layout – Get the CyLayoutAlgorithm: • CyLayoutAlgorithm alg = CyLayouts.getLayout(String); – Get the Tunables: • LayoutProperties props = alg.getSettings(); – Set the Tunables you want: • Tunable t1 = props.get(String); • t1.setValue(Object); • alg.updateSettings(); – Set appropriate flags (will also be Tunables): • alg.setSelectedOnly(boolean); • alg.setLayoutAttribute(String); – Do the layout: • alg.doLayout(CyNetworkView, TaskMonitor); cytoscape.org [email protected] 78 Group concepts • A group is a collection of nodes and their edges • A node may be defined in multiple groups • A group is represented by a node, which might itself be part of a group – Groups are hierarchical cytoscape.org [email protected] 79 Creating groups • CyGroupManager.createGroup(name,list, viewer) cytoscape.org [email protected] 80 Using groups • • • • • • • • • • • • • cyGroup.addNode(node) cyGroup.addInnerEdge(edge) cyGroup.addOuterEdge(edge) cyGroup.getNodes() cyGroup.getInnerEdges() cyGroup.getOuterEdges() cyGroup.getGroupNode() cyGroup.getState() cyGroup.removeNode() cyGroup.setState(int) cyNode.inGroup(group) cyNode.getGroups() cyNode.isaGroup() cytoscape.org [email protected] 81 GroupViewers • Group is visualized by a CyGroupViewer • The CyGroupViewer for a group can be changed • Common usage for creating lots of groups: – Create group with no viewer – Set viewer: • CyGroupManager.setGroupViewer(group, viewer, view, false) – On last group: • CyGroupManager.setGroupViewer(group, viewer, view, true) cytoscape.org [email protected] 82 Plugin Lab Time • Demo relevant tutorials: which topics??? • Micro Assignment – Create or elaborate your own plugin using one of the advanced topics cytoscape.org [email protected] 83 7. The future: Cytoscape 3.0 cytoscape.org [email protected] 84 2.x: Disadvantages Cytoscape 2.x works OK but….. • • • • • • • One big graph Layers interconnected No clean ModelViewController separation Library dependencies Library versioning Plugins cannot communicate Plugin versioning cytoscape.org [email protected] 85 Layers Model View Cytoscape CyNetwork CyNode CyEdge CyNetworkView CyNodeView CyEdgeView giny GraphPerspective Node Edge GraphView NodeView EdgeView Cytoscape’s Giny Implementation cytoscape.org [email protected] fing FGraphPerspective FNode Edge Cytoscape API ding DGraphView DNodeView DEdgeView 86 NextGen Cytoscape 3.0 Goals • Easier interface for plugin writers to understand and use. • Better modularity or layering making it easier for components of Cytoscape can be used in different contexts. • Clean up/refactor the structure of the existing Cytoscape core so that it can be more easily maintained, modified, and extended in the future. • Make backwards compatibility easier to maintain. • Clean up the user interface so that it's easier for users. cytoscape.org [email protected] 87 NextGen Cytoscape 3.0 Desired features • All features of 2.7 • Layer Cytoscape; allow alternative uses of Cytoscape. • Separate the view from the model; various headless (or alternatively headed) modes • Command layer; GUI it currently too tightly coupled with actions. Should be extensible for plugin writers • Improved Event handling; currently mish-mash of events, clean interface is needed. • Custom graphics. • Improve build process and package structure; simplify the build process • Local Attributes; allow attributes specific to networks. • Dynamic language support; for dynamic (scripting) languages cytoscape.org [email protected] 88 Cytoscape 3, OSGi, and Spring Framework • Based on slides from Keiichiro Ono, UCSD • Cytoscape Core Developer cytoscape.org [email protected] 89 Outline • • • • Dependency Injection What is Spring Framework? OSGi and Spring Integration to Cytoscape 3 cytoscape.org [email protected] 90 Dependency Injection (DI) • A Design Pattern to achieve: ✓Separate configuration from use ✓Low Coupling ✓Easy unit testing cytoscape.org [email protected] 91 Why DI? (1) • Cytoscape 3 will be an expandable, and UI-independent platform • Desktop application, Web application, or Web Service • Plugins interact to each other to build complex services/functions cytoscape.org [email protected] 92 Why DI? (2) • OSGi solves: – Library versioning/dependency/conflict problem ➡ Important for applications with plugin architecture – Dynamic loading problem – Modularity – Interface-Based Design (Service Framework) cytoscape.org [email protected] 93 Why DI? (3) • Remaining Issues – How can we make Cytoscape re-configurable? –From Desktop to Sever Backend – How can we manage instances of components ➡ DI Pattern helps to solve these problems cytoscape.org [email protected] 94 Summary • • • Dependency Injection pattern is useful for applications with plugin architecture DI pattern makes application scalable Spring DM provides simpler way to manage OSGi services cytoscape.org [email protected] 95 Current status of Cy3 • • • • • Core plugins are being ported to Cy3 Plugin development not yet possible Keep an eye on the development modules page Docs not yet complete Learning curve quite steep cytoscape.org [email protected] 96 Feedback! • • • • • Quirks Annoyances Dev suggestions Features? … cytoscape.org [email protected] 97
© Copyright 2025 Paperzz