-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_datacite.py
257 lines (238 loc) · 10.1 KB
/
gen_datacite.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/usr/bin/env python
import json
from collections import OrderedDict
namespace = 'datacite:'
# Defined in:
# https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf # noqa
DATACITE_TITLE_TYPES = ['AlternativeTitle', 'Subtitle', 'TranslatedTitle',
'Other']
DATACITE_RESOURCE_TYPES = ['Audiovisual', 'Collection', 'DataPaper', 'Dataset',
'Event', 'Image', 'InteractiveResource', 'Model',
'PhysicalObject', 'Service', 'Software', 'Sound',
'Text', 'Workflow', 'Other']
DATACITE_CONTRIBUTOR_TYPES = ['ContactPerson', 'DataCollector', 'DataCurator',
'DataManager', 'Distributor', 'Editor',
'HostingInstitution', 'Producer',
'ProjectLeader', 'ProjectManager',
'ProjectMember', 'RegistrationAgency',
'RegistrationAuthority', 'RelatedPerson',
'Researcher', 'ResearchGroup', 'RightsHolder',
'Sponsor', 'Supervisor', 'WorkPackageLeader',
'Other']
DATACITE_DATE_TYPES = ['Accepted', 'Available', 'Copyrighted', 'Collected',
'Created', 'Issued', 'Submitted', 'Updated', 'Valid',
'Other']
DATACITE_RELATED_IDENTIFIER_TYPES = [
'ARK', 'arXiv', 'bibcode', 'DOI', 'EAN13', 'EISSN', 'Handle', 'IGSN',
'ISBN', 'ISSN', 'ISTC', 'LISSN', 'LSID', 'PMID', 'PURL', 'UPC', 'URL',
'URN']
DATACITE_RELATED_IDENTIFIER_RELATION_TYPES = [
'IsCitedBy', 'Cites', 'IsSupplementTo', 'IsSupplementedBy',
'IsContinuedBy', 'Continues', 'IsDescribed by', 'Describes', 'HasMetadata',
'IsMetadataFor', 'HasVersion', 'IsVersionOf', 'IsNewVersionOf',
'IsPreviousVersionOf', 'IsPartOf', 'HasPart', 'IsReferencedBy',
'References', 'IsDocumentedBy', 'Documents', 'IsCompiledBy', 'Compiles',
'IsVariantFormOf', 'IsOriginalFormOf', 'IsIdenticalTo', 'IsReviewedBy',
'Reviews', 'IsDerivedFrom', 'IsSourceOf', 'IsRequiredBy', 'Requires',
]
DATACITE_DESCRIPTION_TYPES = ['Abstract', 'Methods', 'SeriesInformation',
'TableOfContents', 'TechnicalInfo', 'Other']
# Based on the Datacite 4.1 Schema shown here:
# https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf # noqa
FIELD_GENERATORS = (
# Occurrences identifier: 1
(namespace + 'identifier', lambda x: {
namespace + 'identifier_type': 'DOI',
namespace + 'value': ''
}),
# Occurrences creator: 1-n
(namespace + 'creators', lambda x: [{
# Occurrences: 1
namespace + 'creator_name': {
namespace + 'value': name,
# Occurrences: 0-1
# Must be one of Organisational, Personal
namespace + 'name_type': 'Personal'
},
# # Occurrences: 0-1
# 'given_name': 'name',
# # Occurrences: 0-1
# 'family_name': 'name',
# # Occurrences: 0-n
# 'name_identifier': [{
# # Occurrences: 1
# 'name_identifier_scheme': 'foo',
# 'scheme_uri': 'bar'
# }],
# # Occurrences: 0-1
# 'affiliation': 'name',
} for name in ['Seo J', 'Ju YS', 'Lee W']
]),
# Occurrences: 0-n
(namespace + 'subjects', lambda x: [
{namespace + 'value': 'Homo sapiens'}
]),
# Occurrences: 1-n
(namespace + 'titles', lambda x: [{
namespace + 'value': 'The transcriptional landscape and mutational '
'profile of lung adenocarcinoma',
# Occurrences: 0-n
namespace + 'title_type': 'Subtitle',
}]),
# Occurrences: 1
(namespace + 'publisher', lambda x: {
namespace + 'value': 'MD Anderson Cancer Center',
}),
# Occurrences: 1
(namespace + 'publication_year', lambda x: {
namespace + 'value': '2012',
}),
# Occurrences: 1
(namespace + 'resource_type', lambda x: {
# Occurrences: 1
namespace + 'value': 'Dataset/GSM Samples',
# Occurrences: 1
namespace + 'resource_type_general': 'Dataset',
}),
# Occurrences: 0-n
# ('contributors', lambda x: [
# {
# # Occurrences: 1
# 'contributor_type': 'Other',
# # Occurrences: 1
# 'contributor_name': name,
# # # Occurrences: 0-1
# # 'nameType': 'foo',
# # # Occurrences: 0-1
# # 'familyName': 'foo',
# # # Occurrences: 0-1
# # 'given_name': 'foo',
# # # Occurrences: 0-1
# # 'name_identifier': {
# # # Occurrences: 1
# # 'name_identifier_scheme': 'foo',
# # # Occurrences: 0-1
# # 'scheme_uri': 'bar'
# # },
# # # Occurrences: 0-n Free Text
# # 'affiliation': [],
# } for name in ['Seo J', 'Ju YS', 'Lee W']
# ]),
# Occurrences: 0-n
(namespace + 'dates', lambda x: [
{
namespace + 'date_type': 'Submitted',
namespace + 'value': '2012-08-28'
},
{
namespace + 'date_type': 'Updated',
namespace + 'value': '2018-06-11'
},
{
namespace + 'date_type': 'Public',
namespace + 'value': '2012-09-06'
}
]
),
# Occurrences: 0-1
(namespace + 'language', lambda x: {
namespace + 'value': 'en'
}),
# Occurrences: 0-n
# ('alternate_identifiers', lambda x: [{
# Occurrences: 1
# 'alternateIdentifierType': 'foo',
# 'value': 'foo'
# } for n in range(NUM_ALTERNATE_IDENTIFIERS)),
# Occurrences: 0-n
# ('related_identifiers', lambda x: [{
# # Occurrences: 1
# 'related_identifier_type': 'DOI',
# # 'related_identifier_type':
# ranlist(DATACITE_RELATED_IDENTIFIER_TYPES)
# # Occurances: 1
# 'relation_type': ranlist(DATACITE_RELATED_IDENTIFIER_RELATION_TYPES),
# 'value': '{}.{}/foo-bar-doi-1.0'.format(
# random.randint(1, 10),
# random.randint(1000, 9000)
# )
# # # Occurrences: 0-1
# # 'relatedMetadataScheme': '',
# # # Occurrences: 0-1
# # 'schemeURI': '',
# # # Occurrences: 0-1
# # 'schemeType': '',
# } for n in range(NUM_RELATED_IDENTIFIERS)]),
# Occurrences: 0-n
# ('sizes', lambda x: [{
# 'value': '{} {}'.format(
# random.randint(1, 1000),
# ranlist(DEF_SIZE_TYPES)
# )
# } for n in range(NUM_SIZES)
# ]),
# Occurrences: 0-n
(namespace + 'formats', lambda x: [
namespace + 'SOFT', 'MINiML', 'TXT'
]),
# Occurrences: 0-1
# ('version', lambda x: {
# 'value': '1.0.0'
# }),
# Occurrences: 0-n
# ('rights', lambda x: {
# 'value': ranlist(['https://opensource.org/licenses/GPL-3.0']),
# # Occurrences: 0-1
# 'rights_uri': ranlist(['https://opensource.org/licenses/GPL-3.0'])
# }),
# Occurrences: 0-n
(namespace + 'descriptions', lambda x: {
namespace + 'value': 'Understanding the molecular signatures of cancer is '
'important to apply appropriate targeted therapies. Here we '
'present the first large scale RNA sequencing study of lung '
'adenocarcinoma demonstrating its power to identify somatic '
'point mutations as well as transcriptional variants such as '
'gene fusions, alternative splicing events and expression '
'outliers. Our results reveal the genetic basis of 200 lung '
'adenocarcinomas in Koreans including deep characterization '
'of 87 surgical specimens by transcriptome sequencing. We '
'identified driver somatic mutations in cancer genes '
'including EGFR, KRAS, NRAS, BRAF, PIK3CA, MET and CTNNB1. '
'New cancer genes, such as LMTK2, ARID1A, NOTCH2 and '
'SMARCA4, were also suggested as candidates for novel '
'drivers in lung adenocarcinoma. We found 45 fusion genes, '
'8 of which were chimeric tyrosine kinases involving ALK, '
'RET, ROS1, FGFR2, AXL and PDGFRA. Of 17 recurrent '
'alternative splicing events, we identified exon 14 skipping '
'in the proto-oncogene MET as highly likely to be a cancer '
'driver. The number of somatic mutations and expression '
'outliers varied markedly between individual cancers and '
'was strongly correlated with smoking history of cancer '
'patients. In addition, we identified genomic blocks where '
'genes were frequently up- or down-regulated together that '
'could be explained by copy number alterations in the cancer '
'tissue. We also found an association between lymph node '
'metastasis and somatic mutations in TP53. Our findings '
'broaden our understanding of lung adenocarcinoma and may '
'also lead to new diagnostic and therapeutic approaches.',
# We'll only use Abstract for this mock data for now
namespace + 'description_type': 'Abstract',
# 'description_type': ranlist(DATACITE_DESCRIPTION_TYPES)
}),
# ('geo_location', lambda x: {
# 'value': ''
# }),
)
def gen_datacite_entry():
"""Generate a Datacite Search entry."""
search_entry = OrderedDict()
for name, func in FIELD_GENERATORS:
search_entry[name] = func(search_entry)
return search_entry
def add_datacite_entries(dict):
"""Add Datacite Search entries."""
for name, func in FIELD_GENERATORS:
dict[name] = func(dict)
if __name__ == '__main__':
"""Pretty print generated data to console"""
print(json.dumps(gen_datacite_entry(), indent=4))