-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to output a new config file (#63)
Add write-config option to the runanalyzer. This provides an optimized configuration file. --------- Co-authored-by: Kevin Sayers <[email protected]> Co-authored-by: Mark Schreiber <[email protected]>
- Loading branch information
1 parent
40da936
commit e2a8286
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import textwrap | ||
|
||
def create_config(engine, task_resources, filename): | ||
if engine == 'NEXTFLOW': | ||
with open(filename, 'w') as out: | ||
for task in task_resources: | ||
task_string = textwrap.dedent(f""" | ||
withName: {task} {{ | ||
cpu = {task_resources[task]['cpus']} | ||
memory = {task_resources[task]['mem']} | ||
}} | ||
""") | ||
out.write(task_string) | ||
|
||
elif engine == 'CWL': | ||
raise ValueError("--write-config does not currently support CWL workflows") | ||
elif engine == 'WDL': | ||
raise ValueError("--write-config does not currently support WDL workflows") | ||
else: | ||
raise ValueError("Unknown workflow engine") | ||
|
||
def get_base_task(engine, task): | ||
# Returns the base task name | ||
if engine == 'NEXTFLOW': | ||
individual_task = task.split(" ")[0] | ||
return individual_task | ||
elif engine == 'CWL': | ||
return task | ||
elif engine == 'WDL': | ||
return task | ||
else: | ||
raise ValueError("Unknown workflow engine") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import unittest | ||
from omics.cli.run_analyzer import writeconfig | ||
|
||
class TestGetBaseTask(unittest.TestCase): | ||
def test_get_base_task_nextflow(self): | ||
result = writeconfig.get_base_task('NEXTFLOW', 'task1 (sample1)') | ||
self.assertEqual(result, 'task1') | ||
|
||
def test_get_base_task_cwl(self): | ||
result = writeconfig.get_base_task('CWL', 'task1 (sample1)') | ||
self.assertRaises(ValueError) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |