=HEADER
<% require 'json' %>
{
    "HEADER": {
	"options":<%= options.to_h.to_json %>,
	"files": <%= ARGV %>,
	"version": "<%= BIOVCF_VERSION %>"
    },
    "COLUMNS": <%= header.column_names.to_json %>,
    "META": <%= header.meta.to_json %>,
    "BODY": [
=BODY
	<% sample_num = 0
	sample_name = nil
	sample_size = header.samples.size
	%>
	{
	    "seq:chr": "<%= rec.chrom %>" ,
	    "seq:pos": <%= rec.pos %> ,
	    "seq:ref": "<%= rec.ref %>" ,
	    "seq:alt": "<%= rec.alt[0] %>"
	    <% if rec.info.dp %> , "dp": <%= rec.info.dp %> <% end %>,
	    "samples" : {
		<% rec.each_sample do |s| %>
		<% if not s.empty? 
		sample_name = header.samples[sample_num]
		%>
		<%= (sample_num!=0 ? "," : "" ) %>
		<% sample_num += 1%>
		"<%= sample_name %>": {
		    <% header.meta['FORMAT'].each_key do |k| %>
		    "<%= k %>": <%= s[k].to_json %><%= (k==header.meta['FORMAT'].keys.last ? "" : "," ) %>
		    <% end %>
		}
		<% end %>
		<% end %>
	    }
	},
=FOOTER
    ]
}
