From aff77ff59785eec8abe942493be6a9bd7cf2041b Mon Sep 17 00:00:00 2001
From: Dominik Brilhaus <brilhaus@nfdi4plants.org>
Date: Fri, 8 Nov 2024 11:31:24 +0100
Subject: [PATCH] add cwl

---
 runs/heatmap-run/job.yml       |  4 ++++
 workflows/heatmap/heatmap.py   | 21 +++++++++++++++++++++
 workflows/heatmap/workflow.cwl | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 runs/heatmap-run/job.yml
 create mode 100644 workflows/heatmap/heatmap.py
 create mode 100644 workflows/heatmap/workflow.cwl

diff --git a/runs/heatmap-run/job.yml b/runs/heatmap-run/job.yml
new file mode 100644
index 0000000..0117e64
--- /dev/null
+++ b/runs/heatmap-run/job.yml
@@ -0,0 +1,4 @@
+MeasurementTableCSV:
+    class: File
+    path: ../../assays/SugarMeasurement/dataset/sugar_result.csv
+FigureFileName: heatmap
\ No newline at end of file
diff --git a/workflows/heatmap/heatmap.py b/workflows/heatmap/heatmap.py
new file mode 100644
index 0000000..79efcbd
--- /dev/null
+++ b/workflows/heatmap/heatmap.py
@@ -0,0 +1,21 @@
+import pandas as pd
+import plotly.express as px
+import sys
+
+# Read command line arguments
+MeasurementTableCSV=sys.argv[0]
+FigureFileName=sys.argv[1]
+
+# Read the CSV file
+data = pd.read_csv(MeasurementTableCSV, index_col=0)
+
+# Create a heatmap
+fig = px.imshow(data, 
+                labels=dict(x="Columns", y="Rows", color="Value"),
+                x=data.columns, 
+                y=data.index)
+
+# Save heatmap to file
+fig.write_image(FigureFileName + ".svg")
+
+
diff --git a/workflows/heatmap/workflow.cwl b/workflows/heatmap/workflow.cwl
new file mode 100644
index 0000000..f080070
--- /dev/null
+++ b/workflows/heatmap/workflow.cwl
@@ -0,0 +1,32 @@
+#!/usr/bin/env cwl-runner
+
+cwlVersion: v1.2
+class: CommandLineTool
+# hints:
+#   DockerRequirement:
+#     dockerPull: 
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entryname: heatmap.py
+        entry:
+          $include: heatmap.py
+  - class: NetworkAccess
+    networkAccess: true
+baseCommand: [python, heatmap.py]
+inputs:
+  MeasurementTableCSV:
+    type: File
+    inputBinding:
+      position: 1
+  FigureFileName:
+    type: string
+    inputBinding:
+      position: 2
+
+outputs:
+  output:
+    type: File
+    outputBinding:
+      glob: "*.svg"
+
-- 
GitLab