'use strict';

var multi = require('./multi');
var parsePos = require('./parsePos');

var fieldTypeSelector = x => x.fieldType;
var columnFieldTypeSelector = x => x.column.fieldType;
var annotationSelector = ({fields, refGene}) =>
	parsePos(fields[0]) ? 'chrom' : (refGene ? 'gene' : null);

var widget = {
	cmp: multi(fieldTypeSelector),
	index: multi(x => x),
	transform: multi(fieldTypeSelector),
	avg: multi(fieldTypeSelector),
	download: multi(columnFieldTypeSelector),
    specialDownload: multi(columnFieldTypeSelector),
	column: multi(columnFieldTypeSelector),
	legend: multi(columnFieldTypeSelector),
	pdf: multi(fieldTypeSelector),
	annotation: multi(annotationSelector)
};

widget.index.dflt = () => null;
widget.avg.dflt = () => null;
widget.annotation.dflt = () => null;

module.exports = widget;

'use strict';

var multi = require('./multi');
var parsePos = require('./parsePos');

var fieldTypeSelector = x => x.fieldType;
var columnFieldTypeSelector = x => x.column.fieldType;

// XXX check for null field[0] is an odd artifact of denseMatrix transform which
// overwrites fields with probes, if the server returns probes. If a gene is not
// recognized, the probe list is empty. Needs a better semantics.
var annotationSelector = ({fields, refGene}) =>
	parsePos(fields[0] || '') ? 'chrom' : (refGene ? 'gene' : null);

var widget = {
	cmp: multi(fieldTypeSelector),
	index: multi(x => x),
	transform: multi(fieldTypeSelector),
	avg: multi(fieldTypeSelector),
	download: multi(columnFieldTypeSelector),
    specialDownload: multi(columnFieldTypeSelector),
	column: multi(columnFieldTypeSelector),
	legend: multi(columnFieldTypeSelector),
	pdf: multi(fieldTypeSelector),
	annotation: multi(annotationSelector)
};

widget.index.dflt = () => null;
widget.avg.dflt = () => null;
widget.annotation.dflt = () => null;

module.exports = widget;

Handle unknown gene in dense matrix.
Handle unknown gene in dense matrix.
