forked from thomasstjerne/mgnify-to-dwc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
eml.js
127 lines (112 loc) · 3.77 KB
/
eml.js
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
const institutionMap = require('./institutionEnum')
const _ = require('lodash')
const createEML = (study, pipeline, publications) => {
const institution = institutionMap[study["centre-name"]] || {organizationName: study["centre-name"], address: {city: "", deliveryPoint: "", postalCode: ""}, phone: ""};
return `<eml:eml xmlns:eml="eml://ecoinformatics.org/eml-2.1.1"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="eml://ecoinformatics.org/eml-2.1.1 http://rs.gbif.org/schema/eml-gbif-profile/1.1/eml.xsd"
packageId="84d26682-f762-11e1-a439-00145eb45e9a/v9.3" system="http://gbif.org" scope="system"
xml:lang="en">
<dataset>
<title xml:lang="en">${_.escape(study["study-name"])}</title>
<creator>
<organizationName>${institution.organizationName}</organizationName>
<address>
<deliveryPoint>${institution.address.deliveryPoint}</deliveryPoint>
<city>${institution.address.city}</city>
<postalCode>${institution.address.postalCode}</postalCode>
<country>${institution.address.country}</country>
</address>
<phone>${institution.phone}</phone>
</creator>
<metadataProvider>
<organizationName>${institution.organizationName}</organizationName>
<address>
<deliveryPoint>${institution.address.deliveryPoint}</deliveryPoint>
<city>${institution.address.city}</city>
<postalCode>${institution.address.postalCode}</postalCode>
<country>${institution.address.country}</country>
</address>
<phone>${institution.phone}</phone>
</metadataProvider>
<pubDate>
${study["last-update"]}
</pubDate>
<language>en</language>
<abstract>
<para>${_.escape(study["study-abstract"])}</para>
</abstract>
<keywordSet>
<keyword>Metagenomics</keyword>
<keyword>environmental genomics</keyword>
<keywordThesaurus>N/A</keywordThesaurus>
</keywordSet>
<intellectualRights>
<para>This work is licensed under a <ulink url="http://creativecommons.org/licenses/by/4.0/legalcode"><citetitle>Creative Commons Attribution Non Commercial (CC-BY) 4.0 License</citetitle></ulink>.</para>
</intellectualRights>
<distribution scope="document">
<online>
<url function="information">https://www.ebi.ac.uk/metagenomics/studies/${
study.accession
}</url>
</online>
</distribution>
<maintenance>
<description>
<para></para>
</description>
<maintenanceUpdateFrequency>unkown</maintenanceUpdateFrequency>
</maintenance>
<contact>
<organizationName>${institution.organizationName}</organizationName>
<address>
<deliveryPoint>${institution.address.deliveryPoint}</deliveryPoint>
<city>${institution.address.city}</city>
<postalCode>${institution.address.postalCode}</postalCode>
<country>${institution.address.country}</country>
</address>
<phone>${institution.phone}</phone>
</contact>
<methods>
<methodStep>
<description>
<para>Pipeline used: https://www.ebi.ac.uk/metagenomics/pipelines/${pipeline}</para>
</description>
</methodStep>
<sampling>
<samplingDescription>
<para>
${_.escape(study["study-abstract"])}
</para>
</samplingDescription>
</sampling>
</methods>
<project >
<title>${_.escape(study["study-name"])}</title>
</project>
</dataset>
<additionalMetadata>
<metadata>
<gbif>
${createBibliography(publications)}
</gbif>
</metadata>
</additionalMetadata>
</eml:eml>`;
};
const createBibliography = publications => {
return `<bibliography>
${publications.map(({ attributes }) => createCitation(attributes)).join(' ')}
</bibliography>`;
};
const createCitation = publication => {
return `<citation identifier="DOI:${publication.doi}">${publication.authors} ${
publication["published-year"]
}. ${publication["pub-title"]} ${publication["iso-journal"]} vol. ${
publication.volume
}</citation>`;
};
module.exports = {
createEML:createEML
}