pyworkflow.protocol.params module

class pyworkflow.protocol.params.BooleanParam(display=1, **args)[source]

Bases: Param

Param to store boolean values. By default it will be displayed as 2 radio buttons with Yes/no labels. Alternatively, if you pass checkbox it will be displayed as a checkbox.

Parameters

display – (Optional) default DISPLAY_YES_NO. (Yes /no) Alternatively use BooleanParam.DISPLAY_CHECKBOX to use checkboxes

DISPLAY_CHECKBOX = 2
DISPLAY_YES_NO = 1
class pyworkflow.protocol.params.Conditional(error, allowsNull=False)[source]

Bases: Validator

Simple validation based on a condition. If the value doesn’t meet the condition, the error will be returned.

class pyworkflow.protocol.params.DeprecatedParam(newParamName, prot)[source]

Bases: object

Deprecated param. To be used when you want to rename an existing param and still be able to recover old param value. It acts like a redirector, passing the value received when its value is set to the new renamed parameter

usage: In defineParams method, before the renamed param definition line add the following:

self.oldName = DeprecatedParam(“newName”, self) form.addParam(‘newName’, …)

Parameters
  • newParamName – Name of the renamed param

  • prot – Protocol hosting this and the renamed param

getObjValue()[source]
isPointer()[source]
set(value, cleanExtended=False)[source]
class pyworkflow.protocol.params.DigFreqParam(**args)[source]

Bases: FloatParam

Digital frequency param.

class pyworkflow.protocol.params.ElementGroup(form=None, **args)[source]

Bases: FormElement

Class to group some params in the form. Such as: Labeled group or params in the same line.

addHidden(paramName, ParamClass, **kwargs)[source]

Add a hidden parameter to be used in conditions.

addLine(lineName, **kwargs)[source]
addParam(paramName, ParamClass, **kwargs)[source]

Add a new param to the group

iterParams()[source]

Return key and param for every child param.

class pyworkflow.protocol.params.EnumParam(**args)[source]

Bases: IntParam

Select from a list of values, separated by comma

DISPLAY_COMBO = 1
DISPLAY_HLIST = 2
DISPLAY_LIST = 0
class pyworkflow.protocol.params.FileParam(**args)[source]

Bases: PathParam

Filename path

class pyworkflow.protocol.params.FloatParam(**args)[source]

Bases: Param

class pyworkflow.protocol.params.FolderParam(**args)[source]

Bases: PathParam

Folder path

class pyworkflow.protocol.params.Form(protocol)[source]

Bases: object

Store all sections and parameters

Build a Form from a given protocol.

addBooleanParam(name, label, help, default=True, **kwargs)[source]
addGeneralSection()[source]
addGroup(*args, **kwargs)[source]
addHidden(*args, **kwargs)[source]
addLine(*args, **kwargs)[source]
addParallelSection(threads=1, mpi=8, condition='', hours=72, jobsize=0)[source]
Adds the parallelization section to the form

pass threads=0 to disable threads parameter and mpi=0 to disable mpi params

Parameters
  • threads – default value for of threads, defaults to 1

  • mpi – default value for mpi, defaults to 8

addParam(*args, **kwargs)[source]

Add a new param to last section

addSection(label='', **kwargs)[source]

Add a new section

evalParamCondition(paramName)[source]

Evaluate if a condition is True for a give param with the values of a particular Protocol

getClass()[source]
getParam(paramName)[source]

Retrieve a param given a the param name None is returned if not found

getSection(label)[source]

get section by label from _sectionList

hasParam(paramName)[source]
iterAllParams()[source]

Iter all parameters, including ElementGroups.

iterParams()[source]

Iter parameters disregarding the ElementGroups.

iterPointerParams()[source]
iterSections()[source]
registerParam(paramName, param)[source]

Register a given param in the form.

validateParams(protocol)[source]

Check that all validations of the params in the form are met for the protocol param values. It will return a list with errors, just in the same way of the Protocol.validate function

class pyworkflow.protocol.params.FormElement(**args)[source]

Bases: Object

Base for any element on the form

ATTRIBUTES = ['label', 'expertLevel', 'condition', 'important', 'help', 'default', 'paramClass']
config(**kwargs)[source]

Configure the object and set attributes coming in the keyword-arguments, the same as in the __init__

getHelp()[source]
getLabel()[source]
hasCondition()[source]
isExpert()[source]
isImportant()[source]
setExpert()[source]
setImportant(value)[source]
class pyworkflow.protocol.params.Format(valueType, error='Value have not a correct format', allowsNull=False)[source]

Bases: Conditional

Check if the format is right.

class pyworkflow.protocol.params.GE(thresold, error='Value should be greater or equal than the threshold')[source]

Bases: Conditional

class pyworkflow.protocol.params.GT(threshold, error='Value should be greater than the threshold')[source]

Bases: Conditional

class pyworkflow.protocol.params.Group(form=None, **args)[source]

Bases: ElementGroup

Group some parameters with a labeled frame.

class pyworkflow.protocol.params.HiddenBooleanParam(**args)[source]

Bases: BooleanParam

class pyworkflow.protocol.params.IntParam(**args)[source]

Bases: Param

class pyworkflow.protocol.params.LE(threshold, error='Value should be less or equal than the threshold')[source]

Bases: Conditional

class pyworkflow.protocol.params.LT(threshold, error='Value should be less than the threshold')[source]

Bases: Conditional

class pyworkflow.protocol.params.LabelParam(**args)[source]

Bases: StringParam

Just the same as StringParam, but to be rendered as a label and can not be directly edited by the user in the Protocol Form.

class pyworkflow.protocol.params.Line(form=None, **args)[source]

Bases: ElementGroup

Group to put some parameters in the same line.

class pyworkflow.protocol.params.MultiPointerParam(**args)[source]

Bases: PointerParam

This type of Param will serve to select objects with DIFFERENT types from the database to be input for some protocol.

class pyworkflow.protocol.params.NonEmptyBoolCondition(error='Boolean param needs to be set.')[source]

Bases: Conditional

class pyworkflow.protocol.params.NonEmptyCondition(error='Value cannot be empty')[source]

Bases: Conditional

class pyworkflow.protocol.params.NumericListParam(**args)[source]

Bases: StringParam

This class will serve to have list representations as strings. Possible notation are: 1000 10 1 1 -> to define a list with 4 values [1000, 10, 1, 1], or 10x2 5x3 -> to define a list with 5 values [10, 10, 5, 5, 5] If you ask for more elements than in the list, the last one is repeated

class pyworkflow.protocol.params.NumericListValidator(error='Incorrect format for numeric list param')[source]

Bases: Conditional

Validator for ListParam. See ListParam.

class pyworkflow.protocol.params.NumericRangeParam(**args)[source]

Bases: StringParam

This class will serve to specify range of numbers with a string representation. Possible notation are:

"1,5-8,10" -> [1,5,6,7,8,10]
"2,6,9-11" -> [2,6,9,10,11]
"2 5, 6-8" -> [2,5,6,7,8]
class pyworkflow.protocol.params.NumericRangeValidator(error='Incorrect format for numeric range param')[source]

Bases: Conditional

Validator for RangeParam. See RangeParam.

class pyworkflow.protocol.params.Param(**args)[source]

Bases: FormElement

Definition of a protocol parameter

addValidator(validator)[source]

Validators should be callables that receive a value and return a list of errors if so. If everything is ok, the result should be an empty list.

getDefault()[source]
setDefault(newDefault)[source]
validate(value)[source]
class pyworkflow.protocol.params.PathParam(**args)[source]

Bases: StringParam

Param for path strings

class pyworkflow.protocol.params.PointerParam(paramClass=<class 'pyworkflow.object.Pointer'>, **args)[source]

Bases: Param

This type of Param will serve to select existing objects in the database that will be input for some protocol.

setPointerClass(newPointerClass)[source]
class pyworkflow.protocol.params.ProtocolClassParam(**args)[source]

Bases: StringParam

class pyworkflow.protocol.params.Range(minValue, maxValue, error='Value is outside range')[source]

Bases: Conditional

class pyworkflow.protocol.params.RegexParam(**args)[source]

Bases: StringParam

Regex based string param

class pyworkflow.protocol.params.RelationParam(**args)[source]

Bases: Param

This type of Param is very similar to PointerParam, since it will hold a pointer to another object. But, in the PointerParam, we search for objects of some Class (maybe with some conditions). Here, we search for objects related to a given attribute of a protocol by a given relation.

getAttributeName()[source]
getDirection()[source]
getName()[source]
class pyworkflow.protocol.params.Section(form, **args)[source]

Bases: ElementGroup

Definition of a section to hold other params

addGroup(groupName, **kwargs)[source]
getQuestion()[source]

Return the question param

getQuestionName()[source]

Return the name of the question param.

hasQuestion()[source]

Return True if a question param was set

class pyworkflow.protocol.params.StringParam(**args)[source]

Bases: Param

Param with underlying String value

class pyworkflow.protocol.params.TextParam(**args)[source]

Bases: StringParam

Long string params

class pyworkflow.protocol.params.TupleParam(**args)[source]

Bases: Param

This class will condense a tuple of several other params of the same type and related concept. For example: min and max, low and high.

class pyworkflow.protocol.params.Validator[source]

Bases: object