-
Notifications
You must be signed in to change notification settings - Fork 3
/
update.groovy
93 lines (86 loc) · 3.53 KB
/
update.groovy
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
// Copyright (C) 2020-2023 Egon Willighagen
// License: MIT
// import groovy.xml.XmlSlurper
import groovy.json.JsonSlurper
templateFile = "template.md"
licenseNames = [
"http://creativecommons.org/publicdomain/zero/1.0/" : "CC0"
]
tools = [
"PV33" : [
"name" : "PathVisio 3.3",
"website" : "https://github.com/PathVisio/pathvisio/releases/tag/v3.3.0"
],
"BioC" : [
"name" : "BridgeDbR",
"website" : "https://bioconductor.org/packages/release/bioc/html/BridgeDbR.html"
],
"WS": [
"name" : "BridgeDb Webservice",
"website" : "https://github.com/bridgedb/BridgeDbWebservice"
]
]
def createBioSchemas(file, type) {
content = "<script type=\"application/ld+json\">{"
content += "\"@context\": \"https://schema.org/\","
content += "\"@type\": \"Dataset\","
content += "\"http://purl.org/dc/terms/conformsTo\": { \"@type\": \"CreativeWork\", \"@id\": \"https://bioschemas.org/profiles/Dataset/1.0-RELEASE\" },"
content += "\"name\": \"${file.file}\","
commonName = file.common != null ? ", " + file.common : ""
extra = type.toLowerCase() == "species" ? " for genes and proteins" : " (species independent)"
content += "\"description\": \"BridgeDb identifier mapping file for ${file[type.toLowerCase()]}${extra}\","
content += "\"@id\": \"https://bridgedb.github.io/data/gene_database/${file.doi}/${file.file}\","
content += "\"identifier\": \"${file.doi}/${file.file}\","
extra = type.toLowerCase() == "species" ? file[type.toLowerCase()] + ", gene, protein" : type.toLowerCase()
if (file.license) content += "\"license\": \"${file.license}\","
content += "\"keywords\": \"BridgeDb, mapping file, identifier, ELIXIR RIR, ${extra}${commonName}\","
content += "\"url\": \"https://doi.org/${file.doi}\","
content += "\"distribution\": [ { \"@type\": \"DataDownload\", \"name\": \"$file.file\", \"contentURL\": \"${file.downloadURL}\" } ],"
content += "\"isAccessibleForFree\": true"
content += "}</script> "
return content
}
lines = new File(templateFile).readLines()
lines.each { String line ->
if (line.startsWith("<files>")) {
def instruction = new XmlSlurper().parseText(line)
def input = instruction.text()
def jsonSlurper = new JsonSlurper()
fileContents = new File(input).text
def data = jsonSlurper.parseText(fileContents)
println "| ${data.type} | BridgeDb Download | QC report | Size | License | Date | Tested with"
println "|-------|--------|---------|"
for (file in data.mappingFiles) {
print "| "
print createBioSchemas(file, data.type)
print "${file[data.type.toLowerCase()]} "
typeID = file[data.type.toLowerCase()+"ID"]
print (typeID ? "(<a href=\"https://bioregistry.io/${typeID}\">${typeID}</a>) " : " ")
print "| [${file.file}](${file.downloadURL}) (doi:[${file.doi}](https://doi.org/${file.doi})) "
print "| " + (file.QCreport ? "[QC](${file.QCreport})" : "")
print "| " + (file.size ? file.size : "")
licenseStr = ""
if (file.license) {
licenseStr = "[" +
(licenseNames[file.license] ?
licenseNames[file.license] :
"license") +
"](" + file.license + ") "
}
print "| ${licenseStr}"
dateStr = ""
if (file.date) dateStr = file.date
print "| ${dateStr} "
testedWithStr = ""
if (file.tested) {
for (tool in file.tested) {
testedWithStr += "<a href=\"${tools[tool].website}\">" + tools[tool].name + "</a> "
}
}
print "| ${testedWithStr}"
println "|"
}
} else {
println line
}
}