Author: kono
Date: 2009-12-04 12:36:02 -0800 (Fri, 04 Dec 2009)
New Revision: 18656

Added:
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/build.xml
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/lib/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/lib/ScriptEngineManager.jar
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/plugin.props
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/
   
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/
   
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/PythonEnginePlugin.java
   
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/ui/
   
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/ui/PythonConsole.java
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/testscripts/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/testscripts/test1.py
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/util-scripts/
   csplugins/trunk/ucsd/kono/JythonEnginePlugin/util-scripts/message.py
Log:


Added: csplugins/trunk/ucsd/kono/JythonEnginePlugin/build.xml
===================================================================
--- csplugins/trunk/ucsd/kono/JythonEnginePlugin/build.xml                      
        (rev 0)
+++ csplugins/trunk/ucsd/kono/JythonEnginePlugin/build.xml      2009-12-04 
20:36:02 UTC (rev 18656)
@@ -0,0 +1,126 @@
+<?xml version="1.0"?>
+<!-- 
+
+       Python Scripting Engine for Cytoscape by Kei Ono 
+       
+       To build this plugin, you need to download Jython separately.
+       
+-->
+
+<project name="PythonScriptingEngine" default="all" basedir=".">
+
+       <!-- Name of jython directory. -->
+       <property name="jython.version" value="jython2.5.1" />
+
+       <!-- You need modify this to your Cytoscape -->
+       <property name="cytoscape.dir" value="../cytoscape" />
+
+       <!-- All files generated by ant go here -->
+       <property name="build.dir" value="${basedir}/build" />
+
+       <!-- The java source directory-->
+       <property name="src.dir" value="${basedir}/src" />
+
+       <property name="project.jar" value="PythonScriptingEngine.jar" />
+
+       <!--  ============ Compilation Control Options ======================= 
-->
+       <property name="compile.debug" value="true" />
+       <property name="compile.deprecation" value="true" />
+       <property name="compile.optimize" value="true" />
+
+
+       <!-- ==================== Compilation Classpath ====================== 
-->
+       <path id="compile.classpath">
+               <fileset dir="${cytoscape.dir}">
+                       <include name="cytoscape.jar" />
+               </fileset>
+               <fileset dir="${basedir}/lib">
+                       <include name="*.jar" />
+               </fileset>
+               <fileset dir="${basedir}/${jython.version}">
+                       <include name="jython.jar" />
+                       <include name="JyConsole.jar" />
+               </fileset>
+
+       </path>
+
+       <!-- ==================== Clean Target =============================== 
-->
+       <target name="clean" description="Deletes all build files and starts 
fresh">
+               <delete dir="${build.dir}" />
+               <delete file="${project.jar}" />
+       </target>
+
+       <!-- ==================== Compile Target 
==============================-->
+       <target name="compile" depends="prepare" description="Compiles all Java 
source files">
+               <mkdir dir="${build.dir}/classes" />
+               <javac srcdir="${src.dir}" source="1.5" target="1.5" 
destdir="${build.dir}/classes" debug="${compile.debug}" 
deprecation="${compile.deprecation}" optimize="${compile.optimize}">
+                       <classpath refid="compile.classpath" />
+               </javac>
+       </target>
+
+       <!-- ==================== Jar Target ============================== -->
+       <target name="jar" depends="compile" description="Creates Plugin Jar:  
${project.jar}">
+
+               <unjar dest="${build.dir}/classes">
+                       <!--fileset dir="${basedir}/lib">
+                               <include name="*.jar" />
+                       </fileset-->
+                       <fileset dir="${basedir}/${jython.version}">
+                               <include name="*.jar" />
+                       </fileset>
+                       <fileset 
dir="${basedir}/JyConsole-1.4-bin/thirdpart/ArtTk">
+                               <include name="*.jar" />
+                       </fileset>
+               </unjar>
+
+
+               <copy toDir="${build.dir}/script">
+                       <fileset dir="${basedir}/JyConsole-1.4-bin/script" 
includes="**/*" />
+               </copy>
+
+               <copy toDir="${build.dir}/classes/Lib">
+                       <fileset dir="${basedir}/${jython.version}/Lib" 
includes="**/*" />
+               </copy>
+
+
+               <copy toDir="${build.dir}/classes/util-scripts">
+                       <fileset dir="${basedir}/util-scripts" includes="**/*" 
/>
+               </copy>
+               <copy 
todir="${build.dir}/classes/edu/ucsd/bioeng/idekerlab/pythonengine" 
file="${basedir}/plugin.props" />
+
+               <copy todir="${build.dir}/classes/images">
+                       <fileset dir="${basedir}/images" />
+               </copy>
+
+
+
+               <jar destfile="${project.jar}" basedir="${build.dir}/classes">
+
+                       <manifest>
+                               <attribute name="Cytoscape-Plugin" 
value="edu.ucsd.bioeng.idekerlab.pythonengine.PythonEnginePlugin" />
+                       </manifest>
+
+               </jar>
+       </target>
+
+       <!-- ==================== Build and test jar 
============================== -->
+       <target name="all" depends="jar" />
+
+       <!-- ==================== Prepare Target ============================== 
-->
+       <target name="prepare">
+               <!-- Create build directories as needed -->
+               <mkdir dir="${build.dir}" />
+               <mkdir dir="${build.dir}/classes" />
+
+       </target>
+
+       <!-- ==================== JUnit Test Target =========================== 
-->
+       <target name="test" description="Runs all JUnit tests" 
depends="compile">
+               <junit printsummary="yes" fork="yes" haltonfailure="yes">
+                       <formatter type="plain" usefile="false" />
+                       <test name="cytoscape.test.AllTest" />
+                       <classpath refid="compile.classpath" />
+               </junit>
+       </target>
+
+</project>

Added: csplugins/trunk/ucsd/kono/JythonEnginePlugin/lib/ScriptEngineManager.jar
===================================================================
(Binary files differ)


Property changes on: 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/lib/ScriptEngineManager.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: csplugins/trunk/ucsd/kono/JythonEnginePlugin/plugin.props
===================================================================
--- csplugins/trunk/ucsd/kono/JythonEnginePlugin/plugin.props                   
        (rev 0)
+++ csplugins/trunk/ucsd/kono/JythonEnginePlugin/plugin.props   2009-12-04 
20:36:02 UTC (rev 18656)
@@ -0,0 +1,22 @@
+# -- The following properties are REQUIRED -- #
+
+# The plugin name that will be displayed to users
+pluginName=PythonScriptingEngine
+
+# Description used to give users information about the plugin such as what it 
does.  
+# Html tags are encouraged for formatting purposes.
+pluginDescription=<p>Scripting engine based on Jython 2.5.1 implementation.  
This plugin uses JyConsole library by Artenum OpenSource 
project.</p><p><strong><font color="red">This plugin is for technology 
evaluation purpose ONLY!  Totally experimental.</font></strong>
+
+# Plugin version number, this must be two numbers separated by a decimlal.  
Ex. 0.2, 14.03
+pluginVersion=0.20
+
+# Compatible Cytoscape version
+cytoscapeVersion=2.6, 2.7
+
+# Category, use one of the categories listed on the website or create your own
+pluginCategory=Communication/Scripting
+
+
+# List of authors.  Note each author and institution pair are separated by a : 
(colon)
+# each additional author institution pair must be separated from other pairs 
bye a ; (semicolon)
+pluginAuthorsIntsitutions=Keiichiro Ono:UCSD Department of Medicine
\ No newline at end of file

Added: 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/PythonEnginePlugin.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/PythonEnginePlugin.java
                             (rev 0)
+++ 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/PythonEnginePlugin.java
     2009-12-04 20:36:02 UTC (rev 18656)
@@ -0,0 +1,173 @@
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package edu.ucsd.bioeng.idekerlab.pythonengine;
+
+import cytoscape.Cytoscape;
+
+import cytoscape.logger.CyLogger;
+
+import cytoscape.plugin.CytoscapePlugin;
+
+import edu.ucsd.bioeng.idekerlab.pythonengine.ui.PythonConsole;
+import edu.ucsd.bioeng.idekerlab.scriptenginemanager.ScriptEngineManagerPlugin;
+import edu.ucsd.bioeng.idekerlab.scriptenginemanager.engine.ScriptingEngine;
+
+import org.apache.bsf.BSFManager;
+
+import java.awt.event.ActionEvent;
+
+import java.beans.PropertyChangeEvent;
+
+import java.io.File;
+
+import java.lang.reflect.Method;
+
+import javax.swing.AbstractAction;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JMenuItem;
+
+
+/**
+ *
+ */
+public class PythonEnginePlugin extends CytoscapePlugin implements 
ScriptingEngine {
+       private static final String ENGINE_NAME = "jython";
+       private static final String ENGINE_DISPLAY_NAME = "Python Scripting 
Engine (based on Jython v2.5.1)";
+
+       // BSF engine name
+       private static final String ENGINE_CLASS_NAME = 
"org.apache.bsf.engines.jython.JythonEngine";
+
+       // Icon of for script runner dialog
+       private static final Icon ICON = new 
ImageIcon(PythonEnginePlugin.class.getResource("/images/python.png"));
+
+       // Static instance of this plugin
+       private static final PythonEnginePlugin engine = new 
PythonEnginePlugin();
+
+       //      private static final JyConsole console = new JyConsole();
+
+       /**
+        * Creates a new RubyEnginePlugin object.
+        */
+       public PythonEnginePlugin() {
+               
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(this);
+       }
+
+       /**
+        * DOCUMENT ME!
+        *
+        * @return DOCUMENT ME!
+        */
+       public String getDisplayName() {
+               // TODO Auto-generated method stub
+               return ENGINE_DISPLAY_NAME;
+       }
+
+       /**
+        * DOCUMENT ME!
+        *
+        * @return DOCUMENT ME!
+        */
+       public Icon getIcon() {
+               // TODO Auto-generated method stub
+               return ICON;
+       }
+
+       /**
+        * DOCUMENT ME!
+        *
+        * @return DOCUMENT ME!
+        */
+       public String getIdentifier() {
+               // TODO Auto-generated method stub
+               return ENGINE_NAME;
+       }
+
+       /**
+        * DOCUMENT ME!
+        */
+       public static void register() {
+               BSFManager.registerScriptingEngine(ENGINE_NAME, 
ENGINE_CLASS_NAME,
+                                                  new String[] { ENGINE_NAME 
});
+
+               try {
+                       final Class engineClass = 
Class.forName("edu.ucsd.bioeng.idekerlab.scriptenginemanager.ScriptEngineManager");
+                       Method method = engineClass.getMethod("registerEngine",
+                                                             new Class[] { 
String.class, ScriptingEngine.class });
+                       Object ret = method.invoke(null, new Object[] { 
ENGINE_NAME, engine });
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+
+               final JMenuItem consoleMenuItem = new JMenuItem(new 
AbstractAction("Open Python Console...") {
+                               public void actionPerformed(ActionEvent e) {
+                                       
PythonConsole.getConsoleFrame().setVisible(true);
+                               }
+                       });
+
+               consoleMenuItem.setIcon(new 
ImageIcon(PythonEnginePlugin.class.getResource("/images/python22x22.png")));
+
+               
ScriptEngineManagerPlugin.getManager().addConsoleMenu(consoleMenuItem);
+
+               CyLogger.getLogger().info("Python scripting engine registered 
successfully.");
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @param fileName DOCUMENT ME!
+        */
+       public static void executePythonScript(String fileName) {
+               PythonConsole.getConsoleFrame().setVisible(true);
+               PythonConsole.getConsole().clear();
+               PythonConsole.getConsole().executePythonFile(new 
File(fileName));
+       }
+
+       /**
+        * DOCUMENT ME!
+        *
+        * @param e
+        *            DOCUMENT ME!
+        */
+       public void propertyChange(PropertyChangeEvent e) {
+               if 
(ScriptEngineManagerPlugin.getManager().getEngine(ENGINE_NAME) != null)
+                       return;
+
+               if 
(e.getPropertyName().equals(Cytoscape.CYTOSCAPE_INITIALIZED)) {
+                       // Register this to ScriptEngineManager.
+                       register();
+               }
+       }
+}

Added: 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/ui/PythonConsole.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/ui/PythonConsole.java
                               (rev 0)
+++ 
csplugins/trunk/ucsd/kono/JythonEnginePlugin/src/edu/ucsd/bioeng/idekerlab/pythonengine/ui/PythonConsole.java
       2009-12-04 20:36:02 UTC (rev 18656)
@@ -0,0 +1,163 @@
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package edu.ucsd.bioeng.idekerlab.pythonengine.ui;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JFrame;
+
+import com.artenum.jyconsole.JyConsole;
+
+import edu.ucsd.bioeng.idekerlab.pythonengine.PythonEnginePlugin;
+
+
+/*
+ * PythonConsole.java
+ *
+ * Created on 2008/09/23, 14:42
+ */
+
+/**
+ *
+ * @author  kono
+ */
+public class PythonConsole extends javax.swing.JFrame {
+       /** Creates new form PythonConsole */
+       private static final JyConsole console = new JyConsole();
+       private static final PythonConsole pyConsole = new PythonConsole();
+       private static JFrame f;
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public static JFrame getConsoleFrame() {
+               
+               if (f == null) {
+                       f = new JFrame("Python Console for Cytoscape");
+                       f.setSize(700, 500);
+                       f.getContentPane().add(console, BorderLayout.CENTER);
+                       f.getContentPane().add(titlePanel, BorderLayout.NORTH);
+                       f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+               }
+
+               return f;
+       }
+       
+       public static JyConsole getConsole() {
+               return console;
+       }
+
+
+       private PythonConsole() {
+               initComponents();
+       }
+
+       /** This method is called from within the constructor to
+        * initialize the form.
+        * WARNING: Do NOT modify this code. The content of this method is
+        * always regenerated by the Form Editor.
+        */
+       @SuppressWarnings("unchecked")
+       // <editor-fold defaultstate="collapsed" desc="Generated Code">
+       private void initComponents() {
+               this.setTitle("Python Console for Cytoscape");
+               this.setDefaultCloseOperation(HIDE_ON_CLOSE);
+
+               titlePanel = new javax.swing.JPanel();
+               pythonIcon = new javax.swing.JLabel();
+               plusLabel = new javax.swing.JLabel();
+               cytoscapeIcon = new javax.swing.JLabel();
+               titleLabel = new javax.swing.JLabel();
+               //consolePanel = new javax.swing.JPanel();
+
+               //JyConsole jyConsole = new JyConsole();
+               //jyConsole.add(jyConsole, BorderLayout.CENTER);
+               //this.getContentPane().add(jyConsole, BorderLayout.CENTER);
+
+               
//setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+               titlePanel.setBackground(new java.awt.Color(255, 255, 255));
+
+               pythonIcon.setBackground(new java.awt.Color(255, 255, 255));
+               pythonIcon.setIcon(new 
javax.swing.ImageIcon(PythonEnginePlugin.class.getResource("/images/python.png")));
 // NOI18N
+
+               plusLabel.setFont(new java.awt.Font("SansSerif", 1, 24)); // 
NOI18N
+               plusLabel.setText("+");
+
+               cytoscapeIcon.setBackground(new java.awt.Color(255, 255, 255));
+               cytoscapeIcon.setIcon(new 
javax.swing.ImageIcon(PythonEnginePlugin.class.getResource("/images/icon48.png")));
 // NOI18N
+
+               titleLabel.setFont(new java.awt.Font("SansSerif", 1, 18)); // 
NOI18N
+               titleLabel.setText("Python Console for Cytoscape");
+
+               org.jdesktop.layout.GroupLayout titlePanelLayout = new 
org.jdesktop.layout.GroupLayout(titlePanel);
+               titlePanel.setLayout(titlePanelLayout);
+               
titlePanelLayout.setHorizontalGroup(titlePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                                                                   
.add(titlePanelLayout.createSequentialGroup()
+                                                                               
         .addContainerGap()
+                                                                               
         .add(pythonIcon)
+                                                                               
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                                                                               
         .add(plusLabel)
+                                                                               
         .add(18, 18, 18)
+                                                                               
         .add(cytoscapeIcon)
+                                                                               
         .add(18, 18, 18)
+                                                                               
         .add(titleLabel)
+                                                                               
         .addContainerGap(51,
+                                                                               
                          Short.MAX_VALUE)));
+               
titlePanelLayout.setVerticalGroup(titlePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                                                                 
.add(titlePanelLayout.createSequentialGroup()
+                                                                               
       .addContainerGap()
+                                                                               
       
.add(titlePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                                                                               
                            .add(pythonIcon)
+                                                                               
                            .add(plusLabel)
+                                                                               
                            .add(cytoscapeIcon)
+                                                                               
                            .add(titleLabel))
+                                                                               
       .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+                                                                               
                        Short.MAX_VALUE)));
+
+               pack();
+       } // </editor-fold>
+
+       // Variables declaration - do not modify
+       //private javax.swing.JPanel jyConsole;
+       private javax.swing.JLabel cytoscapeIcon;
+       private javax.swing.JLabel plusLabel;
+       private javax.swing.JLabel pythonIcon;
+       private javax.swing.JLabel titleLabel;
+       private static javax.swing.JPanel titlePanel;
+
+       // End of variables declaration
+}

Added: csplugins/trunk/ucsd/kono/JythonEnginePlugin/testscripts/test1.py
===================================================================
--- csplugins/trunk/ucsd/kono/JythonEnginePlugin/testscripts/test1.py           
                (rev 0)
+++ csplugins/trunk/ucsd/kono/JythonEnginePlugin/testscripts/test1.py   
2009-12-04 20:36:02 UTC (rev 18656)
@@ -0,0 +1,61 @@
+from cytoscape import Cytoscape
+
+import cytoscape.layout.CyLayouts as CyLayouts
+import java.lang.Integer as Integer
+import random
+
+ORIGINAL_NODES = 2
+MAX_LOOP = 1000 - ORIGINAL_NODES
+EACH_TRIAL = 2
+
+# Create network
+graph = Cytoscape.createNetwork("Barabasi-Albert generated by Python Script");
+
+#Create seed graph
+node1 = Cytoscape.getCyNode("Seed 1", True)
+node2 = Cytoscape.getCyNode("Seed 2", True)
+nodes = [node1, node2]
+
+graph.addNode(node1)
+graph.addNode(node2)
+edge = Cytoscape.getCyEdge(node1, node2, "interaction", "-", True);
+graph.addEdge(edge);
+
+degree = 0.0
+prob = 0.0
+i = 0
+
+# Grow the seed graph
+print "\n\n============Barabasi-Albert Random Graph Generator ============"
+print "\nGenerating network (1000 nodes).  Please wait..."
+
+while (i<MAX_LOOP) :
+    newNode = Cytoscape.getCyNode(Integer.toString(i), True)
+    graph.addNode(newNode)
+    
+    j = 0
+    while (j<EACH_TRIAL):   
+        created = False
+        while (created == False):
+            idx = random.random() * len(nodes)
+            selectedNode = nodes[int(idx)]
+            degree = graph.getDegree(selectedNode)
+            prob = (degree + 1.0) / (graph.getNodeCount() + 
graph.getEdgeCount() - 1.0)
+            if prob >= random.random() and newNode.getIdentifier != 
selectedNode.getIdentifier:
+                created = True;
+        
+        edge = Cytoscape.getCyEdge(newNode, selectedNode, "interaction", "-", 
True)
+        graph.addEdge(edge)
+        nodes.append(newNode)
+        j = j+1        
+    
+    i = i+1
+
+# Layout nodes
+
+print "Network generated.  Start layout..."
+
+CyLayouts.getLayout("force-directed").doLayout();
+Cytoscape.getCurrentNetworkView().redrawGraph(False, True);
+
+print "\n\nDone!"
\ No newline at end of file

Added: csplugins/trunk/ucsd/kono/JythonEnginePlugin/util-scripts/message.py
===================================================================
--- csplugins/trunk/ucsd/kono/JythonEnginePlugin/util-scripts/message.py        
                        (rev 0)
+++ csplugins/trunk/ucsd/kono/JythonEnginePlugin/util-scripts/message.py        
2009-12-04 20:36:02 UTC (rev 18656)
@@ -0,0 +1 @@
+print "============= Finished! ==============="
\ No newline at end of file

--

You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.


Reply via email to