trackhub.parsed_params.Param

digraph inheritancecc27fbbc05 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "trackhub.validate.Param" [URL="#trackhub.parsed_params.Param",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }
class trackhub.parsed_params.Param(name, fmt, types, required, validator, min_bed_fields=None)[source]

Bases: object

Parameters:
  • name (str) – Name of the parameter

  • fmt (list) – List of strings parsed from the “format” section of the spec from UCSC. Mostly used as an informal guide to the format.

  • types (list) – List of track types this parameter applies to

  • required (bool or list) – If True, all tracks must have it. If list, only those types must have it.

  • validator (callable, set, or type) – Validation to run on user-provided values. If callable, must return True if the value passes. If set, validation will pass if the value is in the provided set.

  • min_bed_fields (int) – Some parameters only work for a certain number of BED fields. Specify that here.

Examples

>>> Param(name='test', fmt=['test <#>'], types=['bigBed'], required=False, validator=int).validate(999)
True
>>> Param(name='test', fmt=['test <#>'], types=['bigBed'], required=False, validator=int).validate('999')
True
>>> Param(name='test', fmt=['test <#>'], types=['bigBed'], required=False, validator=int).validate(0)
True

Methods

__init__(name, fmt, types, required, validator)

param name:

Name of the parameter

validate(value)

__init__(name, fmt, types, required, validator, min_bed_fields=None)[source]
Parameters:
  • name (str) – Name of the parameter

  • fmt (list) – List of strings parsed from the “format” section of the spec from UCSC. Mostly used as an informal guide to the format.

  • types (list) – List of track types this parameter applies to

  • required (bool or list) – If True, all tracks must have it. If list, only those types must have it.

  • validator (callable, set, or type) – Validation to run on user-provided values. If callable, must return True if the value passes. If set, validation will pass if the value is in the provided set.

  • min_bed_fields (int) – Some parameters only work for a certain number of BED fields. Specify that here.

Examples

>>> Param(name='test', fmt=['test <#>'], types=['bigBed'], required=False, validator=int).validate(999)
True
>>> Param(name='test', fmt=['test <#>'], types=['bigBed'], required=False, validator=int).validate('999')
True
>>> Param(name='test', fmt=['test <#>'], types=['bigBed'], required=False, validator=int).validate(0)
True