generated from Sage-Bionetworks-Challenges/model-to-data-challenge-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscore.cwl
95 lines (84 loc) · 2.54 KB
/
score.cwl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env cwl-runner
#
# Example score submission file
#
cwlVersion: v1.0
class: CommandLineTool
baseCommand: python
hints:
DockerRequirement:
dockerPull: python:3.8.8-slim-buster
inputs:
- id: input_file
type: File
- id: goldstandard
type: File
- id: check_validation_finished
type: boolean?
arguments:
- valueFrom: score.py
- valueFrom: $(inputs.input_file.path)
prefix: -f
- valueFrom: $(inputs.goldstandard.path)
prefix: -g
- valueFrom: results.json
prefix: -r
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: score.py
entry: |
#!/usr/bin/env python
import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--submissionfile", required=True, help="Submission File")
parser.add_argument("-r", "--results", required=True, help="Scoring results")
parser.add_argument("-g", "--goldstandard", required=True, help="Goldstandard for scoring")
args = parser.parse_args()
score = 3
prediction_file_status = "SCORED"
# secondary_metric and secondary_metric_value are optional
result = {'primary_metric': 'auc',
'primary_metric_value': 0.8,
'secondary_metric': 'aupr',
'secondary_metric_value': 0.2,
'submission_status': prediction_file_status}
with open(args.results, 'w') as o:
o.write(json.dumps(result))
outputs:
- id: results
type: File
outputBinding:
glob: results.json
- id: primary_metric
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['primary_metric'])
- id: primary_metric_value
type: double
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['primary_metric_value'])
- id: secondary_metric
type: string?
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['secondary_metric'])
- id: secondary_metric_value
type: double?
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['secondary_metric_value'])
- id: status
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['submission_status'])