Native App Report Engine Improvements

We recently released improvements to our reporting engine for native apps that make it much easier to do some common tasks.  For those of you that are new to the “Native App Engine”, it’s comprised of three main developer components that allow a developer to package up any analytic workflow and publish it in the BaseSpace App store.  

Those three components are:

  1. Form Builder – Custom input form designer
  2. Docker – Linux container technology that your app runs in
  3. Report Builder – HTML 5 template engine

It’s the same toolset that we use internally to publish apps and we are constantly looking to make improvements based on internal and external feedback. 

Report Generation

report-editor-shot2

The reporting engine, which is essentially a html template engine,  is the last step in building a native app.  When your application finishes processing, we build a meta model around all the data that was produced and allow you to bind that to an html template.  We leverage an open source technology called Liquid which is a markup template engine used in lots of other companies with similar needs.  Along with some of the basic filters that are defined in liquid, we have extended the syntax to include BaseSpace specific needs.

New Features

Find Filter

XPath operator on XML files

  • Takes in an xpath expression and returns the resultant xml text

{{ statsFile | find: "/Statistics/Overall/Stats[SampleID='10002 - R1']/NumberOfClustersPF" }}

 

Stringify Improvements

Stringify is a custom filter that allows you to serialize contents of a drop, csv, or xml segment to JSON.

var globals = {}; 
globals.sample = {{ sample | stringify }};
globals.sample.chromosomes = {{ sample.chromosomes | stringify }};
globals.sample.statsByChromosome = {{ statsFile.parse.StatisticsResequencing.Samples.SampleStatistics | stringify }}; 

 

Custom Dictionary Filters

  • where.starts_with – returns the values where the dictionary key starts with provided string
  • where.ends_with – returns the values where the dictionary key starts with provided string
  • where.contains – returns the values where the dictionary key starts with provided string
  • first – returns the first value, errors if nothing there
  • first_or_default – returns the first value or default (usually null)
{% assign_object datafile1 = result.files.where.starts_with["datafile1"].first %}
{% assign_object anyXml = result.files.where.ends_with[".xml"].first_or_default %}
{% assign_object datafile3 = result.files.where.contains["file3"].first %}

 

Break and Continue Tags

Allows breaking and continuing in Liquid loops.

{% for file in files %}
	{% if file.href == null %}
		{% continue %}
	{% endif %}
	{% if file.href == 'http://special.com' %}
		{% assign specialHref = file.href %}
		{% break %}
	{% endif %}
{% endfor %}

 

Select Columns

Allows the selection of columns in a csv by column name or index. 

{% assign grid2 = result.files[key].select['0,1,2'].take[1].parse %}
{% assign grid3 = result.files[key].select['LastName','City','Phone'].take[5].parse %}

 

Take

Ability to take a subset of rows from a csv file.

{% assign grid2 = result.files[key].select['0,1,2'].take[1].parse %}
{% assign grid3 = result.files[key].select['LastName','City','Phone'].take[5].parse %}

 

ToArray

Ability to output csv data rows to a 2-dimensional data array.

{{ result.files[key].parse.to_array | stringify }}

 

Assign Improvements

Assign now allows assignment of any liquid object, not just primitives.

{% assign myFiles = result.files %}
{% assign myCsv = myFiles.where.ends_with[".csv"].first.select["0"].take[2].parse.to_array | stringify %}
{{ myCsv }}

 

Summary

We hope developers will leverage these new features to build great interactive reports.  If you want to learn more about native apps, then read our intro post, check out our developer portal, or follow our native app tutorial.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: