Mercurial > repos > galaxyp > fragpipe
annotate generate_workflow.py @ 9:1455d3e7f191 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
| author | galaxyp |
|---|---|
| date | Fri, 16 Jan 2026 09:34:00 +0000 |
| parents | |
| children |
| rev | line source |
|---|---|
|
9
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
2 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
3 # |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
4 # Generates a FragPipe Workflow file. |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
5 # |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
6 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
7 import pathlib |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
8 import sys |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
9 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
10 default_workflow = sys.argv[1] |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
11 user_params_filename = sys.argv[2] |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
12 output_workflow_filename = sys.argv[3] |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
13 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
14 # Default workflow as packaged in the Galaxy $__tool_directory__ |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
15 default_workflow_path = pathlib.Path(__file__).resolve().parent.joinpath(f'workflows/{default_workflow}.workflow') |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
16 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
17 # Collect comments separately from parameters |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
18 comments = [] |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
19 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
20 # Dictionary with workflow parameters |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
21 wfdict = {} |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
22 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
23 # Initialize workflow dictionary with defaults |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
24 with open(default_workflow_path, 'r') as inf: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
25 for line in inf: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
26 if line.startswith('#'): |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
27 comments.append(line) |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
28 elif line.strip() != '': |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
29 kv = line.strip().split('=') |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
30 if len(kv) < 2: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
31 kv.append('') |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
32 wfdict[kv[0]] = '='.join(kv[1:]) |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
33 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
34 # Overwrite with user parameters from Galaxy |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
35 with open(user_params_filename, 'r') as inf: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
36 for line in inf: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
37 if line.strip() != '': |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
38 kv = line.strip().split('=') |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
39 if len(kv) < 2: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
40 kv.append('') |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
41 wfdict[kv[0]] = '='.join(kv[1:]) |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
42 |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
43 # Output comments and parameter definitions to workflow file |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
44 with open(output_workflow_filename, 'w') as outf: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
45 for comment in comments: |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
46 print(comment, file=outf) |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
47 for k in sorted(wfdict.keys()): |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
48 kv = f'{k}={wfdict[k]}' |
|
1455d3e7f191
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit 02d7c1a0439315c2868c0e66d74fd567e89cca02
galaxyp
parents:
diff
changeset
|
49 print(kv, file=outf) |
