@@ -12,7 +12,6 @@ def create_ro_crate(input_file: str, workflow_file: str, output_dir: str) -> Non
12
12
:param input_file: The input file provided by the Snakemake workflow (e.g., merged data file).
13
13
:param workflow_file: Reference to the Snakemake workflow.
14
14
:param output_dir: The output directory to store the RO-Crate metadata file.
15
- :return:
16
15
"""
17
16
crate = ROCrate ()
18
17
@@ -23,18 +22,54 @@ def create_ro_crate(input_file: str, workflow_file: str, output_dir: str) -> Non
23
22
)
24
23
25
24
# Add authors:
26
- alice = crate .add (
25
+ auth_1 = crate .add (
27
26
Person (
28
27
crate ,
29
28
"https://orcid.org/0000-0000-0000-0000" ,
30
- properties = {"name" : "Alice Doe" , "affiliation" : "University of Flatland" },
29
+ properties = {
30
+ "name" : "Alexander Hambley" ,
31
+ "affiliation" : "University of Manchester" ,
32
+ },
33
+ )
34
+ )
35
+ auth_2 = crate .add (
36
+ Person (
37
+ crate ,
38
+ "https://orcid.org/0000-0002-0035-6475" ,
39
+ properties = {
40
+ "name" : "Eli Chadwick" ,
41
+ "affiliation" : "University of Manchester" ,
42
+ },
43
+ )
44
+ )
45
+ auth_3 = crate .add (
46
+ Person (
47
+ crate ,
48
+ "https://orcid.org/0000-0002-4565-9760" ,
49
+ properties = {
50
+ "name" : "Oliver Woolland" ,
51
+ "affiliation" : "University of Manchester" ,
52
+ },
31
53
)
32
54
)
33
- bob = crate .add (
55
+ auth_4 = crate .add (
34
56
Person (
35
57
crate ,
36
- "https://orcid.org/0000-0000-0000-0001" ,
37
- properties = {"name" : "Bob Doe" , "affiliation" : "University of Flatland" },
58
+ "https://orcid.org/0000-0001-9842-9718" ,
59
+ properties = {
60
+ "name" : "Stian Soiland-Reyes" ,
61
+ "affiliation" : "University of Manchester" ,
62
+ },
63
+ )
64
+ )
65
+ auth_5 = crate .add (
66
+ Person (
67
+ crate ,
68
+ "https://orcid.org/0000-0001-6353-0808" ,
69
+ properties = {
70
+ "name" : "Volodymyr Savchenko" ,
71
+ "affiliation" : "University of Geneva" ,
72
+ },
38
73
)
39
74
)
40
75
@@ -52,12 +87,23 @@ def create_ro_crate(input_file: str, workflow_file: str, output_dir: str) -> Non
52
87
properties = {
53
88
"@type" : "File" ,
54
89
"name" : "Dockerfile" ,
55
- "encodingFormat" : "application/yaml " ,
90
+ "encodingFormat" : "text/plain " ,
56
91
"description" : "The Dockerfile used to build the Docker images for the workflow." ,
57
92
"conformsTo" : {"@id" : "https://docs.docker.com/reference/dockerfile/" },
58
93
},
59
94
)
60
95
96
+ created_files = crate .add_file (
97
+ "./created_files.json" ,
98
+ properties = {
99
+ "@type" : "File" ,
100
+ "name" : "created_files.json" ,
101
+ "encodingFormat" : "application/json" ,
102
+ "description" : "A JSON file containing the list of files sourced by the workflow." ,
103
+ "conformsTo" : {"@id" : "https://docs.docker.com/reference/dockerfile/" },
104
+ },
105
+ )
106
+
61
107
crate .add_file ("./poetry.lock" )
62
108
crate .add_file ("./README.md" )
63
109
@@ -68,42 +114,32 @@ def create_ro_crate(input_file: str, workflow_file: str, output_dir: str) -> Non
68
114
"name" : "Merged Data File" ,
69
115
"description" : "This file contains merged RDF triples from multiple RO-Crates sourced from WorkflowHub." ,
70
116
"encodingFormat" : "text/turtle" ,
71
- "author" : [alice ["@id" ], bob ["@id" ]],
72
117
},
73
118
)
74
119
120
+ data_entity ["author" ] = [auth_1 , auth_2 , auth_3 , auth_4 , auth_5 ]
121
+ data_entity ["isBasedOn" ] = created_files
122
+
75
123
workflow_entity = crate .add_workflow (
76
124
source = workflow_file ,
77
125
properties = {
78
126
"name" : "Snakemake Workflow" ,
79
127
"description" : "This is the Snakemake workflow used to generate the merged RDF triples." ,
80
- "author" : [alice ["@id" ], bob ["@id" ]],
81
- "output" : data_entity ["@id" ],
82
128
},
83
129
main = True ,
84
130
lang = "snakemake" ,
85
131
)
86
132
133
+ workflow_entity ["author" ] = [auth_1 , auth_2 , auth_3 , auth_4 ]
134
+ workflow_entity ["output" ] = data_entity
135
+
87
136
if "conformsTo" not in crate .root_dataset :
88
137
crate .root_dataset .append_to (
89
138
"conformsTo" , {"@id" : "https://w3id.org/ro/wfrun/workflow/0.5" }
90
139
)
91
140
92
- crate .add (
93
- ContextEntity (
94
- crate ,
95
- identifier = str (uuid .uuid4 ()),
96
- properties = {
97
- "@type" : "CreateAction" ,
98
- "name" : "Merge RDF Triples" ,
99
- "description" : "Merging RDF triples from sourced crates." ,
100
- "agent" : [alice ["@id" ], bob ["@id" ]],
101
- "endTime" : datetime .now ().time ().isoformat (),
102
- "instrument" : workflow_entity ["@id" ],
103
- "result" : data_entity ["@id" ],
104
- },
105
- )
106
- )
141
+ # Add license:
142
+ crate .license = "https://opensource.org/license/bsd-2-clause"
107
143
108
144
# Writing the RO-Crate metadata:
109
145
crate .write (output_dir )
0 commit comments