-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.cwl
66 lines (58 loc) · 1.79 KB
/
validate.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
#!/usr/bin/env cwl-runner
#
# Example validate submission file
#
cwlVersion: v1.0
class: CommandLineTool
baseCommand: python
inputs:
- id: inputfile
type: File
arguments:
- valueFrom: validate.py
- valueFrom: $(inputs.inputfile)
prefix: -s
- valueFrom: results.json
prefix: -r
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: validate.py
entry: |
#!/usr/bin/env python
import synapseclient
import argparse
import os
import json
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--submissionFile", required=True, help="Submission File")
parser.add_argument("-r", "--results", required=True, help="validation results")
args = parser.parse_args()
with open(args.submissionFile,"r") as subFile:
message = subFile.read()
invalidReasons = []
predictionFileStatus = "VALIDATED"
if not message.startswith("test"):
invalidReasons.append("Submission must have test column")
predictionFileStatus = "INVALID"
result = {'predictionFileErrors':"\n".join(invalidReasons),'predictionFileStatus':predictionFileStatus}
with open(args.results, 'w') as o:
o.write(json.dumps(result))
outputs:
- id: results
type: File
outputBinding:
glob: results.json
- id: status
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['predictionFileStatus'])
- id: invalidReasons
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['predictionFileErrors'])