spang2 is a commmand-line SPARQL client implemented in JavaScript.
spang2 requires node (version >= 14).
node -v
If you have installed it, skip installation of node.
node on LinuxIf you do not have npm, install it.
sudo apt -y install npm
on Ubuntu, or
sudo yum -y install npm
on CentOS.
The defualt directories for installation of npm modules are under /usr/local/, which requires sudo.
You can change the directories as follows.
npm set prefix ~/.npm-global
The configuration is saved in ~/.npmrc, so you can also configure by editing it.
Install n to manage node version.
npm install -g n
n stable
node -v
node on MacIf you do not have brew, install it.
brew -v
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install nodebrew using brew.
brew install nodebrew
mkdir -p ~/.nodebrew/src
export PATH=$HOME/.nodebrew/current/bin:$PATH
Now you can use node. Check the version.
node -v
Download the source code from GitHub.
git clone https://github.com/sparqling/spang
Install by using npm command.
cd spang
npm install
npm link
For the help message, just type the command
spang2
npm test
$ cat messy.rq
SELECT * WHERE { ?s ?p ?o }
$ spfmt messy.rq
SELECT *
WHERE {
?s ?p ?o .
}
See: https://github.com/sparqling/sparql-formatter
An example web site:
https://spang.dbcls.jp/example_fmt.html
spfmt.js and use it in your HTML.<script src="/js/spfmt.js"></script>
spfmt.spfmt("SELECT * WHERE {?s ?p ?o}");
/*
SELECT *
WHERE {
?s ?p ?o .
}
*/
spfmt.js through the jsDelivr service. <textarea id="sparql-text" rows=5></textarea>
<button id="reformat-button">Reformat</button>
<textarea id="sparql-text-after" rows=5></textarea>
<script src="https://cdn.jsdelivr.net/gh/sparqling/spang@master/js/spfmt.js"></script>
<script type="text/javascript">
window.onload = () => {
var textArea =
document.querySelector("#reformat-button").addEventListener('click', (event) => {
document.querySelector("#sparql-text-after").value =
spfmt(document.querySelector("#sparql-text").value);
});
};
</script>
js/*.js should be updated for those who call spang functions through their Web applications.
js/spang.js should be updated after modifying codes.js/spfmt.js should be updated after modifying parser or formatter codes.Update the js/*.js by converting codes using browserify as follows.
npm run browserify
The EBNF notation of SPARQL is extracted from:
https://www.w3.org/TR/sparql11-query/#sparqlGrammar
The PEG expression of SPARQL grammer was originally provided by:
https://github.com/antoniogarrote/rdfstore-js/
PEG can be tested at:
https://pegjs.org/online
# @title Get orthololog from MBGD
# @author Hirokazu Chiba
# @tag ortholog
# @endpoint http://sparql.nibb.ac.jp/sparql
extension
# @prefixes https://
# @input_class id:Taxon
# @output_class up:Protein
# @param gene=
Content type
Image
Digest
sha256:0472bdac7…
Size
52.2 MB
Last updated
almost 2 years ago
docker pull sparqling/spang