Skip to content

Commit 93ac0b8

Browse files
committed
updating_cwlworkflows
1 parent 02692e2 commit 93ac0b8

File tree

6 files changed

+164
-72
lines changed

6 files changed

+164
-72
lines changed

configuration/analysis/BBBC001.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ group_by: c
1010
map_directory: false
1111
features: ALL
1212
file_extension: pandas
13-
13+
background_correction: false

configuration/analysis/BBBC039.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ df_pattern: "x\\(00-15\\)_y\\(01-24\\)_p0\\(1-9\\)_c{c:d}_darkfield.ome.tif"
99
group_by: c
1010
map_directory: false
1111
features: "ALL_INTENSITY"
12-
file_extension: pandas
12+
file_extension: pandas
13+
background_correction: false

cwl_adapters/BbbcDownload.cwl

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.2
3+
inputs:
4+
name:
5+
inputBinding:
6+
prefix: --name
7+
type: string
8+
outDir:
9+
inputBinding:
10+
prefix: --outDir
11+
type: Directory
12+
outputs:
13+
outDir:
14+
outputBinding:
15+
glob: $(inputs.outDir.basename)
16+
type: Directory
17+
requirements:
18+
DockerRequirement:
19+
dockerPull: polusai/bbbc-download-plugin:0.1.0-dev1
20+
EnvVarRequirement:
21+
envDef:
22+
HOME: /home/polusai
23+
InitialWorkDirRequirement:
24+
listing:
25+
- entry: $(inputs.outDir)
26+
writable: true
27+
InlineJavascriptRequirement: {}
28+
NetworkAccess:
29+
networkAccess: true

cwl_adapters/FileRenaming.cwl

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.2
3+
inputs:
4+
filePattern:
5+
inputBinding:
6+
prefix: --filePattern
7+
type: string
8+
inpDir:
9+
inputBinding:
10+
prefix: --inpDir
11+
type: Directory
12+
mapDirectory:
13+
inputBinding:
14+
prefix: --mapDirectory
15+
type: boolean?
16+
outDir:
17+
inputBinding:
18+
prefix: --outDir
19+
type: Directory
20+
outFilePattern:
21+
inputBinding:
22+
prefix: --outFilePattern
23+
type: string
24+
outputs:
25+
outDir:
26+
outputBinding:
27+
glob: $(inputs.outDir.basename)
28+
type: Directory
29+
requirements:
30+
DockerRequirement:
31+
dockerPull: polusai/file-renaming-tool:0.2.4-dev1
32+
EnvVarRequirement:
33+
envDef:
34+
HOME: /home/polusai
35+
InitialWorkDirRequirement:
36+
listing:
37+
- entry: $(inputs.outDir)
38+
writable: true
39+
InlineJavascriptRequirement: {}
40+
NetworkAccess:
41+
networkAccess: true

pyproject.toml

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ python = ">=3.9,<3.12"
1111
typer = "^0.9.0"
1212
pyyaml = "^6.0.1"
1313
pydantic = "^2.6.1"
14-
cwl-utils="0.31"
15-
toil="^5.12"
1614
polus-plugins = {path = "../image-tools", develop = true}
1715
workflow-inference-compiler = {path = "../workflow-inference-compiler", develop = true}
1816

workflows/cwl_nuclear_segmentation.py

+91-68
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def create_step(self, url: str) -> api.Step:
123123
cwl_tool = pp.get_plugin(self._camel(manifest.name), plugin_version).save_cwl(
124124
self.cwl_path.joinpath(f"{self._camel(manifest.name)}.cwl")
125125
)
126-
step = api.Step(cwl_tool)
127-
return step
126+
# step = api.Step(cwl_tool)
127+
return cwl_tool
128128

129129
def manifest_urls(self, x: str) -> str:
130130
"""URLs on GitHub for plugin manifests"""
@@ -162,84 +162,107 @@ def workflow(self) -> None:
162162
"""
163163
A CWL nuclear segmentation pipeline.
164164
"""
165-
# BBBCDownload
165+
# # BBBCDownload
166166
bbbc = self.create_step(self.manifest_urls("bbbc_download"))
167-
bbbc.name = self.name
168-
bbbc.outDir = Path("bbbc.outDir")
167+
# bbbc.name = self.name
168+
# bbbc.outDir = Path("bbbc.outDir")
169169

170-
# Renaming plugin
170+
# # Renaming plugin
171171
rename = self.create_step(self.manifest_urls("file_renaming"))
172+
# rename.filePattern = self.file_pattern
173+
# rename.outFilePattern = self.out_file_pattern
174+
# rename.mapDirectory = self.map_directory
175+
# rename.inpDir = bbbc.outDir
176+
# rename.outDir = Path("rename.outDir")
177+
178+
self.modify_cwl()
179+
180+
181+
# # OMEConverter
182+
# ome_converter = self.create_step(self.manifest_urls("ome_converter"))
183+
# ome_converter.filePattern = self._string_after_period(self.out_file_pattern)
184+
# ome_converter.fileExtension = ".ome.tif"
185+
# ome_converter.inpDir = rename.outDir
186+
# ome_converter.outDir = Path("ome_converter.outDir")
187+
188+
# # Estimate Flatfield
189+
# estimate_flatfield = self.create_step(self.manifest_urls("estimate_flatfield"))
190+
# estimate_flatfield.inpDir = ome_converter.outDir
191+
# estimate_flatfield.filePattern = self.image_pattern
192+
# estimate_flatfield.groupBy = self.group_by
193+
# estimate_flatfield.getDarkfield = True
194+
# estimate_flatfield.outDir = Path("estimate_flatfield.outDir")
195+
196+
# # # Apply Flatfield
197+
# apply_flatfield = self.create_step(self.manifest_urls("apply_flatfield"))
198+
# apply_flatfield.imgDir = ome_converter.outDir
199+
# apply_flatfield.imgPattern = self.image_pattern
200+
# apply_flatfield.ffDir = estimate_flatfield.outDir
201+
# apply_flatfield.ffPattern = self.ff_pattern
202+
# apply_flatfield.dfPattern = self.df_pattern
203+
# apply_flatfield.outDir = Path("apply_flatfield.outDir")
204+
# apply_flatfield.dataType = True
205+
206+
# ## Kaggle Nuclei Segmentation
207+
# kaggle_nuclei_segmentation = self.create_step(
208+
# self.manifest_urls("kaggle_nuclei_segmentation")
209+
# )
210+
# kaggle_nuclei_segmentation.inpDir = apply_flatfield.outDir
211+
212+
# kaggle_nuclei_segmentation.filePattern = self.image_pattern
213+
# kaggle_nuclei_segmentation.outDir = Path("kaggle_nuclei_segmentation.outDir")
214+
215+
# ## FTL Label Plugin
216+
# ftl_plugin = self.create_step(self.manifest_urls("ftl_plugin"))
217+
# ftl_plugin.inpDir = kaggle_nuclei_segmentation.outDir
218+
# ftl_plugin.connectivity = 1
219+
# ftl_plugin.binarizationThreshold = 0.5
220+
# ftl_plugin.outDir = Path("ftl_plugin.outDir")
221+
222+
# logger.info("Initiating CWL Nuclear Segmentation Workflow!!!")
223+
# steps = [
224+
# bbbc,
225+
# # rename,
226+
# # ome_converter,
227+
# # estimate_flatfield,
228+
# # apply_flatfield,
229+
# # kaggle_nuclei_segmentation,
230+
# # ftl_plugin
231+
# ]
232+
bbbc = api.Step(clt_path='/Users/abbasih2/Documents/Job/Axle_Work/image-workflows/cwl_adapters/BbbcDownload.cwl')
233+
# We can inline the inputs to each step individually.
234+
bbbc.name = 'BBBC001'
235+
bbbc.outDir = Path('bbbc.outDir')
236+
237+
238+
rename = api.Step(clt_path='/Users/abbasih2/Documents/Job/Axle_Work/image-workflows/cwl_adapters/FileRenaming.cwl')
172239
rename.filePattern = self.file_pattern
173240
rename.outFilePattern = self.out_file_pattern
174241
rename.mapDirectory = self.map_directory
175242
rename.inpDir = bbbc.outDir
176243
rename.outDir = Path("rename.outDir")
177244

178-
179-
# OMEConverter
180-
ome_converter = self.create_step(self.manifest_urls("ome_converter"))
181-
ome_converter.filePattern = self._string_after_period(self.out_file_pattern)
182-
ome_converter.fileExtension = ".ome.tif"
183-
ome_converter.inpDir = rename.outDir
184-
ome_converter.outDir = Path("ome_converter.outDir")
185-
186-
# Estimate Flatfield
187-
estimate_flatfield = self.create_step(self.manifest_urls("estimate_flatfield"))
188-
estimate_flatfield.inpDir = ome_converter.outDir
189-
estimate_flatfield.filePattern = self.image_pattern
190-
estimate_flatfield.groupBy = self.group_by
191-
estimate_flatfield.getDarkfield = True
192-
estimate_flatfield.outDir = Path("estimate_flatfield.outDir")
193-
194-
# # Apply Flatfield
195-
apply_flatfield = self.create_step(self.manifest_urls("apply_flatfield"))
196-
apply_flatfield.imgDir = ome_converter.outDir
197-
apply_flatfield.imgPattern = self.image_pattern
198-
apply_flatfield.ffDir = estimate_flatfield.outDir
199-
apply_flatfield.ffPattern = self.ff_pattern
200-
apply_flatfield.dfPattern = self.df_pattern
201-
apply_flatfield.outDir = Path("apply_flatfield.outDir")
202-
apply_flatfield.dataType = True
203-
204-
## Kaggle Nuclei Segmentation
205-
kaggle_nuclei_segmentation = self.create_step(
206-
self.manifest_urls("kaggle_nuclei_segmentation")
207-
)
208-
kaggle_nuclei_segmentation.inpDir = apply_flatfield.outDir
209-
210-
kaggle_nuclei_segmentation.filePattern = self.image_pattern
211-
kaggle_nuclei_segmentation.outDir = Path("kaggle_nuclei_segmentation.outDir")
212-
213-
## FTL Label Plugin
214-
ftl_plugin = self.create_step(self.manifest_urls("ftl_plugin"))
215-
ftl_plugin.inpDir = kaggle_nuclei_segmentation.outDir
216-
ftl_plugin.connectivity = 1
217-
ftl_plugin.binarizationThreshold = 0.5
218-
ftl_plugin.outDir = Path("ftl_plugin.outDir")
219-
220-
logger.info("Initiating CWL Nuclear Segmentation Workflow!!!")
221245
steps = [
222246
bbbc,
223-
rename,
224-
ome_converter,
225-
estimate_flatfield,
226-
apply_flatfield,
227-
kaggle_nuclei_segmentation,
228-
ftl_plugin
247+
rename
229248
]
230249

231-
workflow = api.Workflow(steps, "experiment", self.workflow_path)
250+
workflow = api.Workflow([], "experiment")
251+
for step in steps:
252+
workflow.append(step)
232253
# # Saving CLT for plugins
233-
workflow._save_all_cwl(overwrite=True)
234-
# # Adding environmental variables for bbbc_download and ome_converter plugin
235-
self.modify_cwl()
236-
# # # Save yaml to run CWL tool
237-
workflow._save_yaml()
238-
# Compile and run using WIC python API
239-
workflow.compile(run_local=True, overwrite=False)
240-
# # print(workflow.yml_path)
241-
# # clean autognerated directories
242-
self._clean()
243-
self._move_outputs()
244-
logger.info("Completed CWL nuclear segmentation workflow.")
254+
# workflow._save_all_cwl()
255+
# # # Adding environmental variables for bbbc_download and ome_converter plugin
256+
# self.modify_cwl()
257+
258+
# # # # Save yaml to run CWL tool
259+
workflow.write_ast_to_disk(directory=Path('/Users/abbasih2/Documents/Job/Axle_Work/image-workflows/outputs'))
260+
# workflow.compile(write_to_disk=True)
261+
# # Compile and run using WIC python API
262+
# workflow.compile(run_local=True, overwrite=False)
263+
workflow.run()
264+
# # # clean autognerated directories
265+
# self._clean()
266+
# self._move_outputs()
267+
# logger.info("Completed CWL nuclear segmentation workflow.")
245268
return

0 commit comments

Comments
 (0)