From 01d15a1e6fa3980e2b1be32d87232d37baa123c6 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 18 Jan 2011 11:22:43 -0500 Subject: [PATCH] Sort workflow steps based on the layout in the workflow editor. Prior to the topological sort, steps are arranged based on distance from top left corner. --- lib/galaxy/web/controllers/workflow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/web/controllers/workflow.py b/lib/galaxy/web/controllers/workflow.py index 788e14c1cd8..c1872372895 100644 --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -5,7 +5,7 @@ pkg_resources.require( "simplejson" ) pkg_resources.require( "SVGFig" ) import simplejson import base64, httplib, urllib2, sgmllib, svgfig - +import math from galaxy.web.framework.helpers import time_ago, grids from galaxy.tools.parameters import * from galaxy.tools import DefaultToolState @@ -1670,6 +1670,7 @@ def order_workflow_steps( steps ): """ Perform topological sort of the steps, return ordered or None """ + steps.sort(cmp=lambda s1,s2: cmp( math.sqrt(s1.position['left']**2 + s1.position['top']**2), math.sqrt(s2.position['left']**2 + s2.position['top']**2))) try: edges = edgelist_for_workflow_steps( steps ) node_order = topsort( edges )