-
Notifications
You must be signed in to change notification settings - Fork 21
/
cwl_workunit.go
91 lines (68 loc) · 3.01 KB
/
cwl_workunit.go
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
package core
import (
"github.com/MG-RAST/AWE/lib/core/cwl"
//cwl_types "github.com/MG-RAST/AWE/lib/core/cwl/types"
//"github.com/davecgh/go-spew/spew"
"fmt"
)
type CWL_workunit struct {
Job_input *cwl.Job_document `bson:"job_input,omitempty" json:"job_input,omitempty" mapstructure:"job_input,omitempty"`
Job_input_filename string `bson:"job_input_filename,omitempty" json:"job_input_filename,omitempty" mapstructure:"job_input_filename,omitempty"`
CWL_tool *cwl.CommandLineTool `bson:"cwl_tool,omitempty" json:"cwl_tool,omitempty" mapstructure:"cwl_tool,omitempty"`
CWL_tool_filename string `bson:"cwl_tool_filename,omitempty" json:"cwl_tool_filename,omitempty" mapstructure:"cwl_tool_filename,omitempty"`
Outputs *cwl.Job_document `bson:"outputs,omitempty" json:"outputs,omitempty" mapstructure:"outputs,omitempty"`
OutputsExpected *[]cwl.WorkflowStepOutput `bson:"outputs_expected,omitempty" json:"outputs_expected,omitempty" mapstructure:"outputs_expected,omitempty"` // this is the subset of outputs that are needed by the workflow
Notice `bson:",inline" json:",inline" mapstructure:",squash"`
}
func NewCWL_workunit() *CWL_workunit {
return &CWL_workunit{
Job_input: nil,
CWL_tool: nil,
Outputs: nil, // formerly Tool_results
OutputsExpected: nil,
}
}
func NewCWL_workunit_from_interface(native interface{}) (workunit *CWL_workunit, err error) {
workunit = &CWL_workunit{}
switch native.(type) {
case map[string]interface{}:
native_map, ok := native.(map[string]interface{})
if !ok {
err = fmt.Errorf("(NewCWL_workunit_from_interface) type error")
return
}
job_input_generic, has_job_input_generic := native_map["job_input"]
if has_job_input_generic {
job_input, xerr := cwl.NewJob_documentFromNamedTypes(job_input_generic)
if xerr != nil {
err = fmt.Errorf("(NewCWL_workunit_from_interface) NewJob_document failed: %s", xerr.Error())
return
}
workunit.Job_input = job_input
}
workunit.Job_input_filename, _ = native_map["Job_input_filename"].(string)
workunit.CWL_tool_filename, _ = native_map["CWL_tool_filename"].(string)
outputs_expected_generic, has_outputs_expected := native_map["outputs_expected"]
if has_outputs_expected {
outputs_expected, xerr := cwl.NewWorkflowStepOutputArray(outputs_expected_generic)
if xerr != nil {
err = fmt.Errorf("(NewCWL_workunit_from_interface) NewWorkflowStepOutput failed: %s", xerr.Error())
return
}
workunit.OutputsExpected = &outputs_expected
}
cwl_tool_generic, has_cwl_tool_generic := native_map["cwl_tool"]
if has_cwl_tool_generic {
cwl_tool, xerr := cwl.NewCommandLineTool(cwl_tool_generic)
if xerr != nil {
err = fmt.Errorf("(NewCWL_workunit_from_interface) NewCommandLineTool failed: %s", xerr.Error())
return
}
workunit.CWL_tool = cwl_tool
}
default:
err = fmt.Errorf("(NewCWL_workunit_from_interface) wrong type, map expected")
return
}
return
}