Semantic-JSON: a lightweight application program interface for accessing the Semantic Web (SciNeS open specifications)

Semantic-JSON Specification and Tutorial (version 1.2)

Meta-information

ID URN:RIKEN:cria160s1ria160s5i
URI http://scinets.org/item/cria160s1ria160s5i
Date last modified 2011-11-17
Images

A link to the RIKEN press release entitled 'Web interface defines new paradigm for life science data sharing' is here.

A link to the SciNetS virtual laboratory cloud centre is here.

Reference:
N. Kobayashi, M. Ishii,S. Takahashi, Y. Mochizuki, A. Matsushima, and T. Toyoda,
Semantic-JSON: a lightweight web service interface for Semantic Web contents integrating multiple life science databases,
Nucl. Acids Res. (2011) 39 (suppl 2): W533-W540. doi: 10.1093/nar/gkr353

Semantic-JSON Specification and Tutorial

Norio KOBAYASHI, Manabu ISHII and Tetsuro TOYODA,
Bioinformatics And Systems Engineering division (BASE), RIKEN.

30 Dec 2009 (version 1.0; the original version)
26 Mar 2010 (version 1.1)
26 Dec 2010 (version 1.2; the latest version)
Creative Commons License

  1. Introduction
  2. Introductory trials of Semantic-JSON
  3. Design of Semantic-JSON
  4. Architecture of Semantic-JSON Server
  5. SciNetS Data Structure
  6. Semantic-JSON URI
  7. Sample Programs
  8. Applications

1. Introduction

Life sciences data integration is important in bioinformatics for achieving a comprehensive understanding of life phenomena. The Semantic Web is a technology that accomplishes data integration over heterogeneous datasets distributed on the Web. On the Semantic Web, each data item is identified by a globally unique identifier, i.e. a URI, and a relationship between two data items is described as a statement including a triple of subject, predicate and object. These data items are typically described in a standardised format called resource description framework (RDF); a standardised query language called SPARQL is used to query the RDF data. Since the combination of RDF and SPARQL requires expensive computer resources, it is difficult to effectively retrieve such data items in various computer languages, including scripting languages popularly used by bioinformaticians.

Semantic-JSON is an approach that provides light-weight access to Semantic Web data without having to download RDF files and perform queries using SPARQL. More concretely, Semantic-JSON employs an integrated single-domain data repository, which is generated by collecting multiple-domain data on the Semantic Web. It provides a Representational State Transfer (REST) Web service that retrieves Semantic Web data described in the light-weight JavaScript Object Notation (JSON) format. Because JSON is supported by most popular programming languages, the service interface is defined independently in a programming language used for implementation. As a single-domain Semantic Web data repository, we employed Scientists' Network System (SciNetS), which is a framework for developing and integrating databases by collaboration among scientists on the Web, and implemented a Semantic-JSON server interface.

In this document, we will discuss the design of Semantic-JSON and illustrate the manner in which a user handles Semantic Web data via Semantic-JSON, using sample programs written in several languages.




2. Introductory Trials of Semantic-JSON

  1. Sample Semantic-JSON command to obtain the English name (title) of the top page of SciNetS web site identified by ID rib158i in JSON format
    http://semantic-json.org/json/name/en/rib158i

  2. Sample Semantic-JSON command to obtain the statements (descriptions of semantic relationships comprising a subject, a predicate and an object) whose subjects are "Protocol of SHIRPA test in RIKEN" identified by ID cria93s1ria93s1i in JSON format
    http://semantic-json.org/json/statements/cria93s1ria93s1i

  3. Sample Semantic-JSON command to search data record in taxonomy having keyword "arabidopsis"
    http://semantic-json.org/json/searchInstances/crib166u26i?keyword=arabidopsis

  4. Sample JavaScript program to obtain the English name (title) of the top page of SciNetS web site (cf. Section 7.2)
        View sample code    Execute sample code

  5. Sample JavaScript program to process genome sequences (cf. Section 7.3)
        View sample code    Execute sample code

  6. Ontology tree viewer for Plant Ontology (PO) generated by Semantic-JSON (cf. Section 8.1)
    http://scinets.org/sw/wiki/en/cria130u7131i


3. Design of Semantic-JSON

The core component of Semantic-JSON is an integrated single-domain data repository (Figure 3.1).



Figure 3.1.  Concept of Semantic-JSON.  This figure shows a path of a semantic inference that starts from a data item in Domain 1 and ends at a data item in Domain n.  During semantic inference, a user gains access to a Semantic-JSON repository by invoking Semantic-JSON URIs, consisting of an internal ID and a command name, along with step-by-step receipt of a fragment of Semantic Web data in the JSON format.


The dataset on the repository is generated by collecting distributed multiple-domain Semantic Web data on the Web. Each collected data item is simultaneously labelled by an internal ID, and a mapping between its global URI and the internal URI is managed as linked open data (LOD) on the repository. Each element of the RDF statement (subject, property and object or triple) is labelled by an internal ID and is accessed by a global URI called Semantic-JSON URI, consisting of its internal ID and a command name. Semantic-JSON defines a set of commands that obtain a small but relevant fragment of Semantic Web data, including data items and linked data described in the JSON format. This mechanism allows users to traverse Semantic Web data using internal IDs by invoking Semantic-JSON URIs step-by-step in their favourite programming languages instead of traversing a huge distributed Semantic Web data, and to obtain external URIs of the corresponding internal IDs when necessary. The Semantic-JSON URIs and the set of commands must be standardised when multiple Semantic-JSON repositories are launched on the Web and when users want to use them. These standardisation issues will be discussed in the section Semantic-JSON URI. In the following sections, we discuss the implementation issues of Semantic-JSON.

4. Architecture of Semantic-JSON Server

  Semantic-JSON is a Web-based application of the server-client model, as shown in Figure 4.1.


Figure 4.1. Architecture of Semantic-JSON.

A Semantic-JSON client is an HTTP or HTTPS client, such as a user program or a Web browser.
The Semantic-JSON server is developed as a  REST Web service provider implementing the Semantic-JSON interface. It provides a service that performs clients' requests supported by SciNetS, a Semantic Web data repository framework.
First, a client sends a URI as a data request to the Semantic-JSON server. The URI denotes a function that processes Semantic Web datasets defined in the Semantic-JSON specification. Then the Semantic-JSON server evaluates the client's URI, obtains Semantic Web data accurately from SciNetS and converts these data into the JSON format in the same order. Finally, the JSON data is returned to the client as the response.


5. SciNetS Data Structure

Semantic-JSON supports not only the standardised Semantic Web data structures, including Web ontology language (OWL) and RDF, but also the SciNetS data structure, which is defined as an extension of OWL and RDF. In this section, we view the SciNetS data structure as a preparation for further discussion on the Semantic-JSON specification.
SciNetS is designed for developing an integrated collection of life sciences databases and is accessible from a Web browser for data browsing and editing by humans as well as programs. The SciNetS data structure includes not only the page, folder, property and link corresponding to an RDF individual (or instance), OWL class, RDF property and RDF statement, respectively, but also a disk denoted as an OWL class, which provides an individually separated virtual data space for researchers collaborating in the editing and sharing of confidential data. To adapt those data types to a practical life sciences database framework, pre-defined properties for each data type are given and used together with OWL/RDF properties to describe a data item. A user is also able to describe a relationship among data items as a link (quad of link URI, subject, predicate and object, equivalent to an RDF statement) in an OWL-Full manner by defining a user's original or standardised ontology.


Figure 5.1. A snapshot of SciNetS accessed by a Web browser (Firefox 4). This panel shows the disk 'RIKEN SciNetS' (URI: http://scinets.org/item/rib158i). Its Wiki page is displayed in (A), and its folders in (B). (C) is a link to the Semantic-JSON web site.

5.1. Disk

A disk is a data space virtually separated from others and forms an individual dataset. An owner is assigned to each disk. The owner manages the collaboration among database editors (scientists) and data access controls. Pre-defined properties for a disk include uri, name, wiki, image, icon, file and license (cf. Section 5.5).


Figure 5.2. Semantic Web data structure of a disk on SciNetS.

5.2. Folder

A folder is defined as an extension of an OWL class that forms a set of pages corresponding to RDF individuals. The pre-defined properties for a folder include uri, name, wiki, image, icon, dna, rna, peptide, protein, compound, file and license (cf. Section 5.5).


Figure 5.3. Semantic Web data structure of a folder on SciNetS.

5.3. Page

A page is defined as an RDF individual extended with the following pre-defined properties: uri, name, wiki, image, icon, dna, rna, peptide, protein, compound, file and license (cf. Section 5.5).


Figure 5.4. Semantic Web data structure of a page on SciNetS.

5.4. Property

A property in SciNetS is equivalent to a property in OWL. A property itself is described with pre-defined properties including uri, name, wiki, image, icon, file and license (cf. Section 5.5).

Figure 5.5. Semantic Web data structure of a property on SciNetS.

5.5. Pre-defined Properties

The pre-defined properties listed above are uri, name, wiki, image, icon, dna, rna, peptide, protein, compound, file and license. The details of these properties are described below.

5.5.1. Property uri

[domain]:
disk, folder, page and property
[range]:
xsd:String (URI of the data item)
[semantics]:
this specifies the global URI of the corresponding data item.

5.5.2. Property name

[domain]:
disk, folder, page and property
[range]:
xsd:String
[semantics]:
this specifies a name of the corresponding data item. This is equivalent to property 'rdf:label' in RDF, and the value is written as an xsd:String literal with a language attribution. In SciNetS, currently English and Japanese are supported as a data description language.

5.5.3. Property wiki

[domain]:
disk, folder, page and property
[range]:
Wiki page (URI of the Wiki page)
[semantics]:
this specifies a Wiki page attached to the corresponding data item. A data item has, at the most, an English and a Japanese Wiki page. The Wiki page has a global URI and a user can browse it using a Web browser.

5.5.4. Properties image and icon

[domain]:
disk, folder, page and property
[range]:
File (URI of the file)
[semantics]:
this specifies an image file. Similar to a Wiki page, an image file has a global URI and it can be downloaded by specifying this URI as a URL. The difference between image and icon is just in their size: an image is the original one posted to SciNetS and an icon is its corresponding image resized to 100 x 100 pixels.

5.5.5. Properties dna, rna, peptide, protein and compound

[domain]:
folder and page
[range]:
File (URI of the file)
[semantics]:
a sequence file such as Fasta file of dna, rna, peptide and protein and a structure file such as Molfile file of compound can be attached to the corresponding folder or page. The files are named by global URIs, including one of those property names.

5.5.6. Property file

[domain]:
disk, folder, page and property
[range]:
File (URI of the file)
[semantics]:
specialized files described in Section 5.5.4 and 5.5.5, such as image and dna files, as well as arbitrary files can be attached to a data item. This property 'file' specifies the latter files by attaching a global URI.

5.5.7. Property license

[domain]:
disk, folder, page and property
[range]:
License (URI that identifies the license)
[semantics]:
this specifies a license attached to the corresponding data item. The license should be identified by global URI including Creative Commons licenses; such URI is used as the value of this property.

6. Semantic-JSON URI

A URI that specifies a Semantic-JSON function complies with the following syntactic structure:

ServerReference / json / Command / [ Language / ] InternalID [ ? Parameter ]

Language can be omitted when the command does not depend on it. Currently, the languages English (en) and Japanese (ja) are supported. Command is a data-processing command defined based on RDF, RDF schema and their extensions. InternalID is a locally unique identifier of a data item on a Semantic-JSON server located in ServerReferenceParameter is a list of parameters connected by '&' and is used for inernalID, dna, rna and search commands.

For instance, the URI to obtain the English name of the folder specified by URI http://scines.org/item/crib158s1i (internal ID: crib158s1i) managed in the Semantic-JSON server at http://semantic-json.org is written as follows:

http://semantic-json.org/json/name/en/crib158s1i

To perform a command specified as a URI, a user can access the server using the URI as a URL in an HTTP / HTTPS client program, such as a Web browser or a program. A sample operation of command 'name' using a Web browser is shown in Figure 6.1.


Figure 6.1. Sample operation on a Web browser that obtains the English name of the folder 'crib158s1i' in the JSON format.

The commands supported in the current implementation of SciNetS-JSON are listed in Tables 6.1 and 6.2. The commands listed in Table 6.1 are defined based on RDF and RDF schema, and those listed in Table 6.2 are defined as an extension of RDF and RDF schema for SciNetS. For each command, if the result is empty data, then its response is an empty JSON object {}, and if an error occurs on the server side, then its response is a JSON object {"Error":reason} comprising the key-value pair of the key 'Error'.

In the rest of this section, each command will be introduced together with sample operations.

Command Language InternalID Function
externalURI
arbitrary data item returns a external (original) URI of the given data item InternalID as a complete global URI
internalID
arbitrary data item returns an internal ID of the given data item. In this command, the data item is specified as Parameter.
uri
arbitrary data item returns a complete global URI of the given data item
label language code (e.g. en, ja) arbitrary data item returns the label of the given data item written in the specified language
comment language code (e.g. en, ja) arbitrary data item returns the comment of the given data item written in the specified language
seeAlso
arbitrary data item returns a list of internal IDs of the data items related to the given data item by the property 'rdfs:seeAlso' in RDF schema
isDefinedBy
arbitrary data item returns a list of internal IDs of the data items that define the given data item by the property 'rdfs:isDefinedBy' in RDF schema
instances
class returns a list of internal IDs of the instances belonging to the given class
classes
instance returns a list of internal IDs of the classes to which the given instance belongs
superClasses
class
returns a list of internal IDs of the superClasses (same as the property 'rdfs:subClsssOf' in RDF schema) of the given class
subClasses
class
returns a list of internal IDs of the subClasses (subClass is the reverse of superClass) of the given class
properties
class returns a list of internal IDs of the properties associated with the given class, namely the properties whose domain and/or range is the given class
superProperties
property returns a list of internal IDs of the superProperties (same as the property 'rdfs:subPropertyOf' in RDF schema) of the given property
subProperties
property returns a list of internal IDs of the subProperties (subProperty is the reverse of superProperty) of the given property
domain
property returns a list of internal IDs of the classes that are the domain of the given property (same as the property 'rdfs:domain' in RDF schema)
range
property returns a list of internal IDs of the classes and/or data types that are the range of the given property (same as the property 'rdfs:range' in RDF schema)
statements

class, instance returns a list of internal IDs of the triples whose subject is the given data item. If the resultant triples include URIs, it returns a list of triples with the URIs as quads.
reverseStatements
class, instance returns a list of the triples whose object is the given data item. If the resultant triples include URIs, it returns a list of triples with the URIs as quads.
type
class always returns 'rdfs:Class'
instance returns a list of internal IDs of the classes that belong to the given instance
file
instance returns file information, including file internal ID, file type and file size, associated with the given instance
searchClasses
nil
returns a list of internal IDs of the classes whose labels are hit by a given keyword
searchInstances
nil, class
returns a list of internal IDs of the instances whose labels are hit by a given keyword. When the InternalID is a classID, the resultant instances are limited to the ones associated with the class.
searchProperties
nil, class
returns a list of internal IDs of the properties whose labels are hit by a given keyword. When the InternalID is a classID, the resultant properties are limited to the ones associated with the class. 
searchLiteralStatements
nil, class, instance
returns a list of the triples whose objects are literals and are hit by a given keyword. If the resultant triples include URIs, it returns a list of triples with the URIs as quads.
Table 6.1. List of commands provided by Semantic-JSON. These commands are defined based on RDF and RDF schema, except for the commands highlighted in yellow and blue. The command 'file' highlighted in yellow is added for handling a data file associated with an instance. The command 'internalID' highlighted in red requires Parameter in the URI including the externalURI in decoded string format. Search commands highlighted in blue also require Parameter in the URI, including the keyword, such as http://semantic-json.org/searchClasses?keyword=SciNetS. The keyword can be written in the PosMed search query format (cf. http://omicspace.riken.jp/Help/index.html).

Command Language InternalID Function
name en, ja disk, folder, page, property, file returns the name of the given data item written in the specified language. If the data item is a folder or a page, this command is equivalent to the command 'label' listed in Table 6.1.
link
If the object of the given link is a data item, it returns the name of the data item, otherwise returns the literal value written in the specified language.
image
disk, folder, page, property returns the internal ID of the image file attached to the given data item
icon
disk, folder, page, property returns the internal ID of the icon file attached to the given data item
dna
folder, page returns the sequence in string format stored in the DNA sequence file attached to the given data item. If Parameter is provided, it returns a part of the DNA sequence.
rna
folder, page returns the sequence in string format stored in the RNA sequence file attached to the given data item. If Parameter is provided, it returns a part of the RNA sequence.
peptide
folder, page returns the sequence in string format stored in the peptide sequence file attached to the given data item
protein
folder, page returns the sequence in string format stored in the protein sequence file attached to the given data item
compound
folder, page returns the structure in string format stored in the compound structure file attached to the given data item
files
disk, folder, page, property returns a list of file information, including the file URI, file type and file size, attached to the given data item
fileTextString
file returns the content of the given file in text format
fileBase64String
file returns the content of the given file in base-64 format
links

folder, page returns a list of internal IDs of the links whose subjects are the given data item
reverseLinks
folder, page returns a list of internal IDs of the links whose objects are the given data item
subject
link
returns the internal ID of the subject data item of the link
property
link
returns the internal ID of the property of the link
object
link
returns the internal ID of the object data item of the link
wiki en, ja disk, folder, page, property returns the internal ID of the Wiki page of the given data item written in the specified language
pages
folder returns a list of internal IDs of the pages belonging to the given folder
folders
disk returns a list of internal IDs of the folders beloning to the given disk
page returns a list of internal IDs of the folders to which the given page belongs
superFolders
folder returns a list of internal IDs of the superFolders (same as the property 'rdfs:subClsssOf' in RDF schema) of the given folder
subFolders
folder
returns a list of internal IDs of the subFolders (subFolder is the reverse of superFonder) of the given folder
properties
folder returns a list of internal IDs of the properties associated with the given folder. This is equivalent to the command 'properties' called with an argument of class
disk returns a list of internal IDs of the properties defined in the given disk
superProperties
property returns a list of internal IDs of the superProperties (same as the property 'rdfs:subPropertyOf' in RDF schema) of the given property
subProperties
property returns a list of internal IDs of the subProperties (subProperty is the reverse of superProperty) of the given property
license
disk, folder, page, property, file returns the internal ID of the license attached to the given data item
searchDisks
nil
returns a list of internal IDs of the disks hit by a given keyword.
searchFolders
nil, disk returns a list of internal IDs of the folders hit by a given keyword. When an InternalID is a diskID, the resultant folders are limited to the ones associated with the disk.
searchPages
nil, disk, folder
returns a list of internal IDs of the pages hit by a given keyword. When an InternalID is a diskID or a folderID, the resultant pages are limited to the ones associated with the disk or folder, respectively.
searchProperties
nil, disk, folder
returns a list of internal IDs of the properties hit by a given keyword. When an InternalID is a diskID or a folderID, the resultant properties are limited to the ones associated with the disk or folder, respectively.
searchLiteralLinks
nil, disk, folder, page
returns a list of internal IDs of the links whose objects are literals and are hit by a given keyword
Table 6.2. List of commands provided by Semantic-JSON for SciNetS. Because SciNetS data is an extension of RDF and RDF schema, the commands listed in Table 6.1 are also available for SciNetS when folder and page are replaced with class and instance, respectively. For the commands 'dna' and 'rna' highlighted in green, Parameter is optionally given to obtain a part of the DNA or RNA sequence. Search commands highlighted in blue requires Parameter in the URI including keyword and keyword hit targets (wiki and file are options, and name is the default), such as http://semantic-json.org/searchPages?keyword=SciNetS&wiki=on&file=on. The keyword can be written in the PosMed search query format (cf. http://omicspace.riken.jp/Help/index.html).

6.1. Semantic-JSON commands for RDF and RDF schema

6.1.1. Command externalURI

[Language]:
unnecessary
[InternalID]:
an InternalID of a data item of arbitrary data type
[Function]:
returns an external (original) URI of the data item identified by the InternalID as a complete global URI
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'URI'
[Sample URI]:
http://semantic-json.org/json/externalURI/crib158s1i
[Sample response in JSON]:
{"URI":"http:\/\/semantic-json.org\/item\/crib158s1i"}

6.1.2. Command internalID

[Language]:
unnecessary
[InternalID]:
nil
[Parameter]:
an external URI of a data item of arbitrary data type
[Function]:
returns an internal ID of the data item given as Parameter
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'ID'
[Sample URI]:
http://semantic-json.org/json/internalID?http%3A%2F%2Fsemantic-json.org%2Fitem%2Fcrib158s1i
[Sample response in JSON]:
{"ID":"crib158s1i"}

6.1.3. Command uri

[Language]:
unnecessary
[InternalID]:
an InternalID of a data item of arbitrary data type
[Function]:
returns a complete global URI of the data item identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'URI'
[Sample URI]:
http://semantic-json.org/json/uri/crib158s1i
[Sample response in JSON]:
{"URI":"http:\/\/semantic-json.org\/item\/crib158s1i"}

6.1.4. Command label

[Language]:
language code (e.g. en (English) and ja (Japanese))
[InternalID]:
an InternalID of a data item of arbitrary data type
[Function]:
returns the label of the data item identified by the InternalID written in the specified language. That is, a literal object of the triple whose subject is the data item and the property is 'rdfs:label' in RDF schema is returned.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'label' and 'lang'
[Sample URI]:
http://semantic-json.org/json/label/en/crib158s1i
[Sample response in JSON]:
{"label":"Portal", "lang":"en"}

6.1.5. Command comment

[Language]:
language code (e.g. en (English) and ja (Japanese))
[InternalID]:
an InternalID of a data item of arbitrary data type
[Function]:
returns the comment of the data item identified by the InternalID written in the specified language. That is, a literal object of the triple whose subject is the data item and the property is 'rdfs:comment' in RDF schema is returned.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'comment' and 'lang'
[Sample URI]:
http://semantic-json.org/json/comment/en/crib158s1i
[Sample response in JSON]:
{"comment":"The top page of SciNetS", "lang":"en"}

6.1.6. Command seeAlso

[Language]:
unnecessary
[InternalID]:
an InternalID of a data item of arbitrary data type
[Function]:
returns all the related data items of the data item identified by the InternalID. That is, internal IDs of objects of the triples whose subjects are the given data item and the properties are 'rdfs:seeAlso' in RDF schema are returned.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/seeAlso/crib158s1i
[Sample response in JSON]:
{"list":[{"ID":"crib158s2i","dataType":"Class"}]}

6.1.7. Command isDefinedBy

[Language]:
unnecessary
[InternalID]:
an InternalID of a data item of arbitrary data type
[Function]:
returns the defining-related data items of the data item identified by the InternalID. That is, internal IDs of objects of the triples whose subjects are the data item and the properties are 'rdfs:isDefinedBy' in RDF schema are returned.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/isDefinedBy/crib158s1i
[Sample response in JSON]:
{"list":[{"ID":"crib158s3i","dataType":"Class"}]}

6.1.8. Command instances

[Language]:
unnecessary
[InternalID]:
an InternalID of a class
[Function]:
returns a list of internal IDs of the instances belonging to the class identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/instances/cria93s1i
[Sample response in JSON]:
{"list":[{"ID":"cria93s1ria93s1i","dataType":"Instance"},{"ID":"cria93s1ria93s2i","dataType":"Instance"}]}

6.1.9. Command classes

[Language]:
unnecessary
[InternalID]:
an InternalID of an instance
[Function]:
returns a list of internal IDs of the classes to which the instance identified by the InternalID belongs
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/classes/cria93s1ria93s1i
[Sample response in JSON]:
{"list":[{"ID":"cria93s1i","dataType":"Class"}]}

6.1.10. Command superClasses

[Language]:
unnecessary
[InternalID]:
an InternalID of a class
[Function]:
returns a list of internal IDs of the superClasses of the class identified by the InternalID. A superClass is equivalent to the classes described with the property 'rdfs:subClassOf' in RDF schema, i.e. the triple 'class rdfs:subClassOf superClass' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/superClasses/crib158s12i
[Sample response in JSON]:
{"list":[{"ID":"crib158s6i","dataType":"Class"}]}

6.1.11. Command subClasses

[Language]:
unnecessary
[InternalID]:
an InternalID of a class
[Function]:
returns a list of internal IDs of the subClasses of the class identified by the InternalID. A subClass is the reverse of a superClass, i.e. the triple 'subClass rdfs:subClassOf class' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/subClasses/crib158s6i
[Sample response in JSON]:
{"list":[{"ID":"crib158s12i","dataType":"Class"}]}

6.1.12. Command properties

[Language]:
unnecessary
[InternalID]:
an InternalID of a class
[Function]:
returns a list of internal IDs of the properies associated with the class identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/properties/cria93s1i
[Sample response in JSON]:
{"list":[{"ID":"prib23s91i","dataType":"Property"},...,{"ID":"pria93s9i","dataType":"Property"}]}

6.1.13. Command superProperties

[Language]:
unnecessary
[InternalID]:
an InternalID of a property
[Function]:
returns a list of internal IDs of the superProperties of the property identified by the InternalID. A superProperty is equivalent to the property described with property 'rdfs:subPropertyOf' in RDF schema, i.e. the triple 'property rdfs:subPropertyOf superProperty' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/superProperties/pria93s10i
[Sample response in JSON]:
{"list":{"ID":"pria93s8i","dataType":"Property"}}

6.1.14. Command subProperties

[Language]:
unnecessary
[InternalID]:
an InternalID of a property
[Function]:
returns a list of internal IDs of the subProperties of the property identified by the InternalID. A subProperty is the reverse of a superProperty, i.e. the triple 'subProperty rdfs:subPropertyOf property' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/subProperties/pria93s8i
[Sample response in JSON]:
{"list":{"ID":"pria93s10i","dataType":"Property"}}

6.1.15. Command domain

[Language]:
unnecessary
[InternalID]:
an InternalID of a property
[Function]:
returns a list of internal IDs of all the classes that are the domain of the property identified by the InternalID. That is, internal IDs of objects of the triples whose subjects are the property and the properties are 'rdfs:domain' in RDF schema such as the triple 'property rdfs:domain class' are returned.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/domain/pria93s1i
[Sample response in JSON]:
{"list":[{"ID":"rdfs:Class","dataType":"Class"}]}

6.1.16. Command range

[Language]:
unnecessary
[InternalID]:
an InternalID of a property
[function]:
returns a list of internal IDs of all the classes and/or the data types of the literals, which are the range of the property identified by the InternalID. That is, internal IDs of objects of the triples whose subjects are the property and the properties are 'rdfs:domain' in RDF schema, such as the triple 'property rdfs:range class' or the triple 'property rdfs:range dataType', are returned.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/range/pria93s8i
[Sample response in JSON]:
{"list":[{"ID":"crib23s319i","dataType":"Class"}]}

6.1.17. Command statements

[Language]:
unnecessary
[InternalID]:
an InternalID of a class or an instance
[Function]:
returns a list of the triples whose subjects are the data item identified by the InternalID. If the resultant triples have internal IDs, the result includes these internal IDs as quads.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID', 'subject', 'property', 'object' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/statements/cria93s1ria93s1i
[Sample response in JSON]:
{"list":[{"ID":"prib23s56rib23s36i","dataType":"Statement",...},...,{"ID":"pria93s12ria93s2i","dataType":"Statement",...}]}

6.1.18. Command reverseStatements

[Language]:
unnecessary
[InternalID]:
an InternalID of a class or an instance
[Function]:
returns a list of internal IDs of the triples whose objects are the data item identified by the InternalID. If the resultant triples have internal IDs, the result includes these internal IDs as quads.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID', 'subject', 'property', 'object' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/reverseStatements/cria197s9ria197s1i
[Sample response in JSON]:
{"list":[{"ID":"pria197s2ria197s1i","dataType":"Statement",...}]}

6.1.19-1. Command type

[Language]:
unnecessary
[InternalID]:
an InternalID of a class
[Function]:
always returns 'rdfs:Class'
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'type'
[Sample URI]:
http://semantic-json.org/json/type/crib158s1i
[Sample response in JSON]:
{"type":"rdfs:Class" }

6.1.19-2. Command type

[Language]:
unnecessary
[InternalID]:
an InternalID of an instance
[Function]:
returns a list of internal IDs of the classes to which the instance identified by the InternalID belongs
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'type'
[Sample URI]:
http://semantic-json.org/json/type/cria93s1ria93s2i
[Sample response in JSON]:
{"type":"cria93s1i" }

6.1.20. Command file

[Language]:
unnecessary
[InternalID]:
an InternalID of an instance
[Function]:
returns file information, including the internal ID, file type and file size associated with the instance identified by the InternalID.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID', 'fileType', 'fileSize' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/file/cria197s3ria197s1i~files~Oxt.fasta
[Sample response in JSON]:
{"ID":"cria197s3ria197s1i~files~Oxt.fasta", "fileType":"chemical\/seq-aa-fasta","fileSize":933, "dataType":"File"}

6.1.21. Command searchClasses

[Language]:
unnecessary
[InternalID]:
nil
[Parameter]:
keyword
[Function]:
returns a list of internal IDs of the classes whose labels include a keyword given as the term Parameter of the Semantic-JSON URI
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchClasses?keyword=SciNetS
[Sample response in JSON]:
{"list":[{"ID":"cria309s5i", "dataType":"Class"},...,{"ID":"crib158s2i", "dataType":"Class"}]}

6.1.22. Command searchInstances

[Language]:
unnecessary
[InternalID]:
nil or an InternalID of a class
[Parameter]:
keyword
[Function]:
returns a list of internal IDs of the instances whose labels include a keyword given as the term Parameter of the Semantic-JSON URI. When a classID is given as an InternalID, the resultant instances are limited to the ones associated with the class.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchInstances/cria61u5i?keyword=arabidopsis
[Sample response in JSON]:
{"list":[{"ID":"cria61u5ria61u2006020100i", "dataType":"Instance"},...,{"ID":"cria61u5ria61u2002260100i", "dataType":"Instance"}]}

6.1.23. Command searchProperties

[Language]:
unnecessary
[InternalID]:
nil or an InternalID of a class
[Parameter]:
keyword
[Function]:
returns a list of internal IDs of the properties whose labels include a keyword given as the term Parameter of the Semantic-JSON URI. When a classID is given as an InternalID, the resultant properties are limited to the ones associated with the class.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchProperties/cria35u3i?keyword=language
[Sample response in JSON]:
{"list":[{"ID":"pria35u14i", "dataType":"Property"}]}

6.1.24. Command searchLiteralStatements

[Language]:
unnecessary
[InternalID]:
nil or an InternalID of a class or an instance
[Parameter]:
keyword
[Function]:
returns a list of triples, whose literal objects include a keyword given as the term Parameter of the Semantic-JSON URI. When a classID or an instanceID is given as an InternalID, the resultant triples are limited to the ones whose subjects are the class or the instance, respectively. If the resultant triples have internal IDs, the result includes these internal IDs as quads.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID', 'subject', 'property', 'object' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchLiteralStatements/crib151s2i?keyword=semantic
[Sample response in JSON]:
{"list":[{"subject":"crib151s2rib151s132i", "property":"prib164s17i", "object":{"literalDataType":"xsd:String", "value":"The RIKEN integrated database of mammals ...", "lang":"en"}", dataType":"Statement"}]}


6.2. Semantic-JSON commands for SciNetS

6.2.1-1. Command name

[Language]:
en (English) or ja (Japanese)
[InternalID]:
an InternalID of a disk, folder, page, property or file
[Function]:
returns the name of the data item identified by the InternalID written in the specified language
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'name' and 'lang'
[Sample URI]:
http://semantic-json.org/json/name/en/crib158s1i
[Sample response in JSON]:
{"name":"Portal", "lang":"en"}

6.2.1-2. Command name

[Language]:
en (English) or ja (Japanese)
[InternalID]:
an InternalID of a link
[Function]:
(1) returns the name of the data item, if the object of the link identified by the InternalID is a data item; (2) otherwise, returns the literal value written in the specified language.
[Response in JSON]:
(1) A JSON object comprising the key-value pairs of the keys 'name' and 'lang'; or (2) a JSON object comprising the key-value pairs of the keys 'literalDataType', 'value' and 'lang'
[Sample URI (1)]:
http://semantic-json.org/json/name/en/prib139u3rib139s32i
[Sample response in JSON (1)]:
{"lang":"en","name":"Adviser"}
[Sample URI (2)]:
http://semantic-json.org/json/name/en/prib139s1rib139s3i
[Sample response in JSON (2)]:
{"lang":"en","literalDataType":"xsd:string","value":"Advanced Industrial Science"}

6.2.2. Command image

[Language]:
unnecessary
[InternalID]:
an InternalID of a disk, folder, page or property
[Function]:
returns an internal ID of the image file attached to the data item identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/image/crib158s1i
[Sample response in JSON]:
{"ID":"/sw/image/crib158s1","dataType":"Image"}

6.2.3. Command icon

[Language]:
unnecessary
[InternalID]:
an InternalID of a disk, folder, page or property
[function]:
returns an internal ID of the icon file attached to the data item identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/icon/crib158s1i
[Sample response in JSON]:
{"dataType":"Icon", "fileType":"image/png","contents":"iVBOR..."}

6.2.4. Command dna

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Parameter]:
start (optional, the default value is 1), end (optional, the default value is the length of the corresponding sequence) and strand (optional, selected from either forward and reverse direction, the default direction is forward)
[Function]:
returns a DNA sequence in string format attached to the data item identified by the InternalID. The sequence data is written in Fasta format without any comments. If Parameter is given, a part of the DNA sequence between the start and the end of the value of the strand is returned.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'sequence', 'dataType' and 'fileType'
[Sample URI]:
http://semantic-json.org/json/dna/cria197s3ria197s1i
[Sample response in JSON]:
{"sequence":"CATCACCTACAGCGGATCT...","dataType":"DNA", "fileType":"chemical\/seq-aa-fasta"}

6.2.5. Command rna

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Parameter]:
start (optional, the default value is 1), end (optional, the default value is the length of the corresponding sequence) and strand (optional, selected from either forward and reverse direction, the default direction is forward)
[Function]:
returns an RNA sequence in string format attached to the data item identified by the InternalID. The sequence data is written in Fasta format without any comments. If Parameter is given, a part of the RNA sequence between the start and the end of the value of the strand is returned.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'sequence', 'dataType' and 'fileType'
[Sample URI]:
http://semantic-json.org/json/rna/cria197s6ria197s1i
[Sample response in JSON]:
{"sequence":"UUCACUGUGGGAUGAGGUAG...","dataType":"RNA", "fileType":"chemical\/seq-aa-fasta"}

6.2.6. Command peptide

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Function]:
returns a peptide sequence in string format attached to the data item identified by the InternalID. The sequence data is written in Fasta format without any comments.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'sequence', 'dataType' and 'fileType'
[Sample URI]:
http://semantic-json.org/json/peptide/cria197s4ria197s1i
[Sample response in JSON]:
{"sequence":"CYIENCPLG","dataType":"Peptide", "fileType":"chemical\/seq-aa-fasta"}

6.2.7. Command protein

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Function]:
returns a protein sequence in string format attached to the data item identified by the InternalID. The sequence data is written in Fasta format without any comments.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'sequence', 'dataType' and 'fileType'
[Sample URI]:
http://semantic-json.org/json/protein/cria197s5ria197s1i
[Sample response in JSON]:
{"sequence":"mmcqkfyvvllhweflyvia...", "dataType":"Protein", "fileType":"chemical\/seq-aa-fasta"}

6.2.8. Command compound

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Function]:
returns a compound structure data in string format attached to the data item identified by the InternalID. It is assumed that the structure data is written in standardised format, such as Molfile.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'structure', 'dataType' and 'fileType'
[Sample URI]:
http://semantic-json.org/json/compound/cria197s2ria197s1i
[Sample response in JSON]:
{“structure”:” 28 33 0 0 1 0 0 0 0 0999 V2000...", "dataType":"Compound", "fileType":"chemical\/x-mdl-molfile"}

6.2.9. Command files

[Language]:
unnecessary
[InternalID]:
an InternalID of a disk, folder, page or property
[Function]:
returns a list of file information, including internal IDs, file types and file sizes, attached to the data item identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID', 'fileType', 'fileSize' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/files/crib151s2i
[Sample response in JSON]:
{"list":[{"ID":"crib151s2i~files~contents_SJIS.txt", "fileType":"text\/plain", "fileSize":262215, "dataType":"File"},..., {"ID":"crib151s2i~files~crib151s2i_swf_Fig2.PNG", "fileType":"image\/png", "fileSize":2048, "dataType":"File"}]}

6.2.10. Command fileTextString

[Language]:
unnecessary
[InternalID]:
an InternalID of a file
[Function]:
returns the content of the file identified by the InternalID in text string format
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID', 'contents', 'fileType', 'fileSize' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/fileTextString/cria197s6ria197s1i~files~mmu-let-7a-1.fasta
[Sample response in JSON]:
{"ID":"cria197s6ria197s1i~files~mmu-let-7a-1.fasta", "fileType":"chemical\/seq-aa-fasta", "dataType":"File", "fileSize":121, "contents":">mmu-let-7a-1 MI0000556...}

6.2.11. Command fileBase64String

[Language]:
unnecessary
[InternalID]:
an InternalID of a file
[Function]:
returns the content of the file identified by the InternalID in base-64 string format
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID', 'contents', 'fileType', 'fileSize' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/fileBase64String/cria197s15ria197s1i~files~title-en.jpg
[Sample response in JSON]:
{"ID":"cria197s15ria197s1i~files~title-en.jpg", "fileType":"image\/jpeg", "fileSize":56178, "dataType":"File", "contents":"\/9j\/4AAQSkZJRgABAgAAZAB...}

6.2.12. Command wiki

[Language]:
en (English) or ja (Japanese)
[InternalID]:
an InternalID of a disk, folder, page or property
[Function]:
returns an internal ID of the Wiki page of the data item identified by the InternalID written in the specified language
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/wiki/en/crib158s1i
[Sample response in JSON]:
{"ID":"wiki\/en\/crib158s1i", "dataType":"Wiki"}

6.2.13. Command links

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Function]:
returns a list of internal IDs of the links whose subject is the data item identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/links/cria93s1ria93s1i
[Sample response in JSON]:
{"list":[{"ID":"prib23s56rib23s36i","dataType":"Link",...},...,{"ID":"pria93s12ria93s2i","dataType":"Link",...}]}

6.2.14. Command reverseLinks

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder or page
[Function]:
returns a list of internal IDs of the links whose object is the data item identified by the InternalID
[Response in JSON]:
a JSON object having the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/reverseLinks/cria197s9ria197s1i
[Sample response in JSON]:
{"list":[{"ID":"pria197s2ria197s1i","dataType":"Link",...}]}

6.2.15. Command subject

[Language]:
unnecessary
[InternalID]:
an InternalID of a link
[Function]:
returns an internal ID of the data item described as the subject of the link identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/subject/pria197s3ria197s1i
[Sample response in JSON]:
{"ID":"cria197s11ria197s1i","dataType":"Page"}

6.2.16. Command property

[Language]:
unnecessary
[InternalID]:
an InternalID of a link
[Function]:
returns an internal ID of the property described as the predicate of the link identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/property/pria197s2ria197s1i
[Sample response in JSON]:
{"ID":"pria197s2i","dataType":"Property"}

6.2.17. Command object

[Language]:
unnecessary
[InternalID]:
an InternalID of a link
[Function]:
If the object is not a literal, it returns an internal ID of the data item described as the object of the link identified by the InternalID, else it returns an empty object.
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'ID' and 'dataType', or a JSON object comprising the key-value pairs of the keys 'literalDataType', 'value' and 'lang'
[Sample URI]:
http://semantic-json.org/json/object/pria197s2ria197s1i
[Sample response in JSON]:
{"ID":"cria197s9ria197s1i","dataType":"Page"}

6.2.18. Command pages

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder
[Function]:
returns a list of internal IDs of the pages belonging to the folder identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/pages/cria93s1i
[Sample response in JSON]:
{"list":[{"ID":"cria93s1ria93s1i","dataType":"Page"},{"ID":"cria93s1ria93s2i","dataType":"Page"}]}

6.2.19-1. Command folders

[Language]:
unnecessary
[InternalID]:
an InternalID of a disk
[Function]:
returns a list of internal IDs of the folders belonging to the disk identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/folders/rib158i
[Sample response in JSON]:
{"list":[{"ID":"crib158s1i","dataType":"Folder"},...,{"ID":"crib158s65i","dataType":"Folder"}]}

6.2.19-2. Command folders

[Language]:
unnecessary
[InternalID]:
an InternalID of a page
[Function]:
returns a list of internal IDs of the folders to which the page identified by the InternalID belongs
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/folders/crib151s2rib151s11i
[Sample response in JSON]:
{"list":[{"ID":"cria40u3i","dataType":"Folder"},...,{"ID":"crib151s2i","dataType":"Folder"}]}

6.2.20. Command superFolders

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder
[Function]:
returns a list of internal IDs of the superFolders of the folder identified by the InternalID. A superFolder is equivalent to the folders described with the property 'rdfs:subClassOf' in RDF schema, i.e. the triple 'folder rdfs:subClassOf superFolder' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/superFolders/crib158s12i
[Sample response in JSON]:
{"list":[{"ID":"crib158s6i","dataType":"Folder"}]}

6.2.21. Command subFolders

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder
[Function]:
returns a list of internal IDs of the subFolders of the folder identified by the InternalID. A subFolder is the reverse of a superFolder, i.e. the triple 'subFolder rdfs:subClassOf folder' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/subFolders/crib158s6i
[Sample response in JSON]:
{"list":[{"ID":"crib158s12i","dataType":"Folder"}]}

6.2.22. Command properties

[Language]:
unnecessary
[InternalID]:
an InternalID of a folder
[Function]:
returns a list of internal IDs of the properies associated with the folder identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/properties/ria93i
[Sample response in JSON]:
{"list":[{"ID":"pria93s1i","dataType":"Property"},...,{"ID":"pria93s9i","dataType":"Property"}]}

6.2.23. Command superProperties

[Language]:
unnecessary
[InternalID]:
an InternalID of a property
[Function]:
returns a list of internal IDs of the superProperties of the property identified by the InternalID. A superProperty is equivalent to the property described with property 'rdfs:subPropertyOf' in RDF schema, i.e. the triple 'property rdfs:subPropertyOf superProperty' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/superProperties/pria93s10i
[Sample response in JSON]:
{"list":{"ID":"pria93s8i","dataType":"Property"}}

6.2.24. Command subProperties

[Language]:
unnecessary
[InternalID]:
an InternalID of a property
[Function]:
returns a list of internal IDs of the subProperties of the property identified by the InternalID. A subProperty is the reverse of a superProperty, i.e. the triple 'subProperty rdfs:subPropertyOf property' holds.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/subProperties/pria93s8i
[Sample response in JSON]:
{"list":{"ID":"pria93s10i","dataType":"Property"}}

6.2.25. Command license

[Language]:
unnecessary
[InternalID]:
an InternalID of a disk, folder, page, property or file
[Function]:
returns a global URI of the license attached to the data item identified by the InternalID
[Response in JSON]:
a JSON object comprising the key-value pairs of the keys 'URI' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/license/rib158i
[Sample response in JSON]:
{"URI":"http:\/\/creativecommons.org\/licenses\/by-sa\/2.1\/jp","dataType":"License"}

6.2.26. Command searchDisks

[Language]:
unnecessary
[InternalID]:
nil
[Parameter]:
keyword, wiki (option) and file (option)
[Function]:
returns a list of internal IDs of the disks that include a keyword given as the term Parameter of the Semantic-JSON URI
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchDisks?keyword=database
[Sample response in JSON]:
{"list":[{"ID":"rib220i", "dataType":"Disk"},...,{"ID":"ria102i", "dataType":"Disk"}]}

6.2.27. Command searchFolders

[Language]:
unnecessary
[InternalID]:
nil or an InternalID of a disk
[Parameter]:
keyword, wiki (option) and file (option)
[Function]:
returns a list of internal IDs of the folders that include a keyword given as the term Parameter of the Semantic-JSON URI. When a diskID is given as the InternalID, the resultant folders are limited to the ones associated with the disk.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchFolders/rib158i?keyword=SciNetS&wiki=on
[Sample response in JSON]:
{"list":[{"ID":"crib158s2i", "dataType":"Folder"}]}

6.2.28. Command searchPages

[Language]:
unnecessary
[InternalID]:
nil or an InternalID of a disk or folder
[Parameter]:
keyword, wiki (option) and file (option)
[Function]:
returns a list of internal IDs of the pages that include a keyword given as the term Parameter of the Semantic-JSON URI. When a diskID or a folderID is given as the InternalID, the resultant pages are limited to the ones associated with the disk or the class, respectively.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchPages/cria61u5i?keyword=arabidopsis&wiki=on&file=on
[Sample response in JSON]:
{"list":[{"ID":"cria61u5ria61u2006020100i", "dataType":"Page"},...,{"ID":"cria61u5ria61u2002260100i", "dataType":"Page"}]}

6.2.29. Command searchProperties

[Language]:
unnecessary
[InternalID]:
nil or an InternalID of a disk or folder
[Parameter]:
keyword, wiki (option) and file (option)
[Function]:
returns a list of internal IDs of the properties that include a keyword given as the term Parameter of the Semantic-JSON URI. When a diskID or folderID is given as the InternalID, the resultant properties are limited to the ones associated with the disk or the folder, respectively.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchProperties/cria35u3i?keyword=language
[Sample response in JSON]:
{"list":[{"ID":"pria35u14i", "dataType":"Property"}]}

6.2.30. Command searchLiteralLinks

[Language]:
unnecessary
[InternalID]:
nil or a InternalID of a disk, folder or page
[Parameter]:
keyword, wiki (option) and file (option)
[Function]:
returns a list of internal IDs of the links whose objects are literals that include a keyword given as the term Parameter of the Semantic-JSON URI. When a diskID, folderID or pageID is given as the InternalID, the resultant links are limited to the ones whose subjects are the disk, the folder or the page, respectively.
[Response in JSON]:
a JSON object comprising the key-value pair of the key 'list' and a value that is an array of the key-value pairs of the keys 'ID', 'subject', 'property', 'object' and 'dataType'
[Sample URI]:
http://semantic-json.org/json/searchLiteralLinks/crib151s2i?keyword=semantic
[Sample response in JSON]:
{"list":[{"subject":"crib151s2rib151s132i", "property":"prib164s17i", "object":{"literalDataType":"xsd:String", "value":"The RIKEN integrated database of mammals ...", "lang":"en"}", dataType":"Link"}]}

7. Sample Programs

Since Semantic-JSON is a simple Web-based service interface in which a client requests data by specifying a URI and receives the response as a JSON object, a Semantic-JSON developer can program a Semantic-JSON client in several lines in most of the languages that implement an HTTP and/or HTTPS client and a JSON library including Ruby and Perl. However, for the convenience of a developer to generate a Semantic-JSON URI, we have developed small libraries that facilitate an implementation of the Semantic-JSON client. In the following sections, we view simple programs and application programs that handle semantic-web-based data stored in the Semantic-JSON server.

7.1. Preparation

A user can download the Semantic-JSON libraries implemented in Java, Ruby, Perl, Python and Mathematica. The Semantic-JSON library in JavaScript is embedded to the SciNetS framework. For each language, we will see how a user assemble a programming environment.

7.1.1. Java

The Semantic-JSON library includes a JAR file called semanticJSON.jar, which is a collection of Java-doc documents and sample programs. The library can be downloaded from the Semantic-JSON server at http://semantic-json.org/item/cria160s1ria160s5i~files~semanticJsonJava.zip. This library requires external libraries, including Json-lib (http://json-lib.sourceforge.net/), Commons BeanUtils (http://commons.apache.org/beanutils/), Commons Collections (http://commons.apache.org/collections/), Commons Logging (http://commons.apache.org/logging/), Commons Lang (http://commons.apache.org/lang/), Apache log4j (http://logging.apache.org/log4j/index.html) and EZMorph (http://sourceforge.net/projects/ezmorph/). All of the JAR files should be installed and set in the user classpath.

7.1.2. Ruby

The Semantic-JSON library in Ruby is implemented as a Ruby program file called semanticJson.rb, which can be downloaded from the Semantic-JSON server at http://semantic-json.org/item/cria160s1ria160s5i~files~semanticJsonRuby.zip. In addition, a package called Simple JSON (http://rubyforge.org/projects/simple-json/) is required. These program files should be located in a directory listed in the environment variable 'RUBYLIB' so that a Ruby interpreter can discover the files.

7.1.3. Perl

The Semantic-JSON library in Perl is implemented as a Perl program file called semanticJson.pl, which can be downloaded from the Sementic-JSON server at http://semantic-json.org/item/cria160s1ria160s5i~files~semanticJsonPerl.zip. In addition, the JSON/CPAN library (http://search.cpan.org/dist/JSON/) is required; some of the Perl distributions however include this library by default.

7.1.4. Python

The Semantic-JSON library in Python is implemented as a Python program file called semanticJson.py, which can be downloaded from the Semantic-JSON server at http://semantic-json.org/item/cria160s1ria160s5i~files~semanticJsonPython.zip. In addition, library json-py (http://sourceforge.net/projects/json-py/) is required; some of the Python distributions however include this library by default.

7.1.5. JavaScript

Because of the security reasons, usually in JavaScript an HTTP / HTTPS request for a server can be performed only by a program downloaded from the server. Therefore, the Semantic-JSON server supported by SciNetS provides a programming environment with the Semantic-JSON library implemented as the object 'SemanticJSON.library' that allows a SciNetS user to write a Semantic-JSON client program in JavaScript and to publish it by embedding a Wiki page associated with a SciNetS page or folder. In order to develop a JavaScript program on the Semantic-JSON server, a developer needs to log-on the SciNetS system. However, a JavaScript program in Wiki can be performed without log-on using a Web browser. For a developer's convenience, the archive file containing two sample programs in JavaScript can be downloaded from the Semantic-JSON server at http://semantic-json.org/item/cria160s1ria160s5i~files~semanticJsonJavaScript.zip.

7.1.6. Mathematica

The Semantic-JSON library in Mathematica is implemented as a Mathematica package file called SemanticJson.m, which can be downloaded from the Semantic-JSON server at http://semantic-json.org/item/cria160s1ria160s5i~files~semanticJsonMathematica.zip. In addition, library JSON-Mathematica (http://semantic-json.org/item/cria160s4ria160s1i) is required, and this library is included in the Semantic-JSON library.

7.2. Simple Programs

Here we discuss very simple programs to illustrate the manner in which a user programs using the Semantic-JSON libraries. All sample programs shown in this section perform the command 'name' to obtain the English name of the SciNetS disk specified by internalID 'rib158i' stored in the Semantic-JSON server 'http://semantic-json.org'.

7.2.1. Java

Code 6.1. is a sample Java program implemented as the Java class jp.riken.base.scines.JSON.test.SimpleTest.

package jp.riken.base.scines.JSON.test;

// imports class JSONObject defined in Json-lib
import net.sf.json.JSONObject;

// imports class JSONClient that implements a Semantic-JSON client provided by the Semantic-JSON library
import jp.riken.base.scines.JSON.JSONClient;

public class SimpleTest {

    public static void main(String[] args) throws Exception{
        // initialises a client for Semantic-JSON server http://semantic-json.org
        JSONClient client = new JSONClient("http://semantic-json.org");

        // obtains a JSON object including a disk name in English by calling name command for SciNes disk "rib158i"
        JSONObject jObject = client.invoke("http://semantic-json.org/json/name/en/rib158i");

        // the previous line is equivalent to the following line
        jObject = client.invoke("name", "en", "rib158i", null);

        // prints the JSON object
        System.out.println("JSONObject: " + jObject.toString());
        System.out.println("name: " + jObject.getString("name"));
        System.out.println("language: " + jObject.getString("lang"));
    }

}

Code 7.1. Simple program in Java. First, an instance of the class 'JSONClient' is generated by taking the URL of the Semantic-JSON server as a parameter. By calling the method 'invoke', the program obtains a JSON object by accessing the server. The JSON object is analysed using the Json-lib library.

When the program is launched, the following result is obtained:


% java jp.riken.base.scines.JSON.test.SimpleTest

JSONObject: {"lang":"en","name":"RIKEN SciNetS"}
name: RIKEN SciNetS
language: en

Figure 7.1. Result of the Code 7.1.

7.2.2. Ruby

Code 7.2. is a sample Ruby program stored in the file 'simpleTest.rb'.


# Loads the Semantic-JSON library
require "semanticJson"

# Initialises a Client for Semantic-JSON service at http://semantic-json.org
jsonClient = JSONClient.new("http://semantic-json.org")

# Obtains a JSON object including a disk name in English by calling name command for SciNes disk "rib158i"
jObject = jsonClient.invokeByURI("http://semantic-json.org/json/name/en/rib158i");

# the previous line is equivalent to the following line
jObject = jsonClient.invoke("name", "en", "rib158i",nil);

# Prints the JSON object
print "JSONObject: "; p jObject
puts "name: " << jObject["name"]
puts "language: " << jObject["lang"]

Code 7.2. Simple program in Ruby. First, an instance of the class 'JSONClient' is generated by taking the URL of the Semantic-JSON server as a parameter. By calling the method 'invokeByURI' or 'invoke', the program obtains a JSON object by accessing the server. The JSON object is obtained as a Hash and/or Array of Ruby.

When the program is launched, the following result is obtained:


% ruby simpleTest.rb
JSONObject: {"lang"=>"en", "name"=>"RIKEN SciNetS"}
name: RIKEN SciNetS
language: en

Figure 7.2. Result of the Code 7.2.

7.2.3. Perl

Code 7.3. is a sample Perl program stored in the file 'simpleTest.pl'.


#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
# Loads the Semantic-JSON library
use SemanticJson;

# Initialises a Client for Semantic-JSON service at http://semantic-json.org
my $jsonClient = SemanticJson->new("http://semantic-json.org");

# Obtains a JSON object including a disk name in English by calling name command for SciNes disk "rib158i"
my $jObject = $jsonClient->invokeByURI("http://semantic-json.org/json/name/en/rib158i");

# the previous line is equivalent to the following line
$jObject = $jsonClient->invoke("name", "en", "rib158i",undef);

# Prints the JSON object
print "JSONObject: ".Dumper($jObject);
print "name: ".$jObject->{"name"}."\n";
print "language: ".$jObject->{"lang"}."\n";

Code 7.3. Simple program in Perl. First, module "JSONClient" is initialized by taking the URL of the Semantic-JSON server as a parameter. By calling function "invokeByURI" or "invoke", the program obtains a JSON object by accessing the server. The JSON object is obtained as a Hash and/or Array of Perl.

When the program is launched, the following result is obtained:


% perl simpleTest.pl

JSONObject: $VAR1 = {
'lang' => 'en',
'name' => 'RIKEN SciNetS'
};
name: RIKEN SciNetS'
language: en'


Figure 7.3. Result of the Code 7.3.

7.2.4. Python

Code 7.4. is a sample Python program stored in the file 'simpleTest.py'.


#!/usr/bin/python

import semanticJson

# Initialises a Client for Semantic-JSON service at http://semantic-json.org
jClient = semanticJson.jsonClient('http://semantic-json.org')

# Obtains a JSON object including a disk name in English by calling name command for SciNes disk "rib158i"
jObject = jClient.invokeByURI('http://semantic-json.org/json/name/en/rib158i')

# the previous line is equivalent to the following line
jObject = jClient.invoke('name', 'en', 'rib158i','')

# Prints the JSON object
print 'JSONObject: ',
print jObject
print 'name: ' + jObject['name']
print 'language: ' + jObject['lang']

Code 7.4. Simple program in Python. First, the class 'jsonClient' is initialized by taking the URL of the Semantic-JSON server as a parameter. By calling function "invokeByURI" or "invoke", the program obtains a JSON object by accessing the server. The JSON object is obtained as a Map and/or Array of Python.

When the program is launched, the following result is obtained:


% python simpleTest.py
JSONObject: {'lang': 'en', 'name': 'RIKEN SciNetS'}
name: RIKEN SciNetS
language: en

Figure 7.4. Result of the Code 7.4.

7.2.5. JavaScript

Code 7.5. is a sample JavaScript program stored in the file 'simpleTest.js'. This program can also be displayed at http://semantic-json.org/sw/script/en/cria197s17ria197s1i/.


function main() {
   // obtains a JSON object including a disk name in English by calling name command for SciNes disk "rib158i"
   var obj = SemanticJSON.Library.invokeByURI("http://semantic-json.org/json/name/en/rib158i");
   // the previous line is equivalent to the following line
   obj = SemanticJSON.Library.invoke("name","en","rib158i","");
   // prints the JSON object
   SemanticJSON.Library.write("name: "+obj.name);
   SemanticJSON.Library.write("<br>\n");
   SemanticJSON.Library.write("language: "+obj.lang);
   SemanticJSON.Library.write("<br>\n");
}

Code 7.5. Simple program in JavaScript. By calling function "invokeByURI" or "invoke", the program obtains a JSON object by accessing the server.

When the program is launched, the following result is obtained:


name: RIKEN SciNetS
language: en

Figure 7.5. Result of the Code 7.5.

7.2.6. Mathematica

Code 7.6 is a sample Mathematica program stored in the file 'SimpleTest.nb'. Code 7.6 includes the result of the evaluation of each of the Mathematica expressions in the file.


In[1]:= Needs["RIKEN`BASE`SemanticJSON`" ]
Out[1]:= Package RIKEN`BASE`JSON` loaded. (rev: 20100113-4)
         Package RIKEN`BASE`SemanticJSON` loaded. (rev: 20100114-4)

        (* Set a URL for Semantic-JSON service at http://semantic-json.org *)
In[2]:= $JsonServerURL = "http://semantic-json.org"
Out[2]:=
"http://semantic-json.org"

        (* Obtains a JSON object including a disk name in English by calling name command for SciNes disk "rib158i" *)
In[3]:= obj = Invoke["http://semantic-json.org/json/name/en/rib158i"]
Out[3]:=
JsonObject[KVPair["lang", "en"], KVPair["name", "RIKEN SciNetS"]]

        (* the previous line is equivalent to the following line *)
In[4]:=obj = Invoke["name", "en", "rib158i"]
Out[4]:=JsonObject[KVPair["lang", "en"], KVPair["name", "RIKEN SciNetS"]]

        (* Prints the result *)
In[5]:= Print["JsonObject: ", obj];
       Print["name: ", GetValue[obj, "name"]];
       Print["language: ", GetValue[obj, "lang"]]

        JsonObject: JsonObject[KVPair[lang,en],KVPair[name,RIKEN SciNetS]]
        name: RIKEN SciNetS
        language: en

Code 7.6. Simple program in Mathematica. First, load the Semantic-JSON package in In[1] and then specify the URL of the Semantic-JSON server in In[2]. By calling the function 'Invoke' in In[3] and In[4], the program obtains a JSON object by accessing the server. The JSON object is obtained as a JSON-Mathematica compliant Mathematica expression.

7.3. Application Programs for Genome Sequence Processing

As an example of problem solving in bioinformatics, we view sample programs that handle a genome sequence stored in the Semantic-JSON server. The sample programs traverse a part of the Semantic Web data starting with page 'ATGC00280' (URI: http://semantic-json.org/item/cria197s11ria197s1i, internal ID: cria197s11ria197s1) of folder 'Arabidopsis Locus' (URI: http://semantic-json.org/item/cria197s11i, internal ID: cria197s11i), stored in disk 'SciNetS Data Structure' (URI: http://semantic-json.org/item/ria197i, internal ID: ria197i) and obtain a part of the genome sequence written in Fasta format (Figure 7.6).


Figure 7.6. Part of the Semantic Web-based data structure stored in SciNetS disk 'SciNetS Data Structure' (URI: http://semantic-json.org/item/ria197i, internal ID: ria197i). In this tutorial, we start from page 'ATCG00280' of folder 'Arabidopsis Locus' and obtain a part of the genome sequence attached to page 'chloroplast genome' of folder 'Arabidopsis Genome Sequence'.

Sample programs prepared for each programming language are included in the library of the language. Detailed descriptions are written as comments in the source code.

7.3.1. Java

Code 7.7 is a sample program implemented as the Java class jp.riken.base.scines.JSON.test.GenomeSequenceTest.

package jp.riken.base.scines.JSON.test;

import net.sf.json.JSONObject;
import jp.riken.base.scines.JSON.JSONClient;

public class GenomeSequenceTest {

   public static void main(String[] args) throws Exception{

     // initialises a Semantic-JSON client
     JSONClient client = new JSONClient("http://semantic-json.org");

     // obtains a list of statements start with the individual labeled by "ATCG00280"
     JSONObject jObject = client.invoke("statements", null, "cria197s11ria197s1i", null);
     JSONObject[] statements = client.getJSONObjectList(jObject);

     // obtains start, end, strand data and the URI of individual associated with a genome sequence from the list of statements
     String start=null, end=null, strand=null, genomeSequenceURI = null;
     for( JSONObject statement: statements){
       String propertyURI = statement.getJSONObject("property").getString("ID");
       String propertyName = client.invoke("name", "en", propertyURI, null).getString("name");
       if( "start".equals(propertyName) ) {
         start = statement.getJSONObject("object").getString("value");
       }
       if( "end".equals(propertyName) ) {
         end = statement.getJSONObject("object").getString("value");
       }
       if( "strand".equals(propertyName) ) {
         String strandURI = statement.getJSONObject("object").getString("ID");
         strand = client.invoke("name", "en", strandURI, null).getString("name");
       }
       if( "genomeSequence".equals(propertyName) ) {
         genomeSequenceURI = statement.getJSONObject("object").getString("ID");
       }
     }

     // obtains part of the genome sequence
     String sequence = client.invoke("dna", null, genomeSequenceURI,new String[]{"start="+start, "end="+end, "strand="+strand}).getString("sequence");

     // finally, print the sequence
     System.out.println("DNA sequence: " + sequence);
  }
}

Code 7.7. Sample program in Java of the class jp.riken.base.scines.JSON.test.GenomeSequenceTest.  It implements a client that obtains a part of a chloroplast genome sequence from 33720 bp to 35141 bp of a forward strand specified by locus 'ATCG00280' in Arabidopsis.

When the program is launched, the following result is obtained:


% java jp.riken.base.scines.JSON.test.GenomeSequenceTest

DNA Sequence: atgaaaaccttatattccctgaggaggttctaccacgtggaaacgctctttaatggaac
tttagctttagctggtcgtgaccaagaaaccaccggtttcgcttggtgggccgggaatgcccgacttatcaat
ttatctggtaaacttttgggagctcatgtagcccatgccggattaatcgtattctgggccggagcaatgaact
tatttgaagtggcccattttgtacctgaaaagcccatgtatgaacaaggattaattttacttccccacctagc
cactttaggatggggggtaggtcctgggggagaagttatagacacctttccgtactttgtatctggagtactt
cacttaatttcttctgcagttttgggctttggcggtatttatcatgcacttctgggacccgaaactcttgaag
aatcttttccctttttcggttatgtatggaaagatagaaataaaatgaccaccattttgggtattcacttaat
tttgttaggtgtaggtgcctttcttctagtattcaaggctctctattttgggggcgtatatgatacctgggct
ccgggagggggggatgtaagaaaaattacaaacttgactcttagcccaagtgttatatttggttatttactaa
aatctccctttgggggagaaggatggattgttagtgtggacgatttggaagatataattggaggacatgtatg
gttaggttccatttgtatatttggtggaatctggcatatcttaaccaagccttttgcatgggctcgccgcgca
cttgtatggtctggggaggcttacttgtcttatagtttagctgctttatctgtttgtggtttcattgcttgtt
gttttgtctggtttaataataccgcttaccctagtgagttttacggacctacggggccagaagcttctcaagc
tcaagcatttacttttctagttagagaccaacgtcttggagctaacgtggggtctgctcaaggacctacaggt
ttaggtaaatacttaatgcgttctccgactggagaagttatttttggaggagaaacaatgcgtttttgggatc
tgcgtgctccctggttagaacctttaaggggtcctaacggtttggacttgagtaggttgaaaaaagacataca
accttggcaagaacgacgttcggcagaatatatgactcatgctcctttaggttcgttaaattctgtagggggc
gtagctactgagatcaatgcagtcaattatgtctctccgagaagttggttatctacctctcattttgttctag
gatttttcctattcgtgggtcatttatggcacgcgggaagggctcgggcagcggcagcgggatttgaaaaagg
aattgatcgtgattttgaacctgttctttccatgactcctcttaactaat

Figure 7.7. Sample operation of launching the Java program 'jp.riken.base.scines.JSON.test.GenomeSequenceTest' and the result.

7.3.2 Ruby

Code 7.8 is a sample Ruby program stored in the file 'genomeSequenceTest.rb'.


# Loads the Semantic-JSON library
require "semanticJson"

# Initialises a Client for Semantic-JSON service at http://semantic-json.org
jsonClient = JSONClient.new("http://semantic-json.org")

# Obtains a list of statements start with the individual labeled by "ATCG00280"
statements = jsonClient.invoke("statements", nil, "cria197s11ria197s1i", nil)["list"]

# Obtains start, end, strand data and the URI of individual associated with a genome sequence from the list of statements
statements.each do |statement|
   propertyURI = statement["property"]["ID"]
   propertyName = jsonClient.invoke("name", "en", propertyURI, nil)["name"]
   if( propertyName == "start" )
     $start = statement["object"]["value"].to_s
   end
   if( propertyName == "end" )
     $end = statement["object"]["value"].to_s
   end
   if( propertyName == "strand" )
     strandURI = statement["object"]["ID"]
     $strand = jsonClient.invoke("name", "en", strandURI, nil)["name"]
   end
   if( propertyName == "genomeSequence" )
     $genomeSequenceURI = statement["object"]["ID"]
   end
end

# Obtains part of the genome sequence
sequence = jsonClient.invoke("dna", nil, $genomeSequenceURI,"start="+$start+"&end="+$end+"&strand="+$strand)["sequence"]

# Finally, print the sequence
puts "DNA sequence: " << sequence

Code 7.8. Sample Ruby program stored in the file 'genomeSequenceTest.rb'.

When the program is launched, the following result is obtained:

% ruby genomeSequenceTest.rb

DNA Sequence: atgaaaaccttatattccctgaggaggttctaccacgtggaaacgctctttaatggaac
tttagctttagctggtcgtgaccaagaaaccaccggtttcgcttggtgggccgggaatgcccgacttatcaat
ttatctggtaaacttttgggagctcatgtagcccatgccggattaatcgtattctgggccggagcaatgaact
tatttgaagtggcccattttgtacctgaaaagcccatgtatgaacaaggattaattttacttccccacctagc
cactttaggatggggggtaggtcctgggggagaagttatagacacctttccgtactttgtatctggagtactt
cacttaatttcttctgcagttttgggctttggcggtatttatcatgcacttctgggacccgaaactcttgaag
aatcttttccctttttcggttatgtatggaaagatagaaataaaatgaccaccattttgggtattcacttaat
tttgttaggtgtaggtgcctttcttctagtattcaaggctctctattttgggggcgtatatgatacctgggct
ccgggagggggggatgtaagaaaaattacaaacttgactcttagcccaagtgttatatttggttatttactaa
aatctccctttgggggagaaggatggattgttagtgtggacgatttggaagatataattggaggacatgtatg
gttaggttccatttgtatatttggtggaatctggcatatcttaaccaagccttttgcatgggctcgccgcgca
cttgtatggtctggggaggcttacttgtcttatagtttagctgctttatctgtttgtggtttcattgcttgtt
gttttgtctggtttaataataccgcttaccctagtgagttttacggacctacggggccagaagcttctcaagc
tcaagcatttacttttctagttagagaccaacgtcttggagctaacgtggggtctgctcaaggacctacaggt
ttaggtaaatacttaatgcgttctccgactggagaagttatttttggaggagaaacaatgcgtttttgggatc
tgcgtgctccctggttagaacctttaaggggtcctaacggtttggacttgagtaggttgaaaaaagacataca
accttggcaagaacgacgttcggcagaatatatgactcatgctcctttaggttcgttaaattctgtagggggc
gtagctactgagatcaatgcagtcaattatgtctctccgagaagttggttatctacctctcattttgttctag
gatttttcctattcgtgggtcatttatggcacgcgggaagggctcgggcagcggcagcgggatttgaaaaagg
aattgatcgtgattttgaacctgttctttccatgactcctcttaactaat

Figure 7.8. Sample operation of launching the Ruby program 'genomeSequenceTest.nb' and the result.

7.3.3. Perl

Code 7.9 is a sample Perl program stored in the file 'genomeSequenceTest.pl'.


#!/usr/bin/perl
use strict;
use warnings;

# Loads the Semantic-JSON library
use JsonClient;

# Initialise a client for Semantic-JSON service at http://semantic-json.org
my $jsonClient = JsonClient->new("http://semantic-json.org");

# Obtains a list of statements start with the individual labeled by "ATCG00280"
my $statements = $jsonClient->invoke("statements", "", "cria197s11ria197s1i" ,"")->{"list"};

my $start="";
my $end="";
my $strand="";
my $genomeSequenceURI="";

# Otains start, end, strand data and the URI of individual associated with a genome sequence from the list of statements
foreach my $statement (@$statements){
   my $propertyURI = $statement->{"property"}->{"ID"};
   my $propertyName = $jsonClient->invoke("name", "en", $propertyURI ,"")->{"name"};
   if( $propertyName eq "start"){
     $start = $statement->{"object"}->{"value"};
   }
   if( $propertyName eq "end"){
     $end = $statement->{"object"}->{"value"};
   }
   if( $propertyName eq "strand"){
     my $strandURI = $statement->{"object"}->{"ID"};
     $strand = $jsonClient->invoke("name", "en", $strandURI,"")->{"name"};
   }
   if( $propertyName eq "genomeSequence"){
     $genomeSequenceURI = $statement->{"object"}->{"ID"};
   }
}

# Obtains part of the genome sequence
my $sequence = $jsonClient->invoke("dna", "", $genomeSequenceURI ,"start=".$start."&end=".$end."&strand=".$strand)->{"sequence"};

# Finally, print the sequence
print 'DNA sequence: ' . $sequence . "\n";

Code 7.9. Sample Perl program stored in the file 'genomeSequenceTest.pl'.

When the program is launched, the following result is obtained:

% perl genomeSequenceTest.pl

DNA Sequence: atgaaaaccttatattccctgaggaggttctaccacgtggaaacgctctttaatggaac
tttagctttagctggtcgtgaccaagaaaccaccggtttcgcttggtgggccgggaatgcccgacttatcaat
ttatctggtaaacttttgggagctcatgtagcccatgccggattaatcgtattctgggccggagcaatgaact
tatttgaagtggcccattttgtacctgaaaagcccatgtatgaacaaggattaattttacttccccacctagc
cactttaggatggggggtaggtcctgggggagaagttatagacacctttccgtactttgtatctggagtactt
cacttaatttcttctgcagttttgggctttggcggtatttatcatgcacttctgggacccgaaactcttgaag
aatcttttccctttttcggttatgtatggaaagatagaaataaaatgaccaccattttgggtattcacttaat
tttgttaggtgtaggtgcctttcttctagtattcaaggctctctattttgggggcgtatatgatacctgggct
ccgggagggggggatgtaagaaaaattacaaacttgactcttagcccaagtgttatatttggttatttactaa
aatctccctttgggggagaaggatggattgttagtgtggacgatttggaagatataattggaggacatgtatg
gttaggttccatttgtatatttggtggaatctggcatatcttaaccaagccttttgcatgggctcgccgcgca
cttgtatggtctggggaggcttacttgtcttatagtttagctgctttatctgtttgtggtttcattgcttgtt
gttttgtctggtttaataataccgcttaccctagtgagttttacggacctacggggccagaagcttctcaagc
tcaagcatttacttttctagttagagaccaacgtcttggagctaacgtggggtctgctcaaggacctacaggt
ttaggtaaatacttaatgcgttctccgactggagaagttatttttggaggagaaacaatgcgtttttgggatc
tgcgtgctccctggttagaacctttaaggggtcctaacggtttggacttgagtaggttgaaaaaagacataca
accttggcaagaacgacgttcggcagaatatatgactcatgctcctttaggttcgttaaattctgtagggggc
gtagctactgagatcaatgcagtcaattatgtctctccgagaagttggttatctacctctcattttgttctag
gatttttcctattcgtgggtcatttatggcacgcgggaagggctcgggcagcggcagcgggatttgaaaaagg
aattgatcgtgattttgaacctgttctttccatgactcctcttaactaat

Figure 7.9. Sample operation of launching Perl program 'genomeSequenceTest.pl' and the result.

7.3.4. Python

Code 7.10 is a sample Python program stored in the file 'genomeSequenceTest.py'.


# Loads the Semantic-JSON library
import semanticJson

# Initialise a Client for Semantic-JSON service at http://semantic-json.org
jClient = semanticJson.jsonClient('http://semantic-json.org')

# Obtains a list of statements start with the individual labeled by "ATCG00280"
statements = jClient.invoke('statements', '', 'cria197s11ria197s1i', '')["list"]

# Otains start, end, strand data and the URI of individual associated with a genome sequence from the list of statements
for statement in statements:
   propertyURI = statement["property"]["ID"]
   propertyName = jClient.invoke('name', 'en', propertyURI, '')["name"]
   if propertyName == 'start':
     start = statement["object"]["value"]
   if propertyName == 'end':
     end = statement["object"]["value"]
   if propertyName == 'strand':
   strandURI = statement["object"]["ID"]
     strand = jClient.invoke('name', 'en', strandURI, '')["name"]
   if propertyName == 'genomeSequence':
     genomeSequenceURI = statement["object"]["ID"]

# Obtains part of the genome sequence
sequence = jClient.invoke('dna', '', genomeSequenceURI, 'start=' + str(start) + '&end='+str(end) + '&strand=' + strand)["sequence"]

# Finally, print the sequence
print 'DNA sequence: ' + sequence

Code 7.10. Sample Python program stored in the file 'genomeSequenceTest.py'.

When the program is launched, the following result is obtained:

% python genomeSequenceTest.py

DNA Sequence: atgaaaaccttatattccctgaggaggttctaccacgtggaaacgctctttaatggaac
tttagctttagctggtcgtgaccaagaaaccaccggtttcgcttggtgggccgggaatgcccgacttatcaat
ttatctggtaaacttttgggagctcatgtagcccatgccggattaatcgtattctgggccggagcaatgaact
tatttgaagtggcccattttgtacctgaaaagcccatgtatgaacaaggattaattttacttccccacctagc
cactttaggatggggggtaggtcctgggggagaagttatagacacctttccgtactttgtatctggagtactt
cacttaatttcttctgcagttttgggctttggcggtatttatcatgcacttctgggacccgaaactcttgaag
aatcttttccctttttcggttatgtatggaaagatagaaataaaatgaccaccattttgggtattcacttaat
tttgttaggtgtaggtgcctttcttctagtattcaaggctctctattttgggggcgtatatgatacctgggct
ccgggagggggggatgtaagaaaaattacaaacttgactcttagcccaagtgttatatttggttatttactaa
aatctccctttgggggagaaggatggattgttagtgtggacgatttggaagatataattggaggacatgtatg
gttaggttccatttgtatatttggtggaatctggcatatcttaaccaagccttttgcatgggctcgccgcgca
cttgtatggtctggggaggcttacttgtcttatagtttagctgctttatctgtttgtggtttcattgcttgtt
gttttgtctggtttaataataccgcttaccctagtgagttttacggacctacggggccagaagcttctcaagc
tcaagcatttacttttctagttagagaccaacgtcttggagctaacgtggggtctgctcaaggacctacaggt
ttaggtaaatacttaatgcgttctccgactggagaagttatttttggaggagaaacaatgcgtttttgggatc
tgcgtgctccctggttagaacctttaaggggtcctaacggtttggacttgagtaggttgaaaaaagacataca
accttggcaagaacgacgttcggcagaatatatgactcatgctcctttaggttcgttaaattctgtagggggc
gtagctactgagatcaatgcagtcaattatgtctctccgagaagttggttatctacctctcattttgttctag
gatttttcctattcgtgggtcatttatggcacgcgggaagggctcgggcagcggcagcgggatttgaaaaagg
aattgatcgtgattttgaacctgttctttccatgactcctcttaactaat

Figure 7.10. Sample operation of launching the Python program 'genomeSequenceTest.py' and the result.

7.3.5. JavaScript

Code 7.11 is a sample JavaScript program stored in the file 'genomeSequenceTest.js'. This program can also be displayed at http://semantic-json.org/sw/script/en/cria197s17ria197s2i/.


function main(){
   var start = 0;
   var end = 0;
   var strand = "";
   var genomeSequenceURI="";
  
   // obtains a list of statements start with the individual labeled by "ATCG00280"
   var obj = SemanticJSON.Library.invoke("statements","","cria197s11ria197s1i","");
   var list = obj.list;
  
   // obtains start, end, strand data and the URI of individual associated with a genome sequence from the list of statements
   for(var i = 0; i
     var statement = list[i];
     var propertyURI = statement.property.ID;
     var nameObj = SemanticJSON.Library.invoke("name","en",propertyURI,"");
     var propertyName = nameObj.name;

     if(propertyName=="start"){
       start = statement.object.value;
     }else if(propertyName=="end"){
       end = statement.object.value;
     }else if(propertyName=="strand"){
       var strandURI = statement.object.ID;
       var strandObj = SemanticJSON.Library.invoke("name","en",strandURI,"");
       strand = strandObj.name;
     }else if(propertyName=="genomeSequence"){
       genomeSequenceURI=statement.object.ID;
     }
   }

   // obtains part of the genome sequence
   var dnaObj = SemanticJSON.Library.invoke("dna","",genomeSequenceURI,"start="+start+"&end="+end+"&strand="+strand);
   var dnaSequence = dnaObj.sequence;
   var result = "<br>";
   for(var j = 0 ; j < dnaSequence.length ; j++){
     result=result+dnaSequence.charAt(j);
     if((j+1)%80===0){
       result=result+"<br>\n";
     }
   }

   // finally, print the sequence
   SemanticJSON.Library.write("DNA sequence: "+ result+"<br>\n");
}

Code 7.11. Sample JavaScript program stored in the file 'genomeSequenceTest.js'.

When the program is launched, the following result is obtained:

DNA Sequence:
atgaaaaccttatattccctgaggaggttctaccacgtggaaacgctctttaatggaactttagctttagctggtcgtga
ccaagaaaccaccggtttcgcttggtgggccgggaatgcccgacttatcaatttatctggtaaacttttgggagctcatg
tagcccatgccggattaatcgtattctgggccggagcaatgaacttatttgaagtggcccattttgtacctgaaaagccc
atgtatgaacaaggattaattttacttccccacctagccactttaggatggggggtaggtcctgggggagaagttataga
cacctttccgtactttgtatctggagtacttcacttaatttcttctgcagttttgggctttggcggtatttatcatgcac
ttctgggacccgaaactcttgaagaatcttttccctttttcggttatgtatggaaagatagaaataaaatgaccaccatt
ttgggtattcacttaattttgttaggtgtaggtgcctttcttctagtattcaaggctctctattttgggggcgtatatga
tacctgggctccgggagggggggatgtaagaaaaattacaaacttgactcttagcccaagtgttatatttggttatttac
taaaatctccctttgggggagaaggatggattgttagtgtggacgatttggaagatataattggaggacatgtatggtta
ggttccatttgtatatttggtggaatctggcatatcttaaccaagccttttgcatgggctcgccgcgcacttgtatggtc
tggggaggcttacttgtcttatagtttagctgctttatctgtttgtggtttcattgcttgttgttttgtctggtttaata
ataccgcttaccctagtgagttttacggacctacggggccagaagcttctcaagctcaagcatttacttttctagttaga
gaccaacgtcttggagctaacgtggggtctgctcaaggacctacaggtttaggtaaatacttaatgcgttctccgactgg
agaagttatttttggaggagaaacaatgcgtttttgggatctgcgtgctccctggttagaacctttaaggggtcctaacg
gtttggacttgagtaggttgaaaaaagacatacaaccttggcaagaacgacgttcggcagaatatatgactcatgctcct
ttaggttcgttaaattctgtagggggcgtagctactgagatcaatgcagtcaattatgtctctccgagaagttggttatc
tacctctcattttgttctaggatttttcctattcgtgggtcatttatggcacgcgggaagggctcgggcagcggcagcgg
gatttgaaaaaggaattgatcgtgattttgaacctgttctttccatgactcctcttaactaat

Figure 7.11. Sample operation of launching the JavaScript program 'genomeSequenceTest.js' and the result.

7.3.6. Mathematica

Code 7.12 is a sample Mathematica program stored in the file 'GenomeSequenceTest.nb'. Code 7.12 includes the result of the evaluation of each of the Mathematica expressions in the file.


In[1]:= Needs["RIKEN`BASE`SemanticJSON`" ]
Out[1]:= Package RIKEN`BASE`JSON` loaded. (rev: 20100201-1)
         Package RIKEN`BASE`SemanticJSON` loaded. (rev: 20100201-1)

        (* Set a URL for Semantic-JSON service at http://semantic-json.org *)
In[2]:= $JsonServerURL = "http://semantic-json.org"
Out[2]:=
http://semantic-json.org/json

        (* Obtains a list of statements start with the individual labeled by \ "ATCG00280" *)
In[3]:= statements = GetValue[Invoke["statements", "cria197s11ria197s1i"], "list"];

        (* Obtains start, end, strand data and the URI of individual associated with a genome sequence from the list of statements *)
In[4]:=Map[Module[{propertyURI, propertyName, strandURI},
           propertyURI = GetValue[GetValue[#, "property"], "ID"];
           propertyName = GetValue[Invoke["name", "en", propertyURI], "name"];
           If[Equal[propertyName, "start"], start = ToString[GetValue[GetValue[#, "object"], "value"]]];
           If[Equal[propertyName, "end"], end = ToString[GetValue[GetValue[#, "object"], "value"]]];
           If[Equal[propertyName, "strand"], strandURI = GetValue[GetValue[#, "object"], "ID"]; strand = GetValue[Invoke["name", "en", strandURI], "name"]];
           If[Equal[propertyName, "genomeSequence"], genomeSequenceURI = GetValue[GetValue[#, "object"], "ID"]];] &, statements];


        (* Obtains part of the genome sequence *)
In[5]:= sequence = GetValue[Invoke["dna", genomeSequenceURI, {"start=" <> start, "end=" <> end, "starnd=" <> strand}], "sequence"];

        (* Finally, prints the sequence *)
In[6]:= Print["DNA Sequence: ", sequence]
Out[6]:=
DNA Sequence: atgaaaaccttatattccctgaggaggttctaccacgtggaaacgctctttaatggaac
tttagctttagctggtcgtgaccaagaaaccaccggtttcgcttggtgggccgggaatgcccgacttatcaat
ttatctggtaaacttttgggagctcatgtagcccatgccggattaatcgtattctgggccggagcaatgaact
tatttgaagtggcccattttgtacctgaaaagcccatgtatgaacaaggattaattttacttccccacctagc
cactttaggatggggggtaggtcctgggggagaagttatagacacctttccgtactttgtatctggagtactt
cacttaatttcttctgcagttttgggctttggcggtatttatcatgcacttctgggacccgaaactcttgaag
aatcttttccctttttcggttatgtatggaaagatagaaataaaatgaccaccattttgggtattcacttaat
tttgttaggtgtaggtgcctttcttctagtattcaaggctctctattttgggggcgtatatgatacctgggct
ccgggagggggggatgtaagaaaaattacaaacttgactcttagcccaagtgttatatttggttatttactaa
aatctccctttgggggagaaggatggattgttagtgtggacgatttggaagatataattggaggacatgtatg
gttaggttccatttgtatatttggtggaatctggcatatcttaaccaagccttttgcatgggctcgccgcgca
cttgtatggtctggggaggcttacttgtcttatagtttagctgctttatctgtttgtggtttcattgcttgtt
gttttgtctggtttaataataccgcttaccctagtgagttttacggacctacggggccagaagcttctcaagc
tcaagcatttacttttctagttagagaccaacgtcttggagctaacgtggggtctgctcaaggacctacaggt
ttaggtaaatacttaatgcgttctccgactggagaagttatttttggaggagaaacaatgcgtttttgggatc
tgcgtgctccctggttagaacctttaaggggtcctaacggtttggacttgagtaggttgaaaaaagacataca
accttggcaagaacgacgttcggcagaatatatgactcatgctcctttaggttcgttaaattctgtagggggc
gtagctactgagatcaatgcagtcaattatgtctctccgagaagttggttatctacctctcattttgttctag
gatttttcctattcgtgggtcatttatggcacgcgggaagggctcgggcagcggcagcgggatttgaaaaagg
aattgatcgtgattttgaacctgttctttccatgactcctcttaactaat

Code 7.12. Sample program in Mathematica called GenomeSequenceTest.nb.


7.4. Application Programs for Inference over Mouse Phenotype databases

The sample programs introduced here handle integrated databases of Mouse Phenotype in SciNetS. These mouse phenotype databases are the Japan Mouse Clinic (JMC) database (http://semantic-json.org/item/ria110i) and Europhenome Mouse Phenotyping Resource database (http://semantic-json.org/item/ria109i) which share common ontologies and data structures defined at Mouse Phenotyping Experiment Template (http://semantic-json.org/item/ria108i).

7.4.1. Union of integrated databases

We view the first sample programs that generate a union of data fragment extracted from JMC and Europhenome databases. These programs implement clients that obtain a union of triples whose subjects are pages of folders ‘Cohort’ (http://semantic-json.org/item/cria109s4i) and ‘Group’ (http://semantic-json.org/item/cria110s4i) that denote groups of individual mice. Since these programs are big, we here introduce only a Java program below. To view programs in other languages, please download the archives including those programs.

Code 7.13 is a sample program implemented as the Java class 'jp.riken.base.scines.JSON.test.MousePenotypeIntegrationTest'.

package jp.riken.base.scines.JSON.test;

import jp.riken.base.scines.JSON.JSONClient;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class MousePhenotypeIntegrationTest {

   private final String[] defaultClassURIs = {"cria109s1i","cria110s1i"};
   private String serverReference = "http://semantic-json.org";
   private JSONClient jsonClient = null;
   private int limitNumOfInstances = 3;

   static public void main(String[] args) throws Exception{
      if( args.length > 2 ){
         String serviceRef = args[0];
         String command = args[1];
         String[] ids = new String[args.length-2];
         for( int i = 2; i < args.length; i++ ) {
            ids[i-2] = args[i];
         }
         MousePhenotypeIntegrationTest generator = new MousePhenotypeIntegrationTest(serviceRef);
         if( command.indexOf("c") >= 0 ) {
            generator.generateInstanceListByClasses(ids);
         }else{
            generator.generateInstanceList(ids);
         }
      }else{
         // Default operation
         MousePhenotypeIntegrationTest generator = new MousePhenotypeIntegrationTest("http://semantic-json.org");
         generator.generateInstanceListByClasses(new String[]{"cria109s4i","cria110s4i"});
      }
   }


   // Constructor: sets a server reference for a JSON client
   public MousePhenotypeIntegrationTest(String serverReference) {
      if( serverReference != null ){
         this.serverReference = serverReference;
      }
      jsonClient = new JSONClient(this.serverReference);
   }


   // Generate a list of records as lists of statements by specifying a list of class URIs
   public void generateInstanceListByClasses(String[] classURIs) throws Exception {
      if( classURIs == null ){
         classURIs = defaultClassURIs;
      }
      // Obtain a list of instances
      for( String classURI: classURIs){
         String className = jsonClient.invoke("name", "en", classURI, null).getString("name");
         System.out.println("Class: " + className + " (" + classURI + ")==============================");

         JSONObject[] instances = jsonClient.getJSONObjectList(jsonClient.invoke("instances", null, classURI, null));
         System.out.println(instances.length + " instances found. (limit: " + limitNumOfInstances + ")");
         int cnt = 0;
         for( JSONObject instance: instances ){
            String instanceID = instance.getString("ID");
            System.out.println(generateInstanceRecord(instanceID));
            cnt++;
            if( cnt >= limitNumOfInstances ){
               break;
            }
         }
      }
   }


   // Generate a list of records as lists of statements by specifying a list of instance URIs
   public void generateInstanceList(String[] instanceURIs) throws Exception{
      if( instanceURIs != null ){
         for( String instanceURI: instanceURIs){
            System.out.println(generateInstanceRecord(instanceURI));
            System.out.println();
         }
      }
   }


   // Generate a record as a list of statements by specifying an instance URI
   public String generateInstanceRecord(String instanceURI) throws Exception {
      // Obtain a list of statements
      String instanceName = jsonClient.invoke("name", "en", instanceURI, null).getString("name");

      JSONObject[] statements = jsonClient.getJSONObjectList(jsonClient.invoke("statements", null, instanceURI, null));
      StringBuffer sb = new StringBuffer();
      sb.append(instanceName);
      sb.append(" (");
      sb.append(instanceURI);
      sb.append(")\n");
      for( JSONObject statement: statements){
         String propertyURI = statement.getJSONObject("property").getString("ID");
         String propertyName = jsonClient.invoke("name", "en", propertyURI, null).getString("name");
         sb.append("\t ---");
         sb.append(propertyName);
         sb.append(" (");
         sb.append(propertyURI);
         sb.append(")---> ");
         if( statement.containsKey("literalDataType")){
            // literal
            String value = null;
            if( statement.getString("literalDataType").equals("xsd:string")){
               JSONArray array = statement.getJSONArray("object");
               for( int i = 0; i < array.size(); i++ ){
                  JSONObject obj = array.getJSONObject(i);
                  if( obj.getString("lang").equals("en")){
                     value = obj.getString("value");
                     break;
                  }
               }
            }else{
               JSONObject obj = statement.getJSONObject("object");
               value = obj.getString("value");
            }
            sb.append(value);
            sb.append(" (Literal)");
         }else{
            JSONObject object = statement.getJSONObject("object");
            String objectType = object.getString("dataType");
            if( objectType.equals("Instance") || objectType.equals("Class")){
               String objectID = object.getString("ID");
               String objectName = jsonClient.invoke("name", "en", objectID, null).getString("name");
               sb.append(objectName);
               sb.append(" (");
               sb.append(objectID);
               sb.append(")");
            }
         }
         sb.append("\n");
      }
      return sb.toString();
   }
}

Code 7.13. Sample program in Java of the class 'jp.riken.base.scines.JSON.test.MousePhenotypeIntegrationTest'. It implements a client that obtains a union of triples whose subjects are pages of folders ‘Cohort’ (http://semantic-json.org/item/cria109s4i/) and ‘Group’ (http://semantic-json.org/item/cria110s4i/) that denote groups of individual mice.

When the program is launched, the following result is obtained:


% java jp.riken.base.scines.JSON.test.MousePhenotypeIntegrationTest

Class: Cohort (cria109s4i)==============================
100 instances found. (limit: 3)
Clinical Chemistry-Creatine kinase-Tpm1 Het_female (cria109s4ria109u494i)
         ---Individual Organism (prib23s73i)---> M00045201 (baseline) (cria109s5ria109u1311i)
...
         ---phenotypic sex (prib23s79i)---> female (cria73s26ria73s1i)
         ---Genotype (prib23s87i)---> Tpm1 Het (cria73s69ria109u48i)
...
Class: Cohort (cria110s4i)==============================
10 instances found. (limit: 3)
B6;D2-Polg_homo_female+male (cria110s4ria110s10i)
         ---by Whom (prib23s56i)---> Technology and Develoment Team for Mouse Phenotype Analysis: Japan Mouse Clinic (crib140u2rib140u455i)
         ---has_body part (prib23s71i)---> whole body of B6;D2-Polg< Rgsc625/Rgsc625 > female and male (cria90s35ria90s2i)
         ---Individual Organism (prib23s73i)---> 0000064009 (cria110s5ria110s9i)
...
         ---Genotype (prib23s87i)---> Polg (Rgsc625/Rgsc625) (cria73s69ria73s2i)
...

Figure 7.13. Sample operation of launching the Java program 'jp.riken.base.scines.JSON.test.MousePhenotypeIntegrationTest' and the result.

7.4.2. Inference on Genotype

The sample programs introduced here change the data schema by performing inferences on Genotype information. A genotype is obtained from annotation of Phenotype Data by following a folder path ‘Annotation of Phenotype Data’ → ‘Attribute’ → ‘Entity’ → ‘Genotype’ as shown in Fig. 7.14. We define a novel property ‘inferred Genotype’ that directly connects from ‘Annotation of Phenotype Data’ to ‘Genotype’ as a result of inference on the folder path. Since these programs are big, we here introduce only a Java program below. To view programs in other languages, please download the archives including those programs.


Figure 7.14.  The definition of inferred property called 'inferred Genotype'.



Code 7.14 is a sample program implemented as the Java class 'jp.riken.base.scines.JSON.test.GenotypeInference'.

package jp.riken.base.scines.JSON.test;

import java.util.ArrayList;
import jp.riken.base.scines.JSON.JSONClient;
import net.sf.json.JSONObject;

public class GenotypeInference {

   private String serverReference = "http://semantic-json.org";
   private JSONClient jsonClient = null;
   private String measuredTraitPropertyURI = "prib23s58i";
   private String inheresInPropertyURI = "prib23s96i";
   private String genotypePropertyURI = "prib23s87i";

   public static void main(String args[]) throws Exception {
      if (args.length != 2) {
         args = new String[] { "http://semantic-json.org", "cria110s1ria110s188i" };
      }
      GenotypeInference ig = new GenotypeInference(args[0]);
      ig.inferenceGenotype(args[1]);
   }

   public GenotypeInference(String serverReference) {
      if (serverReference != null) {
         this.serverReference = serverReference;
      }
      jsonClient = new JSONClient(this.serverReference);
   }

   public void inferenceGenotype(String instanceURI) throws Exception {
      // Obtain a name of instance specified by instanceURI
      String instanceName = jsonClient.invoke("name", "en", instanceURI, null).getString("name");

      // Obtain property names
      String measuredTraitPropertyName = jsonClient.invoke("name", "en", measuredTraitPropertyURI, null).getString("name");
      String inheresInPropertyName = jsonClient.invoke("name", "en", inheresInPropertyURI, null).getString("name");
      String genotypePropertyName = jsonClient.invoke("name", "en", genotypePropertyURI, null).getString("name");

      int count = 1;
      JSONObject[] morphologyObjects = getObjects(instanceURI, measuredTraitPropertyURI);
      for (JSONObject morphologyObject : morphologyObjects) {
         String morphologyObjectName = jsonClient.invoke("name", "en", morphologyObject.getString("ID"), null).getString("name");
         JSONObject[] tailObjects = getObjects(morphologyObject.getString("ID"), inheresInPropertyURI);
         for (JSONObject tailObject : tailObjects) {
            String tailObjectName = jsonClient.invoke("name", "en", tailObject.getString("ID"), null).getString("name");
            JSONObject[] genotypeObjects = getObjects(tailObject.getString("ID"), genotypePropertyURI);
            for (JSONObject genotypeObject : genotypeObjects) {
               String genotypeObjectName = jsonClient.invoke("name", "en", genotypeObject.getString("ID"), null).getString("name");

               StringBuffer sb = new StringBuffer();
               sb.append("Inference(");
               sb.append(count);
               count++;
               sb.append(")==================================================================\n");
               sb.append(instanceName);
               sb.append("(");
               sb.append(instanceURI);
               sb.append(")\n");
               // property: measured Trait
               sb.append("\t --- ");
               sb.append(measuredTraitPropertyName);
               sb.append("(");
               sb.append(measuredTraitPropertyURI);
               sb.append(") ---> ");
               sb.append(morphologyObjectName);
               sb.append("(");
               sb.append(morphologyObject.getString("ID"));
               sb.append(")\n");
               // property: inheres In
               sb.append("\t --- ");
               sb.append(inheresInPropertyName);
               sb.append("(");
               sb.append(inheresInPropertyURI);
               sb.append(") ---> ");
               sb.append(tailObjectName);
               sb.append("(");
               sb.append(tailObject.getString("ID"));
               sb.append(")\n");
               // property: genotype
               sb.append("\t --- ");
               sb.append(genotypePropertyName);
               sb.append("(");
               sb.append(genotypePropertyURI);
               sb.append(") ---> ");
               sb.append(genotypeObjectName);
               sb.append("(");
               sb.append(genotypeObject.getString("ID"));
               sb.append(")\n");
               // print the inferred property: inferred genotype
               sb.append("Inferred Property--------------------------------------------------------------\n");
               sb.append(instanceName);
               sb.append("(");
               sb.append(instanceURI);
               sb.append(")\n");
               sb.append("\t --- inferred genotype ---> ");
               sb.append(genotypeObjectName);
               sb.append("(");
               sb.append(genotypeObject.getString("ID"));
               sb.append(")\n===============================================================================\n");
               System.out.println(sb.toString());
            }
         }
      }
   }

   // Obtain a list objects of statements whose subjects are specified by the given instanceURI and properties are specified by the given propertyURI
   private JSONObject[] getObjects(String instanceURI, String propertyURI)
         throws Exception {
      JSONObject[] statements = jsonClient.getJSONObjectList(jsonClient.invoke("statements", null, instanceURI, null));
      ArrayList results = new ArrayList();
      for (JSONObject statement : statements) {
         String propURI = statement.getJSONObject("property").getString("ID");
         if (propURI.equals(propertyURI)
               && !statement.containsKey("literalDataType")) {
            JSONObject obj = statement.getJSONObject("object");
            String objectType = obj.getString("dataType");
            if (objectType.equals("Instance") || objectType.equals("Class")) {
               results.add(obj);
            }
         }
      }
      return results.toArray(new JSONObject[0]);
   }

}

Code 7.14. Sample program in Java of the class 'jp.riken.base.scines.JSON.test.GenotypeInference'. It implements a client that obtains a page path ‘Ano_SHQ34_hom_M’ (folder ‘Annotation of Phenotype Data’) → ‘tail morphology of B6;D2-Polg <Rgsc625/Rgsc625> male’ (folder ‘Attribute’) → ‘tail of B6;D2-Polg <Rgsc625/Rgsc625> male’ (folder ‘Entity’) → ‘Polg (Rgsc625/Rgsc625)’ (folder ‘Genotype’), and defines an inferred property ‘inferred genotype’ that directly connects ‘Ano_SHQ34_hom_M’ and ‘Polg (Rgsc625/Rgsc625)’.

When the program is launched, the following result is obtained:


% java jp.riken.base.scines.JSON.test.GenotypeInference

Inference(1)==================================================================
Ano_SHQ34_hom_M(cria110s1ria110s188i)
         --- Measured trait(prib23s58i) ---> tail morphology of B6;D2-Polg< Rgsc625/Rgsc625 > male(cria73s63ria73s13i)
         --- inheres in(prib23s96i) ---> tail of B6;D2-Polg< Rgsc625/Rgsc625 > male(cria90s2ria90s1i)
         --- Genotype(prib23s87i) ---> Polg (Rgsc625/Rgsc625)(cria73s69ria73s2i)
Inferred Property--------------------------------------------------------------
Ano_SHQ34_hom_M(cria110s1ria110s188i)
         --- inferred genotype ---> Polg (Rgsc625/Rgsc625)(cria73s69ria73s2i)
===============================================================================

Figure 7.15. Sample operation of launching the Java program 'jp.riken.base.scines.JSON.test.GenotypeInference' and the result.

8. Applications

8.1. Ontology Tree Viewer

Ontologies developed for life-sciences, such as Gene Ontology and Plant Ontology, are introduced in SciNetS. Using Semantic-JSON, a graphical user interface that traverses ontology terms in a tree format is implemented and deployed into SciNetS as a web application.


Figure 8.1. A sample view of Plant Ontology term named 'seeding growth' specified by URI http://scinets.org/sw/wiki/en/cria130u7131i.

Figure 8.1. shows a sample view of Plant Ontology (PO) term named 'seediling growth' identidifed by URI http://scinets.org/sw/wiki/en/cria130u7131i. In this example of tree view, the starting node is a PO term 'seeding growth PO:0007131'. All ancestor nodes of the starting node are obtained by recursively calling Semantic-JSON commands 'superClasses' for is_a relationship and 'reverseStatements' for other relationships. In the same way, child nodes of the starting are obtained by calling Semantic-JSON commands 'subClasses' for is_a relationship and 'statements' for other relationships.

8.2. JavaScript programming environment at SciNetS

SciNetS implements a graphical user interface to develop JavaScript programs that access to the Semantic Web data via Semantic-JSON.


Figure 8.2. Snapshot of the graphical user interface of JavaScript programming environment.(This environment requires log-on.)

Figure 8.2. is a snapshot of the graphical user interface. The interface contains a JavaScript program editor, a result monitoring panel and a logger console. A user writes a JavaScript program that calls functions defined in the SciNetS JavaScript Library. The library is developed using Semantic-JSON, and functionalities of logging and displaying the resultant strings are additionally implemented. The result monitoring panel allows a user to print strings qualified with HTML tags via the user’s program. The logger console displays resultant states of Semantic-JSON command calls, and controls execution flow of the user’s program.