SPARQList/glyco

提供:TogoWiki

2019年4月23日 (火) 08:36時点におけるTk-tk (トーク | 投稿記録)による版
移動: 案内, 検索

SPARQLthon79 (4/23)

  • WURCSから、糖鎖構造のイメージのRDF化するバッチの開発。base64の文字列を、sparqletでエンドポイントにロード。(青木・新町)


# Insert Image RDF by image binary

## Comment

* Construct Image RDF by image binary
* **confirm insert results**
  - https://test.sparqlist.glycosmos.org/sparqlist/check_contents_graph
  - http://rdf.glytoucan.org/core/demo
  - http://glycosmos.org/batch/image/demo

## Parameters

* `hash`: hash key
  * default: a08a0d8f02650690ef66535c5d4df798e421a90591b666fc6ac11eb9e464868c
* `target_core_graph`: core graph of gtc
  * default: http://rdf.glytoucan.org/core/demo
* `target_image_graph`: image graph of gtc
  * default: http://rdf.glytoucan.org/image/demo
* `target_transform_graph`:  RDF graph
  * default: http://glycosmos.org/batch/image/demo
* `target_base`: target base uri of property
  * default: http://glycosmos.org/batch/Wurcs2Image
* `target_transform`: a name of converter
  * default: glycanbuilder
* `target_transform_version`: a version of converter
  * default: 1.0.4-SNAPSHOT
* `style`: image style (compact, normal, normalinfo)
  * default: normalinfo
* `notation`:symbol notation (cfg, cfg_bw, cfg_uoxf, uoxf, uoxf_color, iupac, snfg)
  * default: snfg
* `format`: image format (png, jpg, svg)
  * default: png
* `base64`: image base64
  * default: base64,iVBORw0KGgoAAAANSUhEUgAAAb4AAABSCAIAAACkHibzAAAFp0lEQVR42u3dv2sbZxzH8W8DaV1XbQ1pgwoKFvjayuFK1KKChkI93KDBLRpc6KBBDRo0aEhAgwmiOKDBgwMqaHDBAQfcoSCoKRoUYhA0lBQ0eNCg0UP+AA0aNHhwn7NSERr9PFm606P3i2fwIPBHuofP3T13J8kFAGBMwkcAAFQnAFCdAEB1AgDVCQBUJwCA6gQAqhMAqE4AoDoBgOoEAFCdAEB1AgDVCQBUJwBQnQAAqhMAqE4AoDoBgOoEAKoTAKhOAADVCQBUJwBQnQBAdQIA1QkAoDoBgOoEgFfOz88XpTprtV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FskcgY38XQGc2mkI1s85Vtctls1pXvAZn64fTW1pZ8/9FYjznGYjH1cYxyAjLSO+z/So9nS6XGeySObGSb32yOZTIZV759burV2Wq11CG93VCjHN9Vw5ubm/F4fPC9WlcyV+Yim5rNoxwLtFpCNrLNb7ZJJJPJYrGoYXV2torap0XUKcHgtcVHa4ZhqH3I0HtcR98eQ185F9kGr0OVy0I2ss11tgkvqPS8TqVDdXbXU9SbtH8o6sGqfU9l5470ath+lvx+QO3xTNMsl8sXbpiLbAcH9g/FdO5eVrv9el0KBSEb2RYn25vUqbpb358001/EVLuIUqmUSCTUXst+nkfE5/OFQqFUKlWpVEZ/oOqqTlLIRjayeSGbM81m0+/31+t1/avzykJPYbqQjWxkcyvbJO3pWgtdAACoTgCgOgGA6gQAqhMAqE4AANUJAFQnAFCdAEB1AgDVCQCgOgGA6gQAqhMAqE4AoDoBAFQnAFCdAEB1AgDVCQBUJwBQnQAAqhMAqE4AoDoBgOoEAKoTAEB1AsBV+xd1p+SzBITVgAAAAABJRU5ErkJggg==


## Endpoint

endpoint url

## `repo` insert user info

```sparql
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:	<http://www.w3.org/2001/XMLSchema#>
PREFIX glycan:	<http://purl.jp/bio/12/glyco/glycan#>
PREFIX repo: <http://repository.sparqlite.com/terms#>
PREFIX glytoucan:	<http://www.glytoucan.org/glyco/owl/glytoucan#>

INSERT {
  GRAPH <{{target_core_graph}}> {
    ?sacc_uri glycan:has_image  ?img_uri.
  }
  GRAPH <{{target_image_graph}}> {
    ?img_uri  a glycan:Image.
    ?img_uri  glycan:has_symbol_format <https://rdf.glycoinfo.org/symbol-format/{{symbol_format}}>.
  }
  GRAPH <{{target_transform_graph}}>{
    ?text_uri <{{target_base}}/{{target_transform}}/{{target_transform_version}}> ?img_uri.
  }
}
WHERE {
  # Construct img_uri/hash_uri
  VALUES ?base64 { "{{base64}}" }
  BIND(IRI(CONCAT("http://rdf.glycoinfo.org/image/", ?base64)) AS ?img_uri)
  VALUES ?key { "{{hash}}" }
  BIND(IRI(CONCAT("http://repository.sparqlite.com/key#", ?key)) AS ?text_uri)

  # sacc_uri
  ?text_uri ?property ?sacc_uri.
  ?sacc_uri a glycan:Saccharide.
}
```


## output
```javascript
({
  json({repo}) {
    let inserted = repo.results.bindings.map((row) => {
      let res = "";
      for(key1 in row){
        res = row[key1].value;
        console.log("key1: " + key1);
        console.log("row[key1].value: " + row[key1].value);
      }
      return res;
    });

    let result = {};
    let key2 = "result";
    for (let i of inserted) {
      result[String(key2)] = i;
    }
    return result;
  }
})


/mw/SPARQList/glyco」より作成