[Swift-commit] r7528 - SwiftApps/swift-galaxy/swift

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Thu Jan 30 09:26:31 CST 2014


Author: ketan
Date: 2014-01-30 09:26:30 -0600 (Thu, 30 Jan 2014)
New Revision: 7528

Added:
   SwiftApps/swift-galaxy/swift/swiftforeachrangepp.py
Modified:
   SwiftApps/swift-galaxy/swift/swiftforeachlist.xml
   SwiftApps/swift-galaxy/swift/swiftforeachrange.xml
Log:
add postprocess script

Modified: SwiftApps/swift-galaxy/swift/swiftforeachlist.xml
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachlist.xml	2014-01-30 01:14:51 UTC (rev 7527)
+++ SwiftApps/swift-galaxy/swift/swiftforeachlist.xml	2014-01-30 15:26:30 UTC (rev 7528)
@@ -1,4 +1,4 @@
-<tool id="swiftforeachlist" name="Run any executable over an item list via Swift foreach parallel construct">
+<tool id="swiftforeachlist" name="Swift-foreach-list">
   <description>A tool to run executable over an itemlist via Swift foreach parallel construct</description>
   
   <command interpreter="bash">

Modified: SwiftApps/swift-galaxy/swift/swiftforeachrange.xml
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachrange.xml	2014-01-30 01:14:51 UTC (rev 7527)
+++ SwiftApps/swift-galaxy/swift/swiftforeachrange.xml	2014-01-30 15:26:30 UTC (rev 7528)
@@ -1,4 +1,4 @@
-<tool id="swiftforeachrange" name="Run any executable over a range via Swift foreach parallel construct">
+<tool id="swiftforeachrange" name="Swift-foreach-range">
   <description>A generic tool to run executable via Swift foreach parallel construct</description>
   
   <command interpreter="bash">
@@ -51,6 +51,9 @@
   <outputs>
      <data format="txt" name="log_file" type="data" label="Swift output" />
   </outputs>
+  <code file="swiftforeachrangepp.py">
+    <hook postprocess="postprocess" />
+  </code>
   <help>
 .. class:: warningmark
 

Added: SwiftApps/swift-galaxy/swift/swiftforeachrangepp.py
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachrangepp.py	                        (rev 0)
+++ SwiftApps/swift-galaxy/swift/swiftforeachrangepp.py	2014-01-30 15:26:30 UTC (rev 7528)
@@ -0,0 +1,67 @@
+#post processing, set build for data and add additional data to history^M
+from galaxy import datatypes, config, jobs, tools
+from galaxy.model import HistoryDatasetAssociation
+import operator
+import shutil 
+import os
+import glob
+from lxml import etree
+from os.path import basename
+
+def createDsRef(outDataItems, param_dict, outputName, outputFormat, outputDsRefName, nameSpace):
+    dsrefXML="<?xml version=\"1.0\" ?>\n"
+    dsrefXML=dsrefXML+"<dataSetRefs xmlns=\"http://ci.uchicago.edu/galaxy-es/datasetrefs/"+nameSpace+"\" >\n"
+
+    dsrefFileName=""
+
+    for outDataName, outDataItem in outDataItems:
+        if outDataName==outputDsRefName:
+            dsrefFileName=outDataItem.get_file_name()
+        else:
+            if outDataName==outputName:
+                dsrefXML=dsrefXML+"<dataSetRef id=\"%s\" name=\"%s\" path=\"%s\" type=\"%s\"/>\n" % (outDataItem.id,outDataItem.name,outDataItem.get_file_name(),outputFormat)
+
+    print "dsrefFileName:"+dsrefFileName
+
+    primaryCollectedDatasets=param_dict["__collected_datasets__"]["primary"]
+
+    for primaryCollectedDataset in primaryCollectedDatasets:
+        primaryCollectedDatasetItems=primaryCollectedDatasets[primaryCollectedDataset]
+        for primaryCollectedDatasetItem in primaryCollectedDatasetItems:
+            outDataItem=primaryCollectedDatasetItems[primaryCollectedDatasetItem]
+            if outputFormat in outDataItem.extension:
+
+                dsrefXML=dsrefXML+"<dataSetRef id=\"%s\" name=\"%s\" path=\"%s\" type=\"%s\"/>\n" % (outDataItem.id,outDataItem.name,outDataItem.get_file_name(),outDataItem.extension)
+
+
+    dsrefXML=dsrefXML+"</dataSetRefs>\n"
+
+    return dsrefFileName, dsrefXML
+
+def writeDsRef(dsrefFileName, dsrefXML):
+    dsrefFile = open(dsrefFileName, "w",0)
+    dsrefFile.write(dsrefXML)
+    dsrefFile.flush()
+    dsrefFile.close()
+
+def setSizeAndPeak(outDataItems,outputDsRefName):
+    for outDataName, outDataItem in outDataItems:
+        if outDataName==outputDsRefName:
+            outDataItem.dataset.file_size=None
+            outDataItem.set_size()
+            outDataItem.set_peek()
+
+def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
+
+    outDataItems = out_data.items()
+    outDataItems = sorted(outDataItems, key=operator.itemgetter(0))
+
+    dsrefAcmoFileName, dsrefAcmoXML = createDsRef(outDataItems,param_dict,"acmo","acmo.csv","acmoDsRef","facit/acmo")
+
+    writeDsRef(dsrefAcmoFileName, dsrefAcmoXML)
+
+    setSizeAndPeak(outDataItems,"acmoDsRef")
+
+
+    app.model.context.flush()
+


Property changes on: SwiftApps/swift-galaxy/swift/swiftforeachrangepp.py
___________________________________________________________________
Added: svn:executable
   + *




More information about the Swift-commit mailing list