[Bio] / Detour / go.py Repository:
ViewVC logotype

View of /Detour/go.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (download) (as text) (annotate) (vendor branch)
Thu Sep 9 20:02:51 2004 UTC (15 years, 2 months ago) by sheradon
Branch: init, MAIN
CVS Tags: v0, HEAD
Changes since 1.1: +0 -0 lines
init load

#!/usr/bin/env python

import os, sys, string, tempfile, traceback, cPickle
from wxPython.wx import *
from pydot		 			  import graph_from_dot_file, graph_from_dot_data

# We'll be a Kah plugin module
from KahApp.KahModule     import KahModule

# And other modules for this project:
from Detour.DetourCanvas  import DetourCanvas
import Detour.RecoReader		as RecoReader
import Speck.KPLayout			as KPLayout
import Speck.JGLayout			as JGLayout
import Speck.Chromium			as Chromium

# -------------------------------
# Plugin interface to ModelEditor
# -------------------------------
def registerHook( register ):
	register('Detour: Dot',			'View using a hierarchical DOT layout',			DotViewModule('detour_graphviz', prog='dot'))
	register('Detour: Neato',		'A radial layout, best for very small graphs',	DotViewModule('detour_graphviz', prog='neato'))
	#register('Detour: Circo',		'Only availale with later Graphviz versions',	DotViewModule('detour_graphviz', prog='circo'))
	register('Detour: JGraph',		'Layout with the JGraph Java library',				JGViewModule('detour_jgraph'))
	register('Detour: KP',			'An experimental layout in early development',	KPViewModule('detour_kp'))
	register('Detour/uM2: Dot',	'Look at this pathway on the uMural2',				DotViewModule('detour_graphviz', prog='dot', where='uM2'))
	register('Detour/uM2: Neato',	'Look at this pathway on the uMural2',				DotViewModule('detour_graphviz', prog='neato', where='uM2'))

# ----------------------------
class DotViewModule(KahModule):
# ----------------------------
	def __init__(self, name, prog='dot', where=None):
		KahModule.__init__(self, name)
		self.prog = prog
		self.where = where

	def process(self, re, cfg):
		wxBeginBusyCursor()
		try:
			print 'Processing ' + re.Name + ', this may take a few minutes for large graphs... '
			D = RecoReader.makeDot(re)
			data = D.create(prog=self.prog, format='dot')
			if self.where:
				Chromium.display(self.where, 'Detour.DetourCanvas.DetourCanvas', data, serverPort=8008)
			else:
				# Open a window for it.	
				win = wxFrame(None, wxID_ANY, "Speck : %s" % re.Name, size = (900, 500))
				dc = DetourCanvas(win, data, serverPort=8008)
				win.Show(True)
		finally: wxEndBusyCursor()	

# ----------------------------
class KPViewModule(KahModule):
# ----------------------------
	def process(self, re, cfg):
		wxBeginBusyCursor()
		try:
			print 'Processing ' + re.Name + ', this may take a few minutes for large graphs... '
			d = RecoReader.makeDot(re)
			KPLayout.layoutDot(d)
			# Just open a window for it.	
			win = wxFrame(None, wxID_ANY, "Speck :: %s" % re.Name, size = (900, 500))
			dc = DetourCanvas(win, d.to_string(), serverPort=8008)
			win.Show(True)
		finally: wxEndBusyCursor()	

# ------------------------------
class JGViewModule(KahModule):
# ------------------------------
	def process(self, re, cfg):
		print 'Processing ' + re.Name + ', this may take a few minutes for large graphs... '
		D = RecoReader.makeDot(re)
		D = JGLayout.layoutDot(D)
		# Open a window for it.	
		win = wxFrame(None, wxID_ANY, "Speck :: %s" % re.Name, size = (900, 500))
		dc = DetourCanvas(win, D.to_string(), serverPort=8008)
		win.Show(True)


# -----------------------------------------------------------
#  Takes a .dot file, displays it in a Detour viewer window.
# -----------------------------------------------------------
if ( __name__ == "__main__"):
# -----------------------------------------------------------
	app = wxPySimpleApp()

	# Maybe a filename to test with was specified. Try that first.
	if len(sys.argv) > 1:
		filename = sys.argv[1]
		f = file(filename, 'r')		
		win = wxFrame(None, wxID_ANY, 'Speck', size = (900, 500))
		dc = DetourCanvas(win, f.read(), serverPort=8008)
		f.close()
		win.Show(True)
		app.MainLoop()

	else:
		print 'Usage: ' + sys.argv[0] + ' <dotfile>'
	



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3