Registering a tool in the @ELIXIREurope regisry using XML, XSLT, JSON and curl. My notebook.

The Elixir Registry / pmid:26538599 "A portal to bioinformatics resources world-wide. With community support, the registry can become a standard for dissemination of information about bioinformatics resources: we welcome everyone to join us in this common endeavour. The registry is freely available at https://bio.tools."
In this post, I will describe how I've used the bio.tools API to register some tools from jvarkit.Authenticate with your credentials
using curl, the 'bio.tools' service returns a authentication token.$ curl -s \
-H "Content-type: application/json" \
-X POST \
-d '{"username":"my-login@univ-nantes.fr","password":"password1234"}' \
https://bio.tools/api/auth/login |\
python -m json.tool
{
"token": "74dedea023dbad8ecda49ac57bb1074acd794f"
}Creating a JSON describing the tool.
The tool I'm goind to use is VCFhead. A very simple tool printing the first variants of a VCF file. In jvarkit I don't write the code parsing the arguments, everything is described using a XML file that is going to be processed with a XSTL stylesheet to generate an abstract java code handling the options, etc....xsltproc command2java VcfHead.xml > AbstractVcfHead.java
For VcfHead the XML descriptor is available here: https://github.com/lindenb/jvarkit/blob/master/src/main/java/com/github/lindenb/jvarkit/tools/misc/VcfHead.xml.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app xmlns="http://github.com/lindenb/jvarkit/" xmlns:h="http://www.w3.org/1999/xhtml" app="VcfHead" package="com.github.lindenb.jvarkit.tools.misc" >
<description>Print the first variants of a VCF.</description>
<input type="vcf"/>
<output type="vcf"/>
<options>
<option name="count" type="int" opt="n" longopt="count" min-inclusive="0" default="10">
<description>number of variants to be printed</description>
</option>
</options>
<documentation>
<h:h3>Example</h:h3>
(...)
</documentation>
</app>Using a first XSLT stylesheet https://github.com/lindenb/jvarkit/blob/master/src/main/resources/xsl/jsonxelixir.xsl, 'VcfHead.xml' is firstly converted to the 'infamous' JSONx (JSON+XML) format .
xsltproc jsonxelixir VcfHead.xml > VcfHead.jsonxThe JSONx file:
<?xml version="1.0"?>
<jsonx:object xmlns:jsonx="http://www.ibm.com/xmlns/prod/2009/jsonx" xmlns:c="http://github.com/lindenb/jvarkit/" xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://www.ibm.com/xmlns/prod/2009/jsonx">
<jsonx:string name="accessibility">Public</jsonx:string>
<jsonx:string name="affiliation">univ-nantes.fr</jsonx:string>
<jsonx:string name="cost">Free</jsonx:string>
<jsonx:array name="platform">
<jsonx:string>Linux</jsonx:string>
<jsonx:string>Mac</jsonx:string>
</jsonx:array>
<jsonx:string name="version">1.0</jsonx:string>
<jsonx:string name="homepage">https://github.com/lindenb/jvarkit/wiki/VcfHead</jsonx:string>
<jsonx:array name="function">
<jsonx:object>
<jsonx:array name="input">
<jsonx:object>
<jsonx:object name="dataType">
<jsonx:string name="term">File name</jsonx:string>
<jsonx:string name="uri">http://edamontology.org/data_1050</jsonx:string>
</jsonx:object>
<jsonx:array name="dataFormat">
<jsonx:object>
<jsonx:string name="term">VCF</jsonx:string>
<jsonx:string name="uri">http://edamontology.org/format_3016</jsonx:string>
</jsonx:object>
</jsonx:array>
</jsonx:object>
</jsonx:array>
<jsonx:array name="output">
<jsonx:object>
<jsonx:object name="dataType">
<jsonx:string name="term">File name</jsonx:string>
<jsonx:string name="uri">http://edamontology.org/data_1050</jsonx:string>
</jsonx:object>
<jsonx:string name="dataDescription">any format</jsonx:string>
<jsonx:array name="dataFormat">
<jsonx:object>
<jsonx:string name="term">VCF</jsonx:string>
<jsonx:string name="uri">http://edamontology.org/format_3016</jsonx:string>
</jsonx:object>
</jsonx:array>
</jsonx:object>
</jsonx:array>
<jsonx:array name="functionName">
<jsonx:object>
<jsonx:string name="term">Formatting</jsonx:string>
<jsonx:string name="uri">http://edamontology.org/operation_0335</jsonx:string>
</jsonx:object>
</jsonx:array>
<jsonx:string name="functionDescription">Print the first variants of a VCF.</jsonx:string>
</jsonx:object>
</jsonx:array>
<jsonx:string name="description">Print the first variants of a VCF.</jsonx:string>
<jsonx:object name="docs">
<jsonx:string name="docsTermsOfUse">https://opensource.org/licenses/MIT</jsonx:string>
<jsonx:string name="docsGithub">https://github.com/lindenb/jvarkit/wiki/VcfHead</jsonx:string>
<jsonx:string name="docsHome">https://github.com/lindenb/jvarkit/wiki/VcfHead</jsonx:string>
<jsonx:string name="docsCitationInstructions">https://github.com/lindenb/jvarkit/wiki/Citing</jsonx:string>
<jsonx:string name="docsDownloadSource">https://github.com/lindenb/jvarkit/archive/master.zip</jsonx:string>
<jsonx:string name="docsDownload">https://github.com/lindenb/jvarkit/archive/master.zip</jsonx:string>
</jsonx:object>
<jsonx:array name="collection">
<jsonx:string>jvarkit</jsonx:string>
</jsonx:array>
<jsonx:object name="credits">
<jsonx:array name="creditsInstitution">
<jsonx:string>Institut du Thorax, Nantes, France</jsonx:string>
</jsonx:array>
<jsonx:array name="creditsDeveloper">
<jsonx:string>Pierre Lindenbaum</jsonx:string>
</jsonx:array>
</jsonx:object>
<jsonx:array name="interface">
<jsonx:object>
<jsonx:string name="interfaceType">Command line</jsonx:string>
</jsonx:object>
</jsonx:array>
<jsonx:string name="name">VcfHead</jsonx:string>
<jsonx:array name="topic">
<jsonx:object>
<jsonx:string name="term">Omics</jsonx:string>
<jsonx:string name="uri">http://edamontology.org/topic_3391</jsonx:string>
</jsonx:object>
</jsonx:array>
<jsonx:string name="license">MIT License</jsonx:string>
<jsonx:array name="language">
<jsonx:string>Java</jsonx:string>
</jsonx:array>
<jsonx:array name="resourceType">
<jsonx:string>Tool</jsonx:string>
</jsonx:array>
<jsonx:string name="maturity">Stable</jsonx:string>
<jsonx:array name="contact">
<jsonx:object>
<jsonx:string name="contactURL">https://github.com/lindenb</jsonx:string>
<jsonx:string name="contactName">Pierre Lindenbaum</jsonx:string>
<jsonx:array name="contactRole">
<jsonx:string>Developer</jsonx:string>
<jsonx:string>Maintainer</jsonx:string>
<jsonx:string>Helpdesk</jsonx:string>
</jsonx:array>
</jsonx:object>
</jsonx:array>
<jsonx:object name="publications">
<jsonx:string name="publicationsPrimaryID">doi:10.6084/m9.figshare.1425030.v1</jsonx:string>
</jsonx:object>
</jsonx:object>Using another XSLT stylesheet jsonx2json.xsl, the JSONx is converted to a JSON file.
xsltproc jsonx2json.xsl VcfHead.jsonx > VcfHead.jsonthe JSON file:
{
"accessibility": "Public",
"affiliation": "univ-nantes.fr",
"collection": [
"jvarkit"
],
"contact": [
{
"contactName": "Pierre Lindenbaum",
"contactRole": [
"Developer",
"Maintainer",
"Helpdesk"
],
"contactURL": "https://github.com/lindenb"
}
],
"cost": "Free",
"credits": {
"creditsDeveloper": [
"Pierre Lindenbaum"
],
"creditsInstitution": [
"Institut du Thorax, Nantes, France"
]
},
"description": "Print the first variants of a VCF.",
"docs": {
"docsCitationInstructions": "https://github.com/lindenb/jvarkit/wiki/Citing",
"docsDownload": "https://github.com/lindenb/jvarkit/archive/master.zip",
"docsDownloadSource": "https://github.com/lindenb/jvarkit/archive/master.zip",
"docsGithub": "https://github.com/lindenb/jvarkit/wiki/VcfHead",
"docsHome": "https://github.com/lindenb/jvarkit/wiki/VcfHead",
"docsTermsOfUse": "https://opensource.org/licenses/MIT"
},
"function": [
{
"functionDescription": "Print the first variants of a VCF.",
"functionName": [
{
"term": "Formatting",
"uri": "http://edamontology.org/operation_0335"
}
],
"input": [
{
"dataFormat": [
{
"term": "VCF",
"uri": "http://edamontology.org/format_3016"
}
],
"dataType": {
"term": "File name",
"uri": "http://edamontology.org/data_1050"
}
}
],
"output": [
{
"dataDescription": "any format",
"dataFormat": [
{
"term": "VCF",
"uri": "http://edamontology.org/format_3016"
}
],
"dataType": {
"term": "File name",
"uri": "http://edamontology.org/data_1050"
}
}
]
}
],
"homepage": "https://github.com/lindenb/jvarkit/wiki/VcfHead",
"interface": [
{
"interfaceType": "Command line"
}
],
"language": [
"Java"
],
"license": "MIT License",
"maturity": "Stable",
"name": "VcfHead",
"platform": [
"Linux",
"Mac"
],
"publications": {
"publicationsPrimaryID": "doi:10.6084/m9.figshare.1425030.v1"
},
"resourceType": [
"Tool"
],
"topic": [
{
"term": "Omics",
"uri": "http://edamontology.org/topic_3391"
}
],
"version": "1.0"
}Registering the tool
Now we have the Token and the json descriptor we can add VcfHead to Elixir using curl:curl -H "Content-type: application/json" \ -H "Authorization: Token 74dedea023dbad8ecda49ac57bb1074acd794f" \ -X POST \ -d @path/to/VcfHead.json \ "https://bio.tools/api/tool" |\ python -m json.tooloutput:
{
"accessibility": "Public",
"additionDate": "2016-02-24T11:37:17.458Z",
"affiliation": "univ-nantes.fr",
"collection": [
"jvarkit"
],
"contact": [
{
"contactName": "Pierre Lindenbaum",
"contactRole": [
"Developer",
"Maintainer",
"Helpdesk"
],
"contactURL": "https://github.com/lindenb"
(...)
VCfhead is now visible from the Elixir Registry at https://bio.tools/tool/univ-nantes.fr/VcfHead/1.0.
That's it,
Pierre.

No comments:
Post a Comment