![]() |
| Endocannabinoids. |
This is why I am interested in Wikidata, as I can mint entries there myself (see this ICCS 2018 poster). And so I did, but when adding a chemical class, you want to specific compounds from that class too. That's where LIPID MAPS comes in, because that had info on specific compounds in that class.the trigger was this new @WikiPathways by @stinahanspers: "Thermogenesis (Homo sapiens)" https://t.co/5u8ksZnYAc#endocannabinoidSaturday pic.twitter.com/TajtfgUDzk— Egon Willighⓐgen (@egonwillighagen) June 30, 2018
Some time ago I asked about adding more LIPID MAPS identifiers to Wikidata, which has a lot of benefits for the community and LIPID MAPS. I was informed I could use their REST API to get mappings between InChIKey and their identifiers, and that is enough for me to add more of their identifiers to Wikidata (similar approach I used for the EPA CompTox Dashboard and SPLASHes). The advantages include that LIPID MAPS now can easily get data to add links to the PDB and MassBank to their lipid database (and much more).
My advantage is that I can easily query if a particular compound is a specific endocannabinoids. I created two Bioclipse scripts, and one looks like:
// ask permission to use data from their REST API (I did and got it)
restAPI = "http://www.lipidmaps.org/rest/compound/lm_id/LM/all/download"
propID = "P2063"
allData = bioclipse.downloadAsFile(
restAPI, "/LipidMaps/lipidmaps.txt"
)
sparql = """
PREFIX wdt:
SELECT (substr(str(?compound),32) as ?wd) ?key ?lmid WHERE {
?compound wdt:P235 ?key .
MINUS { ?compound wdt:${propID} ?lmid . }
}
"""
if (bioclipse.isOnline()) {
results = rdf.sparqlRemote(
"https://query.wikidata.org/sparql", sparql
)
}
def renewFile(file) {
if (ui.fileExists(file)) ui.remove(file)
ui.newFile(file)
return file
}
mappingsFile = "/LipidMaps/mappings.txt"
missingCompoundFile = "/LipidMaps/missing.txt"
// ignore certain Wikidata items, where I don't want the LIPID MAPS ID added
ignores = new java.util.HashSet();
// ignores.add("Q37111097")
// make a map
map = new HashMap()
for (i=1;i<=results.rowCount;i++) {
rowVals = results.getRow(i)
map.put(rowVals[1], rowVals[0])
}
batchSize = 500
batchCounter = 0
mappingContent = ""
missingContent = ""
print "Saved a batch"
renewFile(mappingsFile)
renewFile(missingCompoundFile)
new File(bioclipse.fullPath("/LipidMaps/lipidmaps.txt")).eachLine{ line ->
fields = line.split("\t")
if (fields.length > 15) {
lmid = fields[1]
inchikey = fields[15]
if (inchikey != null && inchikey.length() > 10) {
batchCounter++
if (map.containsKey(inchikey)) {
wdid = map.get(inchikey)
if (!ignores.contains(wdid)) {
mappingContent += "${wdid}\t${propID}\t\"${lmid}\"\tS143\tQ20968889\tS854\t\"http://www.lipidmaps.org/rest/compound/lm_id/LM/all/download\"\tS813\t+2018-06-30T00:00:00Z/11\n"
}
} else {
missingContent += "${inchikey}\n"
}
}
}
if (batchCounter >= batchSize) {
ui.append(mappingsFile, mappingContent)
ui.append(missingCompoundFile, missingContent)
batchCounter = 0
mappingContent = ""
missingContent = ""
print "."
}
}
println "\n"
With that, I managed to increase the number of LIPID MAPS identifiers from 2333 to 6099, but there are an additional 38 thousand lipids not yet in Wikidata.
ok, we had 2333 @lipidmaps identifiers in @wikidata this morning... the current count is 6099 :) https://t.co/3T5YvB788O #endocannabinoidSaturday— Egon Willighⓐgen (@egonwillighagen) June 30, 2018
Many more details can be found in my notebook, but in the end I ended up with a nice Scholia page for endocannabinoids :)
ten hours later (well, I have been doing other stuff too...) we have endocannabinoids as chemical class in @wikidata :) And here in #Scholia: https://t.co/6jCbDoz1tN— Egon Willighⓐgen (@egonwillighagen) June 30, 2018
How better to start summer? #endocannabinoidSaturday
I hope you enjoyed this #opennotebook too :) pic.twitter.com/tqcw4MIWEq

No comments:
Post a Comment