Rapid prototyping of a read-only Lims using JSON and Apache Velocity.
In a previous post, I showed how to use the Apache Velocity template engine to format JSON data.
Since that post, I've moved my application to a github repository: https://github.com/lindenb/jsvelocity. The project contains a java-based standalone tool to process the JSON data.
Here is an example: The JSON data:
{ individuals:[ { name: "Riri", age: 8, duck: true }, { name: "Fifi", age: 9, duck: true }, { name: "Loulou", age: 10, duck: true } ] }.... and the velocity template:
#foreach($indi in ${all.individuals}) <h1>${indi['name']}</h1> Age:${indi.age}<br/>${indi.duck} #end... with the following command line ...
$ java -jar dist/jsvelocity.jar \ -f all test.json \ test.vm... produces the following output ...
<h1>Riri</h1> Age:8<br/>true <h1>Fifi</h1> Age:9<br/>true <h1>Loulou</h1> Age:10<br/>true
Today I wrote a web version of the tool using the jetty server. I wanted to quickly write a web interface to display various summaries for our NGS experiments.
My JSON input looks like this:
{ "sequencer":[ { "name":"HiSeq" }, { "name":"MiSeq" } ], "run":[ { "sequencer":"HiSeq", "flowcell":"C2AVTACXX", "name":"131010_C2AVTACXX_61", "date":"2013-10-10", "comment":"A comment", "samples":[ { "name":"CD0001", "meancov": 10 }, { "name":"CD0002", "meancov": 20.0 } , { "name":"CD0003", "meancov": 30.0 } ] }, { "sequencer":"MiSeq", "flowcell":"C3VATACYY", "name":"131011_C3VATACYY_62", "date":"2013-10-11", "comment":"Another comment", "samples":[ { "name":"CD0001", "meancov": 11 }, { "name":"CD0006", "meancov": 21.0 } , { "name":"CD0008", "meancov": null } ] }, { "sequencer":"MiSeq", "flowcell":"C4VATACYZ", "name":"131012_C4VATACYZ_63", "date":"2013-10-12", "comment":"Another comment", "samples":[ { "name":"CD0010", "meancov":1, "comment":"Failed, please, re-sequence" } ] } ], "samples":[ { "name":"CD0001" }, { "name":"CD0002" }, { "name":"CD0003" }, { "name":"CD0004" }, { "name":"CD0005" }, { "name":"CD0006" }, { "name":"CD0007" }, { "name":"CD0008" }, { "name":"CD0009" }, { "name":"CD0010" } ], "projects":[ { "name":"Disease1", "description": "sequencing Project 1", "samples":["CD0001","CD0002","CD0006","CD0009"] }, { "name":"Disease2", "description": "sequencing Project 2", "samples":["CD0002","CD0003","CD0008","CD0009"] } ] }One velocity template is used to browse this 'database': https://github.com/lindenb/jsvelocity/blob/master/src/test/resources/velocity/lims.vm.
The server is started like:
java -jar dist/webjsvelocity.jar \ -F lims src/test/resources/json/lims.json \ src/test/resources/velocity/lims.vm 2013-10-17 12:43:35.566:INFO:oejs.Server:main: jetty-9.1.0.M0 2013-10-17 12:43:35.602:INFO:oejs.ServerConnector:main: Started ServerConnector@72dcb6{HTTP/1.1}{0.0.0.0:8080} (...)And here is a screenshot of the result:
That's it,
Pierre
No comments:
Post a Comment