1

I can load the MonDO ontology into GraphDB Free 9 with the /rest/data/import/upload/{repositoryID}/url method with this body:

{
  "context": "http://purl.obolibrary.org/obo/mondo.owl",
  "data": "https://github.com/monarch-initiative/mondo/releases/download/current/mondo.owl",
  "format": "RDF/XML"
}

I can also load this via the Workbench, but not programatically: http://data.bioontology.org/ontologies/ICD9CM/submissions/17/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb

I set the format line to "Turtle" and I'm getting 202 responses, but the workbench doesn't show any import. It seems like some of the time I see error messages on the workbench's import page, but I don't understand what corrective action to take.

For example, if I intentionally import ICD9 via the workbench, with the wrong format (RDF/XML), then I see

RDF Parse Error: Content is not allowed in prolog. [line 2, column 1]

Mark Miller
  • 3,011
  • 1
  • 14
  • 34

3 Answers3

1
curl 'http://localhost:7200/rest/data/import/upload/w2/url' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"type":"url","name":"http://data.bioontology.org/ontologies/ICD9CM/submissions/17/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb","format":"text/turtle","data":"http://data.bioontology.org/ontologies/ICD9CM/submissions/17/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb","status":"NONE","message":"","context":"","replaceGraphs":[],"baseURI":null,"forceSerial":false,"timestamp":1534939094325,"parserSettings":{"preserveBNodeIds":false,"failOnUnknownDataTypes":false,"verifyDataTypeValues":false,"normalizeDataTypeValues":false,"failOnUnknownLanguageTags":false,"verifyLanguageTags":true,"normalizeLanguageTags":false,"verifyURISyntax":true,"verifyRelativeURIs":true,"stopOnError":true}}

GraphDB handles api key but you should provide file format in the way up or "format":"text/turtle". Hope this helps.

Sava Savov
  • 551
  • 2
  • 4
  • And also if in url part file format is known you should not write latter, GraphDB will recognize it. – Sava Savov Nov 29 '19 at 08:30
  • Can you provide a list of acceptable formats? I don't see them at http://graphdb.ontotext.com/free/devhub/workbench-rest-api/curl-commands.html. Can I trust https://www.iana.org/assignments/media-types/media-types.xhtml ? They don't list a type for `BRF` – Mark Miller Nov 29 '19 at 14:07
1

Thanks to Sava from Ontotext, I was able to construct this minimal curl command that successfully loads the ICD9CM Turtle file from the NCBO BioPortal.

curl -d \
'{"type":"url","format":"text/turtle","data":"http://data.bioontology.org/ontologies/ICD9CM/submissions/17/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb","context":"http://data.bioontology.org/ontologies/ICD9CM/"}' \
-H 'Content-Type: application/json;charset=UTF-8' \
-X POST http://localhost:7200/rest/data/import/upload/disease_diagnosis_dev/url
  • I left out many of the keys, including the timestamp and all of the parserSettings.
  • I used the - d ... -X POST curl style instead of the --data-binary style

I don't claim to know all of the consequences of those decisions.

Here's my approach in R

library(httr)
post.endpoint <- "http://localhost:7200//rest/data/import/upload/disease_diagnosis_dev/url"
update.body <- '{
  "type":"url",
  "format":"text/turtle",
  "context": "http://purl.bioontology.org/ontology/ICD9CM/",
  "data": "http://data.bioontology.org/ontologies/ICD9CM/submissions/17/download?apikey=9cf735c3-a44a-404f-8b2f-c49d48b2b8b2"
}'

post.result <- POST(post.endpoint,
                    body = update.body,
                    content_type("application/json"))

Mark Miller
  • 3,011
  • 1
  • 14
  • 34
0
curl 'http://localhost:7200/rest/data/import/upload/abc/url' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"type":"url","name":"http://www.w3.org/TR/owl-guide/wine.rdf","format":"","data":"http://www.w3.org/TR/owl-guide/wine.rdf","status":"NONE","message":"","context":"","replaceGraphs":[],"baseURI":null,"forceSerial":false,"timestamp":1534939094325,"parserSettings":{"preserveBNodeIds":false,"failOnUnknownDataTypes":false,"verifyDataTypeValues":false,"normalizeDataTypeValues":false,"failOnUnknownLanguageTags":false,"verifyLanguageTags":true,"normalizeLanguageTags":false,"verifyURISyntax":true,"verifyRelativeURIs":true,"stopOnError":true}}'

where,

  • abc - is the repository id
  • http://www.w3.org/TR/owl-guide/wine.rdf - is the URL to import
  • 1534939094325 - the current timestamp in seconds since epoch (in bash, equivalent to date +%s)

If you want to perform regular updates I advise you to put each file in its own graph (using the "context":"<file's url>") and then replace it with "replaceGraphs":"<file's url>". The database will create a delta and update only the changed statements.

TallTed
  • 9,069
  • 2
  • 22
  • 37
Sava Savov
  • 551
  • 2
  • 4
  • Can you provide a list of acceptable formats? I don't see them at http://graphdb.ontotext.com/free/devhub/workbench-rest-api/curl-commands.html – Mark Miller Nov 28 '19 at 16:36
  • The supported RDF formats are: 'ttl', 'rdf', 'rj', 'n3', 'nt', 'nq', 'trig', 'trix', 'brf', 'owl', 'jsonld', as well as their .gz versions and .zip archives. – Sava Savov Dec 02 '19 at 07:43
  • Thanks, I really appreciate all of your responses. Are you saying that I should pass "ttl" as the "format" argument, not "text/turtle"? I really want to see a list of the arguments that can be passed to that parameter. Is it in the documentation anywhere? The list you provided above looks like auto-recognized filename extensions. – Mark Miller Dec 02 '19 at 14:54