agglovar.merge.config.stage

Intersect stage definitions.

Intersect strategies may include one or more steps, each performing a specific type of intersect task. Stages define the type and parameters for each of these steps.

Attributes

RESERVED_PARAM_NAMES

Reserved parameter names for each specification (ro, szro, etc).

TYPE_MATCHER

Recognized values for the val_type field of specification objects.

Classes

IntersectParamSpec

Parameter specification for defining legal parameters, their types, and ranges.

IntersectStage

A set of positional and/or named parameters describing an intersect stage.

IntersectStageDistance

Intersect by distance where distance is defined as the minimum of start or end position differences.

IntersectStageExact

Match on exact POS and END.

IntersectStageMatch

Parameter set: Matcher specification objects.

IntersectStageRo

Param set: Reciprocal overlap (RO).

Module Contents

class agglovar.merge.config.stage.IntersectParamSpec

Bases: object

Parameter specification for defining legal parameters, their types, and ranges.

Objects of this type are used to define legal parameters, their types, and ranges of values. This class provides functions for checking and enforcing parameter values so that configuration objects can use them safely, and error checking code is largely consolidated here.

If the value is a list, then each element inside the list is checked against the list type. If successful, then each element inside the list is checked against the minimum and maximum values, if set.

Variables:
  • name – Parameter name.

  • val_type – Type of value (e.g. “num”, “int”, “list”).

  • default – Default value if not specified.

  • min_val_tuple – Tuple of (minimum value, inclusive flag) or None.

  • max_val_tuple – Tuple of (maximum value, inclusive flag) or None.

  • unlimited_val – If “unlimited” is given, then set this value.

  • allow_unlimited – Whether unlimited values are allowed.

  • list_type – If not None, then this is a list of values and each element in the list must match this type. If None, then the value is not a list.

__post_init__() None

Post-initialization checks.

check(param_tuple: tuple) Any

Take a parameter tuple in the form (type, value, name) and check it against the specification.

Parameters:

param_tuple – Tuple containing (type, value, name) to check.

Returns:

The value of the object after checking (i.e. the value extracted from param_tuple).

allow_unlimited: bool | None = True
default: Any
property has_max_val: bool

Determine if a maximum value is set.

property has_min_val: bool

Determine if a minimum value is set.

list_type: str | None = None
property max_inclusive: bool

Determine if maximum value is inclusive in the range, False if exclusive (None if not defined).

property max_val: Any

Get the maximum value (None if not defined).

max_val_tuple: tuple[Any, bool] | None = None
property min_inclusive: bool

Determine if minimum value is inclusive in the range, False if exclusive (None if not defined).

property min_val: Any

Get the minimum value (None if not defined).

min_val_tuple: tuple[Any, bool] | None = None
name: str
unlimited_val: Any | None = None
val_type: str
class agglovar.merge.config.stage.IntersectStage(spec_type: str, arg_list: list[tuple[str, Any, str]] | None, intersect_strategy: agglovar.merge.config.strategy.IntersectStrategy, param_spec_list: list[IntersectParamSpec] | None, allow_match_stage: bool = True)

Bases: object

A set of positional and/or named parameters describing an intersect stage.

Variables:
  • spec_type – String describing the specification type (e.g. “nr”, etc).

  • arg_list – List of actual arguments used to create this spec. Each element is a tuple of (type, value, name) extracted from the parameter specification string during parsing.

  • intersect_strategy – Link to the IntersectStrategy object creating this step. This is used to query the intersect configuration for global parameters and a global matcher.

  • param_spec_list – List of parameter specifications describing the parameters this specification can take, their types, ranges, and default values.

  • match_stage – Match stage, if set.

  • allow_match_stage – True if this specification allows a sequence match stage.

__repr__(show_match_stage: bool = True) str

Get a string representation for this intersect specification.

Parameters:

show_match_stage – If True, show the match stage parameters.

Returns:

String representation.

get_matcher() agglovar.seqmatch.MatchScoreModel | None

Get the matcher object for this intersect spec.

If a matcher is set for this spec, it is returned. If not, a global matcher is returned if set. If neither, None is returned.

Returns:

Matcher object or None.

set_match_stage(match_stage: IntersectStageMatch | None = None) None

Set the match stage on this object.

Parameters:

match_stage – Match stage or None to clear.

allow_match_stage: bool
arg_list: list[tuple[str, Any, str]]
col_alt = False
col_ref = False
intersect_strategy: agglovar.merge.config.strategy.IntersectStrategy
match_stage: IntersectStageMatch | None
param_spec_list: list[IntersectParamSpec]
read_seq = None
spec_type: str
vcf_temp = False
class agglovar.merge.config.stage.IntersectStageDistance(arg_list, intersect_strategy)

Bases: IntersectStage

Intersect by distance where distance is defined as the minimum of start or end position differences.

Distance is calculated as: min(abs(pos_l - pos_r), abs(end_l - end_r))

At least one of dist or szdist must be set.

Parameters:
  • dist – Distance threshold.

  • szdist – Distance threshold for SVs with size less than szdist.

  • szro – RO threshold for SVs with size less than szdist.

  • alt – Include ALT calls in intersect.

  • ref – Include REF calls in intersect.

alt: bool
dist: int
ref: bool
szdist: float | None
szro: float | None
class agglovar.merge.config.stage.IntersectStageExact(arg_list: list[tuple[str, Any, str]], intersect_strategy: agglovar.merge.config.strategy.IntersectStrategy)

Bases: IntersectStage

Match on exact POS and END.

Parameters:
  • alt – Match on ALT.

  • ref – Match on REF.

alt: bool
ref: bool
class agglovar.merge.config.stage.IntersectStageMatch(arg_list: list[tuple[str, Any, str]], intersect_strategy: agglovar.merge.config.strategy.IntersectStrategy)

Bases: IntersectStage

Parameter set: Matcher specification objects.

Variables:
  • score – Minimum score proportion for intersects.

  • match – Match score.

  • mismatch – Mismatch score.

  • gap – List of gap scores. Must contain an even number of values where each pair of values is a gap-open and gap-extend score. This is a flat list, not a list of tuples, although pairs of values are packaged as tuples when creating the match object.

  • limit – Maximum number of matches.

  • ksize – Size of k-mer to use.

  • matcher – Matcher object configured with the above parameters.

gap: list[float]
ksize: int
limit: int
match: float
matcher: agglovar.seqmatch.MatchScoreModel | None
mismatch: float
score: float
class agglovar.merge.config.stage.IntersectStageRo(arg_list: list[tuple[str, Any, str]], intersect_strategy: agglovar.merge.config.strategy.IntersectStrategy)

Bases: IntersectStage

Param set: Reciprocal overlap (RO).

Classic RO definition. For insertions, the END position is POS + SVLEN for RO computation (does not affect merged calls, END is still POS + 1 for INS after intersects).

agglovar.merge.config.stage.RESERVED_PARAM_NAMES: frozenset[str]

Reserved parameter names for each specification (ro, szro, etc).

These are fields used by the parameter object and no parameter arguments are allowed to have the same names.

agglovar.merge.config.stage.TYPE_MATCHER: Mapping[str, set[str]]

Recognized values for the val_type field of specification objects.

Maps val_type strings to sets of types they may match. For example, “num” type can accept a float or int value, but not unlimited. In many cases, float is assumed, but an int is allowed to convert to a float so specifications don’t have to require float-like input (e.g. “2” is converted to “2.0”).