cradle.sdk.types.tasks.v2

   1from __future__ import annotations
   2
   3from enum import StrEnum
   4from typing import Annotated, Any, ClassVar, Literal
   5
   6from pydantic import BaseModel, Field
   7
   8from .common import (
   9    ArtifactParam,
  10    CustomPredictorParam,
  11    ParametersBase,
  12    ResultBase,
  13    TableResult,
  14    TableSourceLiteral,
  15    TableSourceQuery,
  16    TableSourceSnapshot,
  17    TableSourceTable,
  18    TableSourceTaskResult,
  19)
  20
  21
  22class OptimizationDirection(StrEnum):
  23    MAXIMIZE = "MAXIMIZE"
  24    MINIMIZE = "MINIMIZE"
  25
  26
  27class ScaleType(StrEnum):
  28    MULTIPLICATIVE = "MULTIPLICATIVE"
  29    ADDITIVE = "ADDITIVE"
  30    RANK = "RANK"
  31
  32
  33class AllowedMutation(BaseModel):
  34    in_range: RangeAnnotation = Field(
  35        description="The annotation expression defining the positions at which the amino acids listed in `amino_acids` can be used."
  36    )
  37    amino_acids: list[Annotated[str, Field(description="A single amino acid.")]]
  38
  39
  40class AnalyzeDataParameters(ParametersBase):
  41    """Parameters for the analyze.data task."""
  42
  43    task_type: ClassVar[str] = "analyze.data/v2"
  44
  45    dataset: (
  46        list
  47        | Annotated[
  48            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
  49            Field(discriminator="kind"),
  50        ]
  51    ) = Field(description="The data to analyze before training.")
  52    reference: MonomerAssembly | VhVlAssembly = Field(
  53        description="The reference assembly used for computing mutations."
  54    )
  55    assays: list[Assay] = Field(description="The assays present in the dataset.")
  56
  57
  58class AnalyzeDataResult(ResultBase):
  59    """Result of the analyze.data task."""
  60
  61    report: ArtifactParam = Field(description="The analysis report.")
  62
  63
  64class Assay(BaseModel):
  65    """Metadata of an assay."""
  66
  67    assay_id: str = Field(description="ID of the assay", min_length=1, max_length=124)
  68    name: str = Field(description="Human readable name of the assay", min_length=1, max_length=100)
  69    scale_type: ScaleType = Field(
  70        description="The scale type defines how the assay behaves.\n\n* **Additive**: Assay values are comparable in magnitude over batches, a delta of eg 5 in one batch is equivalent to 5 in another batch.\n* **Multiplicative**: Assay values are comparable over batches by applying a multiplication factor, eg fold improvement: `score_variantB_batch1 = factor(typically starting sequence score) * score_variantB_batch`.\n* **Rank**: Assay values are not comparable over batches, we can only assume the ranking within a batch is correct."
  71    )
  72    unit: str | None = Field(
  73        default=None, description="Unit of the assay - used for display purposes only", min_length=1, max_length=100
  74    )
  75
  76
  77class AssemblyFeature(BaseModel):
  78    ranges: dict[str, list[tuple[int, int]]] = Field(description="The ranges of the feature, keyed by polymer name")
  79    metadata: dict[str, str | int | float | bool] | None = Field(
  80        default=None, description="Optional metadata for the feature"
  81    )
  82
  83
  84class CombinatorialGenerator(BaseModel):
  85    """Combinatorial assembly generation from explicit mutation.
  86
  87    Systematically generates assemblies by combining allowed mutations up to a
  88    specified maximum number.
  89    """
  90
  91    type: Literal["COMBINATORIAL"] = Field(default="COMBINATORIAL")
  92    template: MonomerAssembly | VhVlAssembly = Field(
  93        description="The assembly that serves as template for generation, including any annotations to be used in `requirements`."
  94    )
  95    max_mutations: int = Field(
  96        description="Maximum number of mutations to combine in generation. Lower values will result in fewer total candidate sequences evaluated for this generator."
  97    )
  98    requirements: list[Requirement] = Field(
  99        default_factory=list,
 100        description="A list of requirements to satisfy. All requirements must be met for a valid assembly. See the `Requirement` documentation for details on how requirements are evaluated.",
 101    )
 102    allowed_mutations: list[AllowedMutation] = Field(
 103        description="The complete set of mutations that can be used in generation."
 104    )
 105    alias: str = Field(
 106        default="combinatorial_generator",
 107        description="Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
 108    )
 109
 110
 111class Constraint(BaseModel):
 112    """A constraint on an assay.
 113
 114    Multiple constraints can be specified for the same assay, allowing you to define ranges or
 115    multiple boundaries. All constraints must be satisfied for an assembly to be considered valid.
 116    Constraints with the same direction are also supported (e.g., better than reference A, B, and C),
 117    though this is less common.
 118
 119    Example use case: While optimizing for thermostability as the primary objective, you can constrain
 120    binding Kd to stay within an acceptable range by creating two relative constraints on the same
 121    binding assay. Since lower Kd means stronger binding:
 122    - MINIMIZE direction relative to a weak binder reference (high Kd) ensures Kd stays below the weak binder (binding doesn't get too weak)
 123    - MAXIMIZE direction relative to a strong binder reference (low Kd) ensures Kd stays above the strong binder (binding doesn't get too strong)
 124    """
 125
 126    measure: Measure = Field(description="The measure to constrain.")
 127    threshold: float | RelativeTo = Field(
 128        description="The threshold for the constraint, either an absolute value or relative to a reference.\n\n        Note: Relative thresholds (using `RelativeTo`) are strongly preferred over absolute thresholds.\n        Models are trained using contrastive loss, meaning they learn that assembly A > assembly B for\n        a given assay, rather than learning absolute assay values. Consequently, constraining assemblies\n        to be greater than a reference assembly is more likely to produce accurate results than setting\n        an absolute threshold value."
 129    )
 130
 131
 132class DiversifyParameters(ParametersBase):
 133    """Parameters for the diversify task.
 134
 135    An important detail is that the `LikelihoodBasedRanker` expects all assemblies to be of the same shape and length as its reference assembly. See the
 136    `LikelihoodBasedRanker` docs for further details. In particular, `diversify/v2` is not compatible with generators that produce assemblies of varying
 137    shapes/sizes different from the reference assembly.
 138    """
 139
 140    task_type: ClassVar[str] = "diversify/v2"
 141
 142    generator: Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator = Field(
 143        description="The generator configuration or configurations that define requirements and strategies for generating candidate assemblies.",
 144        discriminator="type",
 145    )
 146    ranker: LikelihoodBasedRanker = Field(
 147        description="The configuration defining how candidate assemblies are evaluated for inclusion in `selected_assemblies`."
 148    )
 149    num_assemblies: int = Field(
 150        description="The target number of `selected_assemblies` to output. In rare cases, the actual number of output assemblies may be slightly lower."
 151    )
 152
 153
 154class DiversifyResult(ResultBase):
 155    """Result of the diversify task."""
 156
 157    selected_assemblies: TableResult = Field(
 158        description="Table containing the selected assemblies output by `diversify`."
 159    )
 160    report: ArtifactParam | None = Field(description="A report on the result of the task.")
 161
 162
 163class EngineerParameters(ParametersBase):
 164    """Parameters for the engineer task."""
 165
 166    task_type: ClassVar[str] = "engineer/v2"
 167
 168    generator: Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator = Field(
 169        description="The generator configuration or configurations that define requirements and strategies for generating candidate assemblies.",
 170        discriminator="type",
 171    )
 172    ranker: ScoreBasedRanker = Field(
 173        description="The configuration defining how candidate assemblies are evaluated for inclusion in `selected_assemblies`."
 174    )
 175    num_assemblies: int = Field(
 176        description="The target number of selected assemblies to output. In rare cases of very difficult `constraints` this task may produce a smaller number."
 177    )
 178    filterers: list[ScoreBasedFilterer] = Field(
 179        default_factory=list,
 180        description="If specified, only generated assemblies accepted by all filterers are considered for inclusion in `selected_assemblies`.\n\nFilterers are applied sequentially in the order they are specified. This implies that filterers involving more expensive computations should be placed later\nin the list and, conversely, filterers that are expected to filter out a large portion of the candidate assemblies should be placed earlier in the list.\n        ",
 181    )
 182
 183
 184class EngineerResult(ResultBase):
 185    """Result of the engineer task."""
 186
 187    selected_assemblies: TableResult = Field(
 188        description="Table containing the selected assemblies output by `engineer`."
 189    )
 190    report: ArtifactParam | None = Field(description="A report on the result of the task.")
 191
 192
 193class Explicit(BaseModel):
 194    """A pre-defined table of assemblies to use directly for generation without modification.
 195
 196    Assemblies will be evaluated in the order provided.
 197    """
 198
 199    type: Literal["EXPLICIT"] = Field(default="EXPLICIT")
 200    source: MonomerSource | VhVlSource
 201    alias: str = Field(
 202        default="explicit_generator",
 203        description="Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
 204    )
 205
 206
 207class LikelihoodBasedRanker(BaseModel):
 208    """Configuration for ranking and selecting generated assemblies based on likelihoods.
 209
 210    Crucially, this ranking strategy relies on a reference assembly as a basis of comparison (see `reference_assembly` in `sampler_config`) and it
 211    will fail if it ever encounters an assembly not of the same shape/size as this reference. This implies that, unlike `ScoreBasedRanker`, this
 212    ranking strategy only works for batches of assemblies whose polymers are all of the same length.
 213    """
 214
 215    type: Literal["LIKELIHOOD_BASED"] = Field(default="LIKELIHOOD_BASED")
 216    sampler_config: MonomerSamplerConfig | VhVlSamplerConfig = Field(
 217        description="The trained sampler artifact used to compute assembly likelihoods, along with any optional control assemblies to include in the final output for experimental validation.",
 218        discriminator="kind",
 219    )
 220    hit_redundancy: int | None = Field(
 221        default=None,
 222        description='The maximum number of similar variants within the proposed set.\n\nWe say two variants are "similar" when their predicted performances are highly correlated.\nAt lower values this will mean on average fewer hits, but greater diversity within the set,\nwhile at maximum value (`hit_redundancy` equals the number of assemblies to select) the selection is purely greedy, with\nno requirement on diversity within the set. If set to None, it will be automatically set\nto a default value of `1 + num_assemblies//20`.',
 223    )
 224
 225
 226class Measure(BaseModel):
 227    """A measure to optimize or constrain."""
 228
 229    assay_id: str = Field(description="The ID of the assay.")
 230    direction: OptimizationDirection = Field(description="The direction of optimization for the assay.")
 231
 232
 233class ModelBasedGenerator(BaseModel):
 234    """Uses a trained sampler model to generate assemblies."""
 235
 236    type: Literal["MODEL_BASED"] = Field(default="MODEL_BASED")
 237    template: MonomerSamplingTemplate | VhVlSamplingTemplate = Field(
 238        description="The template sequence to use for generation.", discriminator="kind"
 239    )
 240    requirements: list[Requirement] = Field(
 241        default_factory=list,
 242        description="A list of requirements to satisfy. All requirements must be met for a valid assembly. See the `Requirement` documentation for details on how requirements are evaluated.",
 243    )
 244    discourage_mutations: RangeAnnotation | None = Field(
 245        default=None, description="Expression defining regions where mutations should be discouraged."
 246    )
 247    min_mutations: int = Field(description="Minimum number of mutations from the template assembly.")
 248    max_mutations: int = Field(description="Maximum number of mutations from the template assembly.")
 249    alias: str = Field(
 250        default="model_based_generator",
 251        description="Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
 252    )
 253
 254
 255class MonomerAssembly(BaseModel):
 256    """A single polymer chain assembly."""
 257
 258    monomer: str = Field(description="The monomer sequence")
 259
 260
 261class MonomerData(BaseModel):
 262    kind: Literal["MONOMER"] = Field(default="MONOMER")
 263    homologs: (
 264        list
 265        | Annotated[
 266            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 267            Field(discriminator="kind"),
 268        ]
 269    ) = Field(description="The homologous assemblies used for training.")
 270    dataset: (
 271        list
 272        | Annotated[
 273            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 274            Field(discriminator="kind"),
 275        ]
 276        | None
 277    ) = Field(
 278        description="The assayed assemblies used for training. If None, predictor finetuning and generator conditioning will be skipped."
 279    )
 280
 281
 282class MonomerHomologsData(BaseModel):
 283    """Monomer homolog sequences for base model training."""
 284
 285    kind: Literal["MONOMER"] = Field(default="MONOMER")
 286    homologs: (
 287        list
 288        | Annotated[
 289            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 290            Field(discriminator="kind"),
 291        ]
 292    ) = Field(
 293        description="Homologous sequences used for training. These sequences should be evolutionarily related to the target protein family."
 294    )
 295
 296
 297class MonomerModels(BaseModel):
 298    kind: Literal["MONOMER"] = Field(default="MONOMER")
 299    sampler: ArtifactParam = Field(description="The monomer sampler model.")
 300    scorer: ArtifactParam | None = Field(description="The monomer scorer model.")
 301    conditioned_sampler: ArtifactParam | None = Field(
 302        description="The monomer sampler model conditioned on the primary objective."
 303    )
 304
 305
 306class MonomerSamplerConditioningData(BaseModel):
 307    kind: Literal["MONOMER"] = Field(default="MONOMER")
 308    train_dataset: (
 309        list
 310        | Annotated[
 311            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 312            Field(discriminator="kind"),
 313        ]
 314    ) = Field(description="The training dataset containing assayed assemblies.")
 315    val_dataset: (
 316        list
 317        | Annotated[
 318            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 319            Field(discriminator="kind"),
 320        ]
 321        | None
 322    ) = Field(
 323        default=None,
 324        description="The validation dataset containing assayed assemblies. If not set, the training dataset will be split to create a validation dataset.",
 325    )
 326    sampler: ArtifactParam = Field(description="The pre-trained sampler model to condition.")
 327
 328
 329class MonomerSamplerConditioningResult(BaseModel):
 330    kind: Literal["MONOMER"] = Field(default="MONOMER")
 331    conditioned_sampler: ArtifactParam = Field(description="The conditioned sampler model.")
 332
 333
 334class MonomerSamplerConfig(BaseModel):
 335    """Configuration for a monomer sampler."""
 336
 337    kind: Literal["MONOMER_SAMPLER"] = Field(default="MONOMER_SAMPLER")
 338    sampler: ArtifactParam = Field(description="The trained sampler artifact used to compute sequence likelihoods.")
 339    reference_assembly: MonomerAssembly = Field(
 340        description="The reference assembly used as the denominator when computing sequence likelihood ratios."
 341    )
 342    controls: (
 343        list
 344        | Annotated[
 345            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 346            Field(discriminator="kind"),
 347        ]
 348        | None
 349    ) = Field(
 350        default=None,
 351        description="Optional control assemblies to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_assemblies` will be intentionally diverse from these assemblies. However these assemblies will *not* be included in the `selected_assemblies` output table, so -- if used -- take care to re-include them. ",
 352    )
 353
 354
 355class MonomerSamplerInput(BaseModel):
 356    kind: Literal["MONOMER"] = Field(default="MONOMER")
 357    assemblies: (
 358        list
 359        | Annotated[
 360            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 361            Field(discriminator="kind"),
 362        ]
 363    ) = Field(description="Monomer assemblies to run inference on.")
 364    sampler: ArtifactParam = Field(description="The trained sampler model.")
 365    reference_assembly: MonomerAssembly | None = Field(
 366        default=None,
 367        description="Optional reference assembly for computing pseudo log-likelihood ratios. All assemblies must be the same length as the reference assembly. When omitted, raw pseudo log-likelihoods are returned.",
 368    )
 369
 370
 371class MonomerSamplingTemplate(BaseModel):
 372    kind: Literal["MONOMER"] = Field(default="MONOMER")
 373    assembly: MonomerAssembly = Field(description="The template sequence to use for generation.")
 374    sampler: ArtifactParam = Field(description="The trained sampler artifact used to generate candidate sequences.")
 375
 376
 377class MonomerScorerConfig(BaseModel):
 378    """Configuration for a monomer scorer."""
 379
 380    kind: Literal["MONOMER_SCORER"] = Field(default="MONOMER_SCORER")
 381    scorer: ArtifactParam = Field(description="The trained scoring model artifact used to score sequences.")
 382    controls: (
 383        list
 384        | Annotated[
 385            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 386            Field(discriminator="kind"),
 387        ]
 388        | None
 389    ) = Field(
 390        default=None,
 391        description="Optional control sequences to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_sequences` will be intentionally diverse from these sequences. However these sequences will *not* be included in the `selected_sequences` output table, so -- if used -- take care to re-include them. ",
 392    )
 393
 394
 395class MonomerScorerInput(BaseModel):
 396    kind: Literal["MONOMER"] = Field(default="MONOMER")
 397    assemblies: (
 398        list
 399        | Annotated[
 400            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 401            Field(discriminator="kind"),
 402        ]
 403    ) = Field(description="Monomer assemblies to run inference on.")
 404    scorer: ArtifactParam | CustomPredictorParam = Field(description="The trained scorer ensemble.")
 405    noise: SamplingNoise | None = Field(
 406        default=None,
 407        description="MC-dropout noise configuration. When omitted, returns un-noised deterministic scores.",
 408    )
 409
 410
 411class MonomerScorerModel(BaseModel):
 412    kind: Literal["MONOMER"] = Field(default="MONOMER")
 413    scorer: ArtifactParam = Field(description="The trained scorer model for monomer sequences.")
 414
 415
 416class MonomerScorerRef(BaseModel):
 417    """A reference to a monomer scorer model."""
 418
 419    kind: Literal["MONOMER"] = Field(default="MONOMER")
 420    scorer: ArtifactParam | CustomPredictorParam = Field(
 421        description="Monomer scorer model. Can be a reference to a custom predictor."
 422    )
 423
 424
 425class MonomerSource(BaseModel):
 426    """A source of monomer assemblies."""
 427
 428    kind: Literal["MONOMER"] = Field(default="MONOMER")
 429    source: (
 430        list
 431        | Annotated[
 432            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 433            Field(discriminator="kind"),
 434        ]
 435    )
 436
 437
 438class MonomerTrainBaseModelResult(BaseModel):
 439    """Result containing a trained monomer sampler."""
 440
 441    kind: Literal["MONOMER"] = Field(default="MONOMER")
 442    sampler: ArtifactParam = Field(description="The trained sampler model that can be used for sequence generation.")
 443
 444
 445class MonomerTrainScorerInputs(BaseModel):
 446    kind: Literal["MONOMER"] = Field(default="MONOMER")
 447    dataset: (
 448        list
 449        | Annotated[
 450            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 451            Field(discriminator="kind"),
 452        ]
 453    ) = Field(description="The dataset containing assayed assemblies for training the scorer.")
 454    base_model: ArtifactParam = Field(description="The pre-trained base model (sampler) to use for scorer training.")
 455
 456
 457class OASDatabaseSearch(BaseModel):
 458    type_: Literal["OAS_SEARCH"] = Field(default="OAS_SEARCH", alias="type")
 459    seed_assemblies: list[VhVlAssembly] = Field(
 460        description="The list of light/heavy chain assemblies to search for.", min_length=1, max_length=100
 461    )
 462    search_unpaired: bool = Field(default=True, description="Whether to search for unpaired heavy/light chains.")
 463    search_paired: bool = Field(default=True, description="Whether to search for paired heavy/light chains.")
 464    annotate_assembly_features: bool = Field(
 465        default=True, description="Whether to infer CDR features based on OAS annotations."
 466    )
 467
 468
 469class ObjectivesAndConstraints(BaseModel):
 470    """Evaluation via a primary objective and/or constraints.
 471
 472    At least one of ``primary_objective`` or ``constraints`` must be provided. The output
 473    property ordering is ``[primary_objective, *constraints]`` when a primary objective is
 474    present; otherwise ``[*constraints]``.
 475    """
 476
 477    primary_objective: PrimaryObjective | None = Field(
 478        default=None,
 479        description="The primary objective defining the optimisation direction and reference value. Used to compute reference-subtracted scores and normalise direction (higher = better).",
 480    )
 481    constraints: list[Constraint] = Field(
 482        default_factory=list, description="Constraints to include in the score computation.", max_length=50
 483    )
 484
 485
 486class Parallel(BaseModel):
 487    """An ensemble of generators to use in parallel.
 488
 489    All generators in the ensemble run independently and each contribute an equal
 490    number of candidate assemblies for evaluation. This does not guarantee that each
 491    generator will contribute an equal number of assemblies to `selected_assemblies`,
 492    as assemblies from some generators in `ensemble` may perform better than others.
 493    """
 494
 495    type: Literal["PARALLEL"] = Field(default="PARALLEL")
 496    ensemble: list[
 497        Annotated[
 498            Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator,
 499            Field(description="The generation strategy for creating candidate sequences.", discriminator="type"),
 500        ]
 501    ] = Field(default_factory=list, description="The list of generators to run in parallel within this ensemble.")
 502    alias: str | None = Field(
 503        default=None,
 504        description="Optional alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. If provided, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
 505    )
 506
 507
 508class PreRanked(BaseModel):
 509    """Configuration for selecting from pre-ranked assemblies.
 510
 511    With this option, the assemblies passed for selection are assumed to be ranked in descending
 512    order of desirability. Selection is based on this order and subject to diversity constraints that
 513    can be controlled via the `hit_redundancy` parameter.
 514    """
 515
 516    type: Literal["PRE_RANKED"] = Field(default="PRE_RANKED")
 517    hit_redundancy: int = Field(
 518        default=3,
 519        description='The maximum number of similar variants within the proposed set.\n\nWe say two variants are "similar" when their predicted performances are highly correlated.\nAt lower values this will mean on average fewer hits, but greater diversity within the set,\nwhile at maximum value (`hit_redundancy` equals the number of assemblies to select) the selection is purely greedy, with\nno requirement on diversity within the set.',
 520    )
 521
 522
 523class PrimaryObjective(BaseModel):
 524    """The primary objective of an optimization task."""
 525
 526    measure: Measure = Field(description="The measure to optimize.")
 527    reference: float | RelativeTo = Field(
 528        description="The reference relative to which the primary objective is defined. For multiplicative assays, an absolute reference has to be positive."
 529    )
 530
 531
 532class RangeAnnotation(BaseModel):
 533    ranges: dict[str, list[tuple[int, int]]] = Field(
 534        description="A mapping from polymer names to annotation ranges. Each range is a tuple of (start, end). Indices are 0-based and inclusive for the start and exclusive for the end. For example, (0, 5) refers to positions 0 to 4."
 535    )
 536
 537
 538class RelativeTo(BaseModel):
 539    """A constraint or objective relative to a reference assembly."""
 540
 541    reference: MonomerAssembly | VhVlAssembly = Field(description="The reference assembly.")
 542    margin: float | None = Field(
 543        default=None,
 544        description="The desired margin relative to the `reference` assembly.\n\n        Denoting the score of the `reference` assembly as `reference_score`, the effective threshold will be `reference_score + margin` for additive assays\n        and `reference_score * margin` for multiplicative assays. Note: for multiplicative assays, the `margin` must be positive.\n\n        As an example, to tighten a constraint on a multiplicative assay with direction `MAXIMIZE`, specify a `margin`\n        greater than 1.0. Alternatively, if the direction is `MINIMIZE`, specify a `margin` less than 1.0.\n        ",
 545    )
 546
 547
 548class Requirement(BaseModel):
 549    """Assembly generation requirements specifying required and forbidden features on the generated assemblies.
 550
 551    Each requirement defines constraints for specific motifs in specific ranges of the assembly.
 552    The `operator` field determines how motif-range pairs are combined:
 553    - operator="all": *All* motif-range pairs must match
 554    - operator="any": *At least one* motif-range pair must match
 555    - operator="none": *No* motif-range pairs must match
 556
 557    When multiple requirements are provided in a list, *all* requirements must be satisfied.
 558
 559    Examples:
 560    1. Block mutations to Methionine ("M") across the entire heavy and light chains to prevent oxidation:
 561
 562       Requirement(
 563           motifs=["M"],
 564           apply_to=RangeAnnotation(ranges={"vh": [(0, 120)], "vl": [(0, 110)]}),
 565           operator="none",
 566       )
 567
 568    2. Avoid deamidation motifs ("NG", "NS", "NT") in the heavy chain:
 569
 570       Requirement(
 571           motifs=["NG", "NS", "NT"],
 572           apply_to=RangeAnnotation(ranges={"vh": [(0, 120)]}),
 573           operator="none",
 574       )
 575
 576    3. Ensure Cysteines are present at positions 22 and 96 in the heavy chain:
 577
 578       Requirement(
 579           motifs=["C"],
 580           apply_to=RangeAnnotation(ranges={"vh": [(22, 23), (96, 97)]}),
 581           operator="all",
 582       )
 583    """
 584
 585    apply_to: RangeAnnotation
 586    motifs: list[Annotated[str, Field(description="A motif or regular expression of amino acids.")]]
 587    operator: Literal["none", "all", "any"] = Field(
 588        description="The choice of how to interpret the motif-range pairs as a single requirement."
 589    )
 590
 591
 592class SamplerConditioningParameters(ParametersBase):
 593    task_type: ClassVar[str] = "condition_sampler/v2"
 594
 595    data: MonomerSamplerConditioningData | VhVlSamplerConditioningData = Field(
 596        description="The training and validation data along with the pre-trained sampler model.", discriminator="kind"
 597    )
 598    primary_objective: Measure = Field(
 599        description="The assay on which to condition the sampler model. Must correspond to an assay present in the datasets."
 600    )
 601
 602
 603class SamplerConditioningResult(ResultBase):
 604    models: MonomerSamplerConditioningResult | VhVlSamplerConditioningResult = Field(
 605        description="The conditioned sampler.", discriminator="kind"
 606    )
 607    report: ArtifactParam | None = Field(default=None, description="A report on the result of the task.")
 608
 609
 610class SamplerInferenceParameters(ParametersBase):
 611    """Parameters for the sampler inference endpoint.
 612
 613    Runs a trained sampler over a set of sequences and emits per-sequence sampler
 614    scores into the ``cradle.inferences.sampler_predictions`` BigQuery table.
 615    """
 616
 617    task_type: ClassVar[str] = "inference_sampler/v2"
 618
 619    sampler_input: MonomerSamplerInput | VhVlSamplerInput = Field(
 620        description="Assemblies and sampler model to use for inference.", discriminator="kind"
 621    )
 622    hyperparameters: dict[str, Any] = Field(
 623        default_factory=dict,
 624        description="A dictionary of hyperparameter overrides to apply to the default hyperparameters used by the task.",
 625    )
 626
 627
 628class SamplerInferenceResult(ResultBase):
 629    pass
 630
 631
 632class SamplingNoise(BaseModel):
 633    """Configuration for MC-dropout score sampling. When omitted on the scorer input, un-noised scores are returned."""
 634
 635    num_samples: int = Field(
 636        default=64, description="Number of score samples to draw per ensemble member and property."
 637    )
 638    dropout_p: float = Field(default=0.3, description="Dropout probability used to generate score samples.")
 639    noise_seed: int | None = Field(
 640        default=None,
 641        description="Seed for noise generation. If None, a fixed default seed is used for reproducibility.",
 642    )
 643
 644
 645class ScoreBasedFilterer(BaseModel):
 646    """Filters assemblies based on whether predicted performance meets constraints.
 647
 648    The scorer evaluates assemblies and only those that meet all specified constraints are retained.
 649    This can, for example, be used to incorporate in-silico metrics in assembly generation.
 650    """
 651
 652    kind: Literal["SCORED_FILTERER"] = Field(default="SCORED_FILTERER")
 653    scorer: MonomerScorerRef | VhVlScorerRef = Field(
 654        description="The scorer used to evaluate assemblies for filtering.", discriminator="kind"
 655    )
 656    constraints: list[Constraint] = Field(
 657        default_factory=list, description="List of constraints to apply during filtering.", max_length=50
 658    )
 659
 660
 661class ScoreBasedRanker(BaseModel):
 662    """Configuration for ranking and selecting generated assemblies."""
 663
 664    type: Literal["SCORE_BASED"] = Field(default="SCORE_BASED")
 665    primary_objective: PrimaryObjective = Field(description="The primary optimization objective of `engineer`.")
 666    constraints: list[Constraint] = Field(
 667        default_factory=list, description="List of constraints `engineer` will attempt to satisfy.", max_length=50
 668    )
 669    scorer_config: MonomerScorerConfig | VhVlScorerConfig = Field(
 670        description="The trained scoring model artifact used to score sequences, along with any optional control sequences to include in the final output for experimental validation.",
 671        discriminator="kind",
 672    )
 673    hit_redundancy: int | None = Field(
 674        default=None,
 675        description='The maximum number of similar variants within the proposed set.\n\nWe say two variants are "similar" when their predicted performances are highly correlated.\nAt lower values this will mean on average fewer hits, but greater diversity within the set,\nwhile at maximum value (`hit_redundancy` equals the number of assemblies to select) the selection is purely greedy, with\nno requirement on diversity within the set. If set to None, it will be automatically set\nto a default value of `1 + num_assemblies//20`.',
 676    )
 677
 678
 679class ScorerInferenceParameters(ParametersBase):
 680    """Parameters for the scorer inference endpoint.
 681
 682    Runs inference using a trained scorer ensemble and emits per-sequence scores
 683    into ``cradle.inferences.scorer_predictions``. When a noise configuration is provided
 684    on the scorer input, produces MC-dropout score samples; otherwise returns un-noised
 685    deterministic scores (``num_samples=1``). For each property the output is a flat array
 686    of shape ``[num_models, num_samples]`` representing either the predicted value above the
 687    property's reference, in direction-normalised log space (if `score_by` is provided) or
 688    the raw scorer values otherwise.
 689    """
 690
 691    task_type: ClassVar[str] = "inference_scorer/v2"
 692
 693    scorer_input: MonomerScorerInput | VhVlScorerInput = Field(
 694        description="Assemblies and scorer model to use for inference.", discriminator="kind"
 695    )
 696    score_by: ObjectivesAndConstraints | None = Field(
 697        description="Defines the properties to evaluate: a primary objective and/or constraints."
 698    )
 699    hyperparameters: dict[str, Any] = Field(
 700        default_factory=dict,
 701        description="A dictionary of hyperparameter overrides to apply to the default hyperparameters used by the task.",
 702    )
 703
 704
 705class ScorerInferenceResult(ResultBase):
 706    pass
 707
 708
 709class SearchParameters(ParametersBase):
 710    task_type: ClassVar[str] = "search/v2"
 711
 712    source: UnirefDatabaseSearch | OASDatabaseSearch = Field(
 713        description="The source database to search against, along with the assemblies to search for, and database-specific configuration.",
 714        discriminator="type_",
 715    )
 716
 717
 718class SearchResult(ResultBase):
 719    assembly_features: list[dict[str, AssemblyFeature]] = Field(
 720        default_factory=list,
 721        description="Parallel array (wrt to `seed_assemblies`) of features, keyed by feature name.",
 722    )
 723    homologs: TableResult
 724    report: ArtifactParam | None = Field(default=None, description="A report on the result of the task.")
 725
 726
 727class SelectParameters(ParametersBase):
 728    """Parameters for the select task."""
 729
 730    task_type: ClassVar[str] = "select/v2"
 731
 732    assemblies: MonomerSource | VhVlSource = Field(description="The source of assemblies to select from.")
 733    ranker: (
 734        Annotated[
 735            LikelihoodBasedRanker | ScoreBasedRanker,
 736            Field(description="The ranking strategy for selecting candidate assemblies.", discriminator="type"),
 737        ]
 738        | PreRanked
 739    ) = Field(
 740        description="The configuration defining how candidate assemblies are evaluated for inclusion in `selected_assemblies`."
 741    )
 742    min_assemblies_to_select: int = Field(
 743        description="The minimum number of assemblies to select. The number of selected candidates is dynamically determined and may be greater than this number. If an exact number of assemblies is desired, set `min_assemblies_to_select` and `max_assemblies_to_select` to the same value."
 744    )
 745    max_assemblies_to_select: int | None = Field(
 746        default=None,
 747        description="An optional (inclusive) upper limit on the number of assemblies to select. If provided, the task will select between `min_assemblies_to_select` and `max_assemblies_to_select` assemblies.",
 748    )
 749
 750
 751class SelectResult(ResultBase):
 752    """Result of the select task."""
 753
 754    selected_assemblies: TableResult = Field(
 755        description="Table containing the selected assemblies output by `select` sorted in descending order of preference."
 756    )
 757
 758
 759class Sequential(BaseModel):
 760    """An ensemble of generators to evaluate sequentially.
 761
 762    Each generator will have the opportunity to evaluate an equal number of candidate
 763    assemblies. However, if earlier generators are able to satisfy the requirements of
 764    the `ranker`, later generators may never be used. In this way this method of
 765    ensembling expresses a strict preference among the generators in `ensemble`.
 766    """
 767
 768    type: Literal["SEQUENTIAL"] = Field(default="SEQUENTIAL")
 769    ensemble: list[
 770        Annotated[
 771            Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator,
 772            Field(description="The generation strategy for creating candidate sequences.", discriminator="type"),
 773        ]
 774    ] = Field(default_factory=list, description="The list of generators to run in sequence within this ensemble.")
 775    alias: str | None = Field(
 776        default=None,
 777        description="Optional alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. If provided, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
 778    )
 779
 780
 781class TrainBaseModelParameters(ParametersBase):
 782    """Parameters for the base model training (evotuning) task.
 783
 784    This task fine-tunes a pretrained language model on a set of homologous sequences using masked language modeling.
 785    The resulting model can be used as a sampler for downstream generation tasks.
 786    """
 787
 788    task_type: ClassVar[str] = "train_base_model/v2"
 789
 790    data: MonomerHomologsData | VhVlHomologsData = Field(
 791        description="Homologous sequences for training the base model. The model learns the sequence distribution of the provided protein family.",
 792        discriminator="kind",
 793    )
 794
 795
 796class TrainBaseModelResult(ResultBase):
 797    """Result of the base model training task."""
 798
 799    models: MonomerTrainBaseModelResult | VhVlTrainBaseModelResult = Field(
 800        description="The trained sampler model.", discriminator="kind"
 801    )
 802    report: ArtifactParam | None = Field(default=None, description="Training report with metrics and diagnostics.")
 803
 804
 805class TrainParameters(ParametersBase):
 806    task_type: ClassVar[str] = "train/v2"
 807
 808    data: MonomerData | VhVlData = Field(
 809        description="The training data, including homologs and assayed sequences.", discriminator="kind"
 810    )
 811    assays: list[Assay] = Field(
 812        default_factory=list,
 813        description="The assays used for sampler conditioning (on the `primary_objective`) and scorer finetuning and evaluation. Must correspond to assays present in `data.dataset`. If `data.dataset` is None, `assays` must be empty. Otherwise, it must contain at least one assay.",
 814        max_length=50,
 815    )
 816    primary_objective: Measure | None = Field(
 817        default=None,
 818        description="The assay on which the sampler model is conditioned. Should correspond to an assay in `dataset`. If `data.dataset` is None, `primary_objective` must not be set. Otherwise, it must be set.",
 819    )
 820
 821
 822class TrainResult(ResultBase):
 823    models: MonomerModels | VhVlModels = Field(description="The trained models.", discriminator="kind")
 824    report: ArtifactParam | None = Field(description="A report on the result of the task.")
 825
 826
 827class TrainScorerParameters(ParametersBase):
 828    task_type: ClassVar[str] = "train_scorer/v2"
 829
 830    data: MonomerTrainScorerInputs | VhVlTrainScorerInputs = Field(
 831        description="The training data and pre-trained base model for scorer training.", discriminator="kind"
 832    )
 833    assays: list[Assay] = Field(
 834        default_factory=list,
 835        description="The assays used for scorer training and evaluation. Must correspond to assays present in `data.dataset`. Must contain at least one assay.",
 836        max_length=50,
 837    )
 838
 839
 840class TrainScorerResult(ResultBase):
 841    scorer_model: MonomerScorerModel | VhVlScorerModel = Field(
 842        description="The trained scorer model.", discriminator="kind"
 843    )
 844    report: ArtifactParam | None = Field(default=None, description="A report on the result of the task.")
 845
 846
 847class UnirefDatabaseSearch(BaseModel):
 848    type_: Literal["UNIREF_SEARCH"] = Field(default="UNIREF_SEARCH", alias="type")
 849    seed_assemblies: list[MonomerAssembly] = Field(
 850        description="A list of monomeric assemblies to search for.", min_length=1, max_length=100
 851    )
 852
 853
 854class VhVlAssembly(BaseModel):
 855    """An assembly of a VH and a VL chain."""
 856
 857    vh: str | None = Field(default=None, description="The heavy chain sequence.")
 858    vl: str | None = Field(default=None, description="The light chain sequence.")
 859
 860
 861class VhVlData(BaseModel):
 862    kind: Literal["VHVL"] = Field(default="VHVL")
 863    homologs: (
 864        list
 865        | Annotated[
 866            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 867            Field(discriminator="kind"),
 868        ]
 869    ) = Field(description="The homologous assemblies used for training.")
 870    dataset: (
 871        list
 872        | Annotated[
 873            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 874            Field(discriminator="kind"),
 875        ]
 876        | None
 877    ) = Field(
 878        description="The assayed assemblies used for training. If None, predictor finetuning and generator conditioning will be skipped."
 879    )
 880
 881
 882class VhVlHomologsData(BaseModel):
 883    """VH/VL homolog sequences for base model training."""
 884
 885    kind: Literal["VHVL"] = Field(default="VHVL")
 886    homologs: (
 887        list
 888        | Annotated[
 889            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 890            Field(discriminator="kind"),
 891        ]
 892    ) = Field(
 893        description="Homologous antibody sequences used for training. These sequences should be evolutionarily related to the target antibody family."
 894    )
 895
 896
 897class VhVlModels(BaseModel):
 898    kind: Literal["VH_VL"] = Field(default="VH_VL")
 899    sampler: ArtifactParam = Field(description="The VhVl sampler model.")
 900    scorer: ArtifactParam | None = Field(description="The VhVl scorer model.")
 901    conditioned_sampler: ArtifactParam | None = Field(
 902        description="The VhVl sampler model conditioned on the primary objective."
 903    )
 904
 905
 906class VhVlSamplerConditioningData(BaseModel):
 907    kind: Literal["VH_VL"] = Field(default="VH_VL")
 908    train_dataset: (
 909        list
 910        | Annotated[
 911            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 912            Field(discriminator="kind"),
 913        ]
 914    ) = Field(description="The training dataset containing assayed assemblies.")
 915    val_dataset: (
 916        list
 917        | Annotated[
 918            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 919            Field(discriminator="kind"),
 920        ]
 921        | None
 922    ) = Field(
 923        default=None,
 924        description="The validation dataset containing assayed assemblies. If not set, the training dataset will be split to create a validation dataset.",
 925    )
 926    sampler: ArtifactParam = Field(description="The pre-trained sampler model to condition.")
 927
 928
 929class VhVlSamplerConditioningResult(BaseModel):
 930    kind: Literal["VH_VL"] = Field(default="VH_VL")
 931    conditioned_sampler: ArtifactParam = Field(description="The conditioned sampler model.")
 932
 933
 934class VhVlSamplerConfig(BaseModel):
 935    """Configuration for a VhVl sampler."""
 936
 937    kind: Literal["VHVL_SAMPLER"] = Field(default="VHVL_SAMPLER")
 938    sampler: ArtifactParam = Field(description="The trained sampler artifact used to compute assembly likelihoods.")
 939    reference_assembly: VhVlAssembly = Field(
 940        description="The reference assembly used as the denominator when computing assembly likelihood ratios."
 941    )
 942    controls: (
 943        list
 944        | Annotated[
 945            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 946            Field(discriminator="kind"),
 947        ]
 948        | None
 949    ) = Field(
 950        default=None,
 951        description="Optional control assemblies to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_assemblies` will be intentionally diverse from these assemblies. However these assemblies will *not* be included in the `selected_assemblies` output table, so -- if used -- take care to re-include them. ",
 952    )
 953
 954
 955class VhVlSamplerInput(BaseModel):
 956    kind: Literal["VHVL"] = Field(default="VHVL")
 957    assemblies: (
 958        list
 959        | Annotated[
 960            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 961            Field(discriminator="kind"),
 962        ]
 963    ) = Field(description="VH/VL assemblies to run inference on.")
 964    sampler: ArtifactParam = Field(description="The trained sampler model.")
 965    reference_assembly: VhVlAssembly | None = Field(
 966        default=None,
 967        description="Optional reference assembly for computing pseudo log-likelihood ratios. All assemblies must be the same length as the reference assembly. When omitted, raw pseudo log-likelihoods are returned.",
 968    )
 969
 970
 971class VhVlSamplingTemplate(BaseModel):
 972    kind: Literal["VHVL"] = Field(default="VHVL")
 973    assembly: VhVlAssembly = Field(description="The template sequence to use for generation.")
 974    sampler: ArtifactParam = Field(description="The trained sampler artifact used to generate candidate sequences.")
 975
 976
 977class VhVlScorerConfig(BaseModel):
 978    """Configuration for a VhVl scorer."""
 979
 980    kind: Literal["VHVL_SCORER"] = Field(default="VHVL_SCORER")
 981    scorer: ArtifactParam = Field(description="The trained scoring model artifact used to score sequences.")
 982    controls: (
 983        list
 984        | Annotated[
 985            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
 986            Field(discriminator="kind"),
 987        ]
 988        | None
 989    ) = Field(
 990        default=None,
 991        description="Optional control sequences to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_sequences` will be intentionally diverse from these sequences. However these sequences will *not* be included in the `selected_sequences` output table, so -- if used -- take care to re-include them. ",
 992    )
 993
 994
 995class VhVlScorerInput(BaseModel):
 996    kind: Literal["VHVL"] = Field(default="VHVL")
 997    assemblies: (
 998        list
 999        | Annotated[
1000            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
1001            Field(discriminator="kind"),
1002        ]
1003    ) = Field(description="VH/VL assemblies to run inference on.")
1004    scorer: ArtifactParam | CustomPredictorParam = Field(
1005        description="VH/VL  scorer model. Can be a referenceto a custom predictor."
1006    )
1007    noise: SamplingNoise | None = Field(
1008        default=None,
1009        description="MC-dropout noise configuration. When omitted, returns un-noised deterministic scores.",
1010    )
1011
1012
1013class VhVlScorerModel(BaseModel):
1014    kind: Literal["VH_VL"] = Field(default="VH_VL")
1015    scorer: ArtifactParam = Field(description="The trained scorer model for antibody sequences.")
1016
1017
1018class VhVlScorerRef(BaseModel):
1019    """A reference to a VH/VL scorer model."""
1020
1021    kind: Literal["VHVL"] = Field(default="VHVL")
1022    scorer: ArtifactParam | CustomPredictorParam = Field(
1023        description="VH/VL scorer model. Can be a reference to a custom predictor."
1024    )
1025
1026
1027class VhVlSource(BaseModel):
1028    """A source of VH/VL assemblies."""
1029
1030    kind: Literal["VHVL"] = Field(default="VHVL")
1031    source: (
1032        list
1033        | Annotated[
1034            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
1035            Field(discriminator="kind"),
1036        ]
1037    )
1038
1039
1040class VhVlTrainBaseModelResult(BaseModel):
1041    """Result containing a trained VH/VL sampler."""
1042
1043    kind: Literal["VHVL"] = Field(default="VHVL")
1044    sampler: ArtifactParam = Field(
1045        description="The trained sampler model that can be used for antibody sequence generation."
1046    )
1047
1048
1049class VhVlTrainScorerInputs(BaseModel):
1050    kind: Literal["VHVL"] = Field(default="VHVL")
1051    dataset: (
1052        list
1053        | Annotated[
1054            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
1055            Field(discriminator="kind"),
1056        ]
1057    ) = Field(description="The dataset containing assayed assemblies for training the scorer.")
1058    base_model: ArtifactParam = Field(description="The pre-trained base model (sampler) to use for scorer training.")
class OptimizationDirection(enum.StrEnum):
23class OptimizationDirection(StrEnum):
24    MAXIMIZE = "MAXIMIZE"
25    MINIMIZE = "MINIMIZE"
MAXIMIZE = <OptimizationDirection.MAXIMIZE: 'MAXIMIZE'>
MINIMIZE = <OptimizationDirection.MINIMIZE: 'MINIMIZE'>
class ScaleType(enum.StrEnum):
28class ScaleType(StrEnum):
29    MULTIPLICATIVE = "MULTIPLICATIVE"
30    ADDITIVE = "ADDITIVE"
31    RANK = "RANK"
MULTIPLICATIVE = <ScaleType.MULTIPLICATIVE: 'MULTIPLICATIVE'>
ADDITIVE = <ScaleType.ADDITIVE: 'ADDITIVE'>
RANK = <ScaleType.RANK: 'RANK'>
class AllowedMutation(pydantic.main.BaseModel):
34class AllowedMutation(BaseModel):
35    in_range: RangeAnnotation = Field(
36        description="The annotation expression defining the positions at which the amino acids listed in `amino_acids` can be used."
37    )
38    amino_acids: list[Annotated[str, Field(description="A single amino acid.")]]
in_range: RangeAnnotation = PydanticUndefined

The annotation expression defining the positions at which the amino acids listed in amino_acids can be used.

amino_acids: list[typing.Annotated[str, FieldInfo(annotation=NoneType, required=True, description='A single amino acid.')]] = PydanticUndefined
class AnalyzeDataParameters(cradle.sdk.types.tasks.common.ParametersBase):
41class AnalyzeDataParameters(ParametersBase):
42    """Parameters for the analyze.data task."""
43
44    task_type: ClassVar[str] = "analyze.data/v2"
45
46    dataset: (
47        list
48        | Annotated[
49            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
50            Field(discriminator="kind"),
51        ]
52    ) = Field(description="The data to analyze before training.")
53    reference: MonomerAssembly | VhVlAssembly = Field(
54        description="The reference assembly used for computing mutations."
55    )
56    assays: list[Assay] = Field(description="The assays present in the dataset.")

Parameters for the analyze.data task.

task_type: ClassVar[str] = 'analyze.data/v2'

The data to analyze before training.

reference: MonomerAssembly | VhVlAssembly = PydanticUndefined

The reference assembly used for computing mutations.

assays: list[Assay] = PydanticUndefined

The assays present in the dataset.

class AnalyzeDataResult(cradle.sdk.types.tasks.common.ResultBase):
59class AnalyzeDataResult(ResultBase):
60    """Result of the analyze.data task."""
61
62    report: ArtifactParam = Field(description="The analysis report.")

Result of the analyze.data task.

report: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The analysis report.

class Assay(pydantic.main.BaseModel):
65class Assay(BaseModel):
66    """Metadata of an assay."""
67
68    assay_id: str = Field(description="ID of the assay", min_length=1, max_length=124)
69    name: str = Field(description="Human readable name of the assay", min_length=1, max_length=100)
70    scale_type: ScaleType = Field(
71        description="The scale type defines how the assay behaves.\n\n* **Additive**: Assay values are comparable in magnitude over batches, a delta of eg 5 in one batch is equivalent to 5 in another batch.\n* **Multiplicative**: Assay values are comparable over batches by applying a multiplication factor, eg fold improvement: `score_variantB_batch1 = factor(typically starting sequence score) * score_variantB_batch`.\n* **Rank**: Assay values are not comparable over batches, we can only assume the ranking within a batch is correct."
72    )
73    unit: str | None = Field(
74        default=None, description="Unit of the assay - used for display purposes only", min_length=1, max_length=100
75    )

Metadata of an assay.

assay_id: str = PydanticUndefined

ID of the assay

name: str = PydanticUndefined

Human readable name of the assay

scale_type: ScaleType = PydanticUndefined

The scale type defines how the assay behaves.

  • Additive: Assay values are comparable in magnitude over batches, a delta of eg 5 in one batch is equivalent to 5 in another batch.
  • Multiplicative: Assay values are comparable over batches by applying a multiplication factor, eg fold improvement: score_variantB_batch1 = factor(typically starting sequence score) * score_variantB_batch.
  • Rank: Assay values are not comparable over batches, we can only assume the ranking within a batch is correct.
unit: str | None = None

Unit of the assay - used for display purposes only

class AssemblyFeature(pydantic.main.BaseModel):
78class AssemblyFeature(BaseModel):
79    ranges: dict[str, list[tuple[int, int]]] = Field(description="The ranges of the feature, keyed by polymer name")
80    metadata: dict[str, str | int | float | bool] | None = Field(
81        default=None, description="Optional metadata for the feature"
82    )
ranges: dict[str, list[tuple[int, int]]] = PydanticUndefined

The ranges of the feature, keyed by polymer name

metadata: dict[str, str | int | float | bool] | None = None

Optional metadata for the feature

class CombinatorialGenerator(pydantic.main.BaseModel):
 85class CombinatorialGenerator(BaseModel):
 86    """Combinatorial assembly generation from explicit mutation.
 87
 88    Systematically generates assemblies by combining allowed mutations up to a
 89    specified maximum number.
 90    """
 91
 92    type: Literal["COMBINATORIAL"] = Field(default="COMBINATORIAL")
 93    template: MonomerAssembly | VhVlAssembly = Field(
 94        description="The assembly that serves as template for generation, including any annotations to be used in `requirements`."
 95    )
 96    max_mutations: int = Field(
 97        description="Maximum number of mutations to combine in generation. Lower values will result in fewer total candidate sequences evaluated for this generator."
 98    )
 99    requirements: list[Requirement] = Field(
100        default_factory=list,
101        description="A list of requirements to satisfy. All requirements must be met for a valid assembly. See the `Requirement` documentation for details on how requirements are evaluated.",
102    )
103    allowed_mutations: list[AllowedMutation] = Field(
104        description="The complete set of mutations that can be used in generation."
105    )
106    alias: str = Field(
107        default="combinatorial_generator",
108        description="Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
109    )

Combinatorial assembly generation from explicit mutation.

Systematically generates assemblies by combining allowed mutations up to a specified maximum number.

type: Literal['COMBINATORIAL'] = 'COMBINATORIAL'
template: MonomerAssembly | VhVlAssembly = PydanticUndefined

The assembly that serves as template for generation, including any annotations to be used in requirements.

max_mutations: int = PydanticUndefined

Maximum number of mutations to combine in generation. Lower values will result in fewer total candidate sequences evaluated for this generator.

requirements: list[Requirement] = PydanticUndefined

A list of requirements to satisfy. All requirements must be met for a valid assembly. See the Requirement documentation for details on how requirements are evaluated.

allowed_mutations: list[AllowedMutation] = PydanticUndefined

The complete set of mutations that can be used in generation.

alias: str = 'combinatorial_generator'

Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the generator_provenance column for rows in selected_sequences which were produced by this generator.

class Constraint(pydantic.main.BaseModel):
112class Constraint(BaseModel):
113    """A constraint on an assay.
114
115    Multiple constraints can be specified for the same assay, allowing you to define ranges or
116    multiple boundaries. All constraints must be satisfied for an assembly to be considered valid.
117    Constraints with the same direction are also supported (e.g., better than reference A, B, and C),
118    though this is less common.
119
120    Example use case: While optimizing for thermostability as the primary objective, you can constrain
121    binding Kd to stay within an acceptable range by creating two relative constraints on the same
122    binding assay. Since lower Kd means stronger binding:
123    - MINIMIZE direction relative to a weak binder reference (high Kd) ensures Kd stays below the weak binder (binding doesn't get too weak)
124    - MAXIMIZE direction relative to a strong binder reference (low Kd) ensures Kd stays above the strong binder (binding doesn't get too strong)
125    """
126
127    measure: Measure = Field(description="The measure to constrain.")
128    threshold: float | RelativeTo = Field(
129        description="The threshold for the constraint, either an absolute value or relative to a reference.\n\n        Note: Relative thresholds (using `RelativeTo`) are strongly preferred over absolute thresholds.\n        Models are trained using contrastive loss, meaning they learn that assembly A > assembly B for\n        a given assay, rather than learning absolute assay values. Consequently, constraining assemblies\n        to be greater than a reference assembly is more likely to produce accurate results than setting\n        an absolute threshold value."
130    )

A constraint on an assay.

Multiple constraints can be specified for the same assay, allowing you to define ranges or multiple boundaries. All constraints must be satisfied for an assembly to be considered valid. Constraints with the same direction are also supported (e.g., better than reference A, B, and C), though this is less common.

Example use case: While optimizing for thermostability as the primary objective, you can constrain binding Kd to stay within an acceptable range by creating two relative constraints on the same binding assay. Since lower Kd means stronger binding:

  • MINIMIZE direction relative to a weak binder reference (high Kd) ensures Kd stays below the weak binder (binding doesn't get too weak)
  • MAXIMIZE direction relative to a strong binder reference (low Kd) ensures Kd stays above the strong binder (binding doesn't get too strong)
measure: Measure = PydanticUndefined

The measure to constrain.

threshold: float | RelativeTo = PydanticUndefined

The threshold for the constraint, either an absolute value or relative to a reference.

    Note: Relative thresholds (using `RelativeTo`) are strongly preferred over absolute thresholds.
    Models are trained using contrastive loss, meaning they learn that assembly A > assembly B for
    a given assay, rather than learning absolute assay values. Consequently, constraining assemblies
    to be greater than a reference assembly is more likely to produce accurate results than setting
    an absolute threshold value.
class DiversifyParameters(cradle.sdk.types.tasks.common.ParametersBase):
133class DiversifyParameters(ParametersBase):
134    """Parameters for the diversify task.
135
136    An important detail is that the `LikelihoodBasedRanker` expects all assemblies to be of the same shape and length as its reference assembly. See the
137    `LikelihoodBasedRanker` docs for further details. In particular, `diversify/v2` is not compatible with generators that produce assemblies of varying
138    shapes/sizes different from the reference assembly.
139    """
140
141    task_type: ClassVar[str] = "diversify/v2"
142
143    generator: Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator = Field(
144        description="The generator configuration or configurations that define requirements and strategies for generating candidate assemblies.",
145        discriminator="type",
146    )
147    ranker: LikelihoodBasedRanker = Field(
148        description="The configuration defining how candidate assemblies are evaluated for inclusion in `selected_assemblies`."
149    )
150    num_assemblies: int = Field(
151        description="The target number of `selected_assemblies` to output. In rare cases, the actual number of output assemblies may be slightly lower."
152    )

Parameters for the diversify task.

An important detail is that the LikelihoodBasedRanker expects all assemblies to be of the same shape and length as its reference assembly. See the LikelihoodBasedRanker docs for further details. In particular, diversify/v2 is not compatible with generators that produce assemblies of varying shapes/sizes different from the reference assembly.

task_type: ClassVar[str] = 'diversify/v2'
generator: Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator = PydanticUndefined

The generator configuration or configurations that define requirements and strategies for generating candidate assemblies.

ranker: LikelihoodBasedRanker = PydanticUndefined

The configuration defining how candidate assemblies are evaluated for inclusion in selected_assemblies.

num_assemblies: int = PydanticUndefined

The target number of selected_assemblies to output. In rare cases, the actual number of output assemblies may be slightly lower.

class DiversifyResult(cradle.sdk.types.tasks.common.ResultBase):
155class DiversifyResult(ResultBase):
156    """Result of the diversify task."""
157
158    selected_assemblies: TableResult = Field(
159        description="Table containing the selected assemblies output by `diversify`."
160    )
161    report: ArtifactParam | None = Field(description="A report on the result of the task.")

Result of the diversify task.

selected_assemblies: cradle.sdk.types.tasks.common.TableResult = PydanticUndefined

Table containing the selected assemblies output by diversify.

report: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

A report on the result of the task.

class EngineerParameters(cradle.sdk.types.tasks.common.ParametersBase):
164class EngineerParameters(ParametersBase):
165    """Parameters for the engineer task."""
166
167    task_type: ClassVar[str] = "engineer/v2"
168
169    generator: Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator = Field(
170        description="The generator configuration or configurations that define requirements and strategies for generating candidate assemblies.",
171        discriminator="type",
172    )
173    ranker: ScoreBasedRanker = Field(
174        description="The configuration defining how candidate assemblies are evaluated for inclusion in `selected_assemblies`."
175    )
176    num_assemblies: int = Field(
177        description="The target number of selected assemblies to output. In rare cases of very difficult `constraints` this task may produce a smaller number."
178    )
179    filterers: list[ScoreBasedFilterer] = Field(
180        default_factory=list,
181        description="If specified, only generated assemblies accepted by all filterers are considered for inclusion in `selected_assemblies`.\n\nFilterers are applied sequentially in the order they are specified. This implies that filterers involving more expensive computations should be placed later\nin the list and, conversely, filterers that are expected to filter out a large portion of the candidate assemblies should be placed earlier in the list.\n        ",
182    )

Parameters for the engineer task.

task_type: ClassVar[str] = 'engineer/v2'
generator: Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator = PydanticUndefined

The generator configuration or configurations that define requirements and strategies for generating candidate assemblies.

ranker: ScoreBasedRanker = PydanticUndefined

The configuration defining how candidate assemblies are evaluated for inclusion in selected_assemblies.

num_assemblies: int = PydanticUndefined

The target number of selected assemblies to output. In rare cases of very difficult constraints this task may produce a smaller number.

filterers: list[ScoreBasedFilterer] = PydanticUndefined

If specified, only generated assemblies accepted by all filterers are considered for inclusion in selected_assemblies.

Filterers are applied sequentially in the order they are specified. This implies that filterers involving more expensive computations should be placed later in the list and, conversely, filterers that are expected to filter out a large portion of the candidate assemblies should be placed earlier in the list.

class EngineerResult(cradle.sdk.types.tasks.common.ResultBase):
185class EngineerResult(ResultBase):
186    """Result of the engineer task."""
187
188    selected_assemblies: TableResult = Field(
189        description="Table containing the selected assemblies output by `engineer`."
190    )
191    report: ArtifactParam | None = Field(description="A report on the result of the task.")

Result of the engineer task.

selected_assemblies: cradle.sdk.types.tasks.common.TableResult = PydanticUndefined

Table containing the selected assemblies output by engineer.

report: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

A report on the result of the task.

class Explicit(pydantic.main.BaseModel):
194class Explicit(BaseModel):
195    """A pre-defined table of assemblies to use directly for generation without modification.
196
197    Assemblies will be evaluated in the order provided.
198    """
199
200    type: Literal["EXPLICIT"] = Field(default="EXPLICIT")
201    source: MonomerSource | VhVlSource
202    alias: str = Field(
203        default="explicit_generator",
204        description="Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
205    )

A pre-defined table of assemblies to use directly for generation without modification.

Assemblies will be evaluated in the order provided.

type: Literal['EXPLICIT'] = 'EXPLICIT'
source: MonomerSource | VhVlSource = PydanticUndefined
alias: str = 'explicit_generator'

Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the generator_provenance column for rows in selected_sequences which were produced by this generator.

class LikelihoodBasedRanker(pydantic.main.BaseModel):
208class LikelihoodBasedRanker(BaseModel):
209    """Configuration for ranking and selecting generated assemblies based on likelihoods.
210
211    Crucially, this ranking strategy relies on a reference assembly as a basis of comparison (see `reference_assembly` in `sampler_config`) and it
212    will fail if it ever encounters an assembly not of the same shape/size as this reference. This implies that, unlike `ScoreBasedRanker`, this
213    ranking strategy only works for batches of assemblies whose polymers are all of the same length.
214    """
215
216    type: Literal["LIKELIHOOD_BASED"] = Field(default="LIKELIHOOD_BASED")
217    sampler_config: MonomerSamplerConfig | VhVlSamplerConfig = Field(
218        description="The trained sampler artifact used to compute assembly likelihoods, along with any optional control assemblies to include in the final output for experimental validation.",
219        discriminator="kind",
220    )
221    hit_redundancy: int | None = Field(
222        default=None,
223        description='The maximum number of similar variants within the proposed set.\n\nWe say two variants are "similar" when their predicted performances are highly correlated.\nAt lower values this will mean on average fewer hits, but greater diversity within the set,\nwhile at maximum value (`hit_redundancy` equals the number of assemblies to select) the selection is purely greedy, with\nno requirement on diversity within the set. If set to None, it will be automatically set\nto a default value of `1 + num_assemblies//20`.',
224    )

Configuration for ranking and selecting generated assemblies based on likelihoods.

Crucially, this ranking strategy relies on a reference assembly as a basis of comparison (see reference_assembly in sampler_config) and it will fail if it ever encounters an assembly not of the same shape/size as this reference. This implies that, unlike ScoreBasedRanker, this ranking strategy only works for batches of assemblies whose polymers are all of the same length.

type: Literal['LIKELIHOOD_BASED'] = 'LIKELIHOOD_BASED'
sampler_config: MonomerSamplerConfig | VhVlSamplerConfig = PydanticUndefined

The trained sampler artifact used to compute assembly likelihoods, along with any optional control assemblies to include in the final output for experimental validation.

hit_redundancy: int | None = None

The maximum number of similar variants within the proposed set.

We say two variants are "similar" when their predicted performances are highly correlated. At lower values this will mean on average fewer hits, but greater diversity within the set, while at maximum value (hit_redundancy equals the number of assemblies to select) the selection is purely greedy, with no requirement on diversity within the set. If set to None, it will be automatically set to a default value of 1 + num_assemblies//20.

class Measure(pydantic.main.BaseModel):
227class Measure(BaseModel):
228    """A measure to optimize or constrain."""
229
230    assay_id: str = Field(description="The ID of the assay.")
231    direction: OptimizationDirection = Field(description="The direction of optimization for the assay.")

A measure to optimize or constrain.

assay_id: str = PydanticUndefined

The ID of the assay.

direction: OptimizationDirection = PydanticUndefined

The direction of optimization for the assay.

class ModelBasedGenerator(pydantic.main.BaseModel):
234class ModelBasedGenerator(BaseModel):
235    """Uses a trained sampler model to generate assemblies."""
236
237    type: Literal["MODEL_BASED"] = Field(default="MODEL_BASED")
238    template: MonomerSamplingTemplate | VhVlSamplingTemplate = Field(
239        description="The template sequence to use for generation.", discriminator="kind"
240    )
241    requirements: list[Requirement] = Field(
242        default_factory=list,
243        description="A list of requirements to satisfy. All requirements must be met for a valid assembly. See the `Requirement` documentation for details on how requirements are evaluated.",
244    )
245    discourage_mutations: RangeAnnotation | None = Field(
246        default=None, description="Expression defining regions where mutations should be discouraged."
247    )
248    min_mutations: int = Field(description="Minimum number of mutations from the template assembly.")
249    max_mutations: int = Field(description="Maximum number of mutations from the template assembly.")
250    alias: str = Field(
251        default="model_based_generator",
252        description="Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
253    )

Uses a trained sampler model to generate assemblies.

type: Literal['MODEL_BASED'] = 'MODEL_BASED'
template: MonomerSamplingTemplate | VhVlSamplingTemplate = PydanticUndefined

The template sequence to use for generation.

requirements: list[Requirement] = PydanticUndefined

A list of requirements to satisfy. All requirements must be met for a valid assembly. See the Requirement documentation for details on how requirements are evaluated.

discourage_mutations: RangeAnnotation | None = None

Expression defining regions where mutations should be discouraged.

min_mutations: int = PydanticUndefined

Minimum number of mutations from the template assembly.

max_mutations: int = PydanticUndefined

Maximum number of mutations from the template assembly.

alias: str = 'model_based_generator'

Custom alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. For example, this name will appear in the generator_provenance column for rows in selected_sequences which were produced by this generator.

class MonomerAssembly(pydantic.main.BaseModel):
256class MonomerAssembly(BaseModel):
257    """A single polymer chain assembly."""
258
259    monomer: str = Field(description="The monomer sequence")

A single polymer chain assembly.

monomer: str = PydanticUndefined

The monomer sequence

class MonomerData(pydantic.main.BaseModel):
262class MonomerData(BaseModel):
263    kind: Literal["MONOMER"] = Field(default="MONOMER")
264    homologs: (
265        list
266        | Annotated[
267            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
268            Field(discriminator="kind"),
269        ]
270    ) = Field(description="The homologous assemblies used for training.")
271    dataset: (
272        list
273        | Annotated[
274            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
275            Field(discriminator="kind"),
276        ]
277        | None
278    ) = Field(
279        description="The assayed assemblies used for training. If None, predictor finetuning and generator conditioning will be skipped."
280    )
kind: Literal['MONOMER'] = 'MONOMER'

The homologous assemblies used for training.

The assayed assemblies used for training. If None, predictor finetuning and generator conditioning will be skipped.

class MonomerHomologsData(pydantic.main.BaseModel):
283class MonomerHomologsData(BaseModel):
284    """Monomer homolog sequences for base model training."""
285
286    kind: Literal["MONOMER"] = Field(default="MONOMER")
287    homologs: (
288        list
289        | Annotated[
290            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
291            Field(discriminator="kind"),
292        ]
293    ) = Field(
294        description="Homologous sequences used for training. These sequences should be evolutionarily related to the target protein family."
295    )

Monomer homolog sequences for base model training.

kind: Literal['MONOMER'] = 'MONOMER'

Homologous sequences used for training. These sequences should be evolutionarily related to the target protein family.

class MonomerModels(pydantic.main.BaseModel):
298class MonomerModels(BaseModel):
299    kind: Literal["MONOMER"] = Field(default="MONOMER")
300    sampler: ArtifactParam = Field(description="The monomer sampler model.")
301    scorer: ArtifactParam | None = Field(description="The monomer scorer model.")
302    conditioned_sampler: ArtifactParam | None = Field(
303        description="The monomer sampler model conditioned on the primary objective."
304    )
kind: Literal['MONOMER'] = 'MONOMER'
sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The monomer sampler model.

scorer: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

The monomer scorer model.

conditioned_sampler: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

The monomer sampler model conditioned on the primary objective.

class MonomerSamplerConditioningData(pydantic.main.BaseModel):
307class MonomerSamplerConditioningData(BaseModel):
308    kind: Literal["MONOMER"] = Field(default="MONOMER")
309    train_dataset: (
310        list
311        | Annotated[
312            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
313            Field(discriminator="kind"),
314        ]
315    ) = Field(description="The training dataset containing assayed assemblies.")
316    val_dataset: (
317        list
318        | Annotated[
319            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
320            Field(discriminator="kind"),
321        ]
322        | None
323    ) = Field(
324        default=None,
325        description="The validation dataset containing assayed assemblies. If not set, the training dataset will be split to create a validation dataset.",
326    )
327    sampler: ArtifactParam = Field(description="The pre-trained sampler model to condition.")
kind: Literal['MONOMER'] = 'MONOMER'

The training dataset containing assayed assemblies.

The validation dataset containing assayed assemblies. If not set, the training dataset will be split to create a validation dataset.

sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The pre-trained sampler model to condition.

class MonomerSamplerConditioningResult(pydantic.main.BaseModel):
330class MonomerSamplerConditioningResult(BaseModel):
331    kind: Literal["MONOMER"] = Field(default="MONOMER")
332    conditioned_sampler: ArtifactParam = Field(description="The conditioned sampler model.")
kind: Literal['MONOMER'] = 'MONOMER'
conditioned_sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The conditioned sampler model.

class MonomerSamplerConfig(pydantic.main.BaseModel):
335class MonomerSamplerConfig(BaseModel):
336    """Configuration for a monomer sampler."""
337
338    kind: Literal["MONOMER_SAMPLER"] = Field(default="MONOMER_SAMPLER")
339    sampler: ArtifactParam = Field(description="The trained sampler artifact used to compute sequence likelihoods.")
340    reference_assembly: MonomerAssembly = Field(
341        description="The reference assembly used as the denominator when computing sequence likelihood ratios."
342    )
343    controls: (
344        list
345        | Annotated[
346            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
347            Field(discriminator="kind"),
348        ]
349        | None
350    ) = Field(
351        default=None,
352        description="Optional control assemblies to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_assemblies` will be intentionally diverse from these assemblies. However these assemblies will *not* be included in the `selected_assemblies` output table, so -- if used -- take care to re-include them. ",
353    )

Configuration for a monomer sampler.

kind: Literal['MONOMER_SAMPLER'] = 'MONOMER_SAMPLER'
sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler artifact used to compute sequence likelihoods.

reference_assembly: MonomerAssembly = PydanticUndefined

The reference assembly used as the denominator when computing sequence likelihood ratios.

Optional control assemblies to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as selected_assemblies will be intentionally diverse from these assemblies. However these assemblies will not be included in the selected_assemblies output table, so -- if used -- take care to re-include them.

class MonomerSamplerInput(pydantic.main.BaseModel):
356class MonomerSamplerInput(BaseModel):
357    kind: Literal["MONOMER"] = Field(default="MONOMER")
358    assemblies: (
359        list
360        | Annotated[
361            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
362            Field(discriminator="kind"),
363        ]
364    ) = Field(description="Monomer assemblies to run inference on.")
365    sampler: ArtifactParam = Field(description="The trained sampler model.")
366    reference_assembly: MonomerAssembly | None = Field(
367        default=None,
368        description="Optional reference assembly for computing pseudo log-likelihood ratios. All assemblies must be the same length as the reference assembly. When omitted, raw pseudo log-likelihoods are returned.",
369    )
kind: Literal['MONOMER'] = 'MONOMER'

Monomer assemblies to run inference on.

sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler model.

reference_assembly: MonomerAssembly | None = None

Optional reference assembly for computing pseudo log-likelihood ratios. All assemblies must be the same length as the reference assembly. When omitted, raw pseudo log-likelihoods are returned.

class MonomerSamplingTemplate(pydantic.main.BaseModel):
372class MonomerSamplingTemplate(BaseModel):
373    kind: Literal["MONOMER"] = Field(default="MONOMER")
374    assembly: MonomerAssembly = Field(description="The template sequence to use for generation.")
375    sampler: ArtifactParam = Field(description="The trained sampler artifact used to generate candidate sequences.")
kind: Literal['MONOMER'] = 'MONOMER'
assembly: MonomerAssembly = PydanticUndefined

The template sequence to use for generation.

sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler artifact used to generate candidate sequences.

class MonomerScorerConfig(pydantic.main.BaseModel):
378class MonomerScorerConfig(BaseModel):
379    """Configuration for a monomer scorer."""
380
381    kind: Literal["MONOMER_SCORER"] = Field(default="MONOMER_SCORER")
382    scorer: ArtifactParam = Field(description="The trained scoring model artifact used to score sequences.")
383    controls: (
384        list
385        | Annotated[
386            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
387            Field(discriminator="kind"),
388        ]
389        | None
390    ) = Field(
391        default=None,
392        description="Optional control sequences to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_sequences` will be intentionally diverse from these sequences. However these sequences will *not* be included in the `selected_sequences` output table, so -- if used -- take care to re-include them. ",
393    )

Configuration for a monomer scorer.

kind: Literal['MONOMER_SCORER'] = 'MONOMER_SCORER'
scorer: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained scoring model artifact used to score sequences.

Optional control sequences to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as selected_sequences will be intentionally diverse from these sequences. However these sequences will not be included in the selected_sequences output table, so -- if used -- take care to re-include them.

class MonomerScorerInput(pydantic.main.BaseModel):
396class MonomerScorerInput(BaseModel):
397    kind: Literal["MONOMER"] = Field(default="MONOMER")
398    assemblies: (
399        list
400        | Annotated[
401            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
402            Field(discriminator="kind"),
403        ]
404    ) = Field(description="Monomer assemblies to run inference on.")
405    scorer: ArtifactParam | CustomPredictorParam = Field(description="The trained scorer ensemble.")
406    noise: SamplingNoise | None = Field(
407        default=None,
408        description="MC-dropout noise configuration. When omitted, returns un-noised deterministic scores.",
409    )
kind: Literal['MONOMER'] = 'MONOMER'

Monomer assemblies to run inference on.

The trained scorer ensemble.

noise: SamplingNoise | None = None

MC-dropout noise configuration. When omitted, returns un-noised deterministic scores.

class MonomerScorerModel(pydantic.main.BaseModel):
412class MonomerScorerModel(BaseModel):
413    kind: Literal["MONOMER"] = Field(default="MONOMER")
414    scorer: ArtifactParam = Field(description="The trained scorer model for monomer sequences.")
kind: Literal['MONOMER'] = 'MONOMER'
scorer: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained scorer model for monomer sequences.

class MonomerScorerRef(pydantic.main.BaseModel):
417class MonomerScorerRef(BaseModel):
418    """A reference to a monomer scorer model."""
419
420    kind: Literal["MONOMER"] = Field(default="MONOMER")
421    scorer: ArtifactParam | CustomPredictorParam = Field(
422        description="Monomer scorer model. Can be a reference to a custom predictor."
423    )

A reference to a monomer scorer model.

kind: Literal['MONOMER'] = 'MONOMER'

Monomer scorer model. Can be a reference to a custom predictor.

class MonomerSource(pydantic.main.BaseModel):
426class MonomerSource(BaseModel):
427    """A source of monomer assemblies."""
428
429    kind: Literal["MONOMER"] = Field(default="MONOMER")
430    source: (
431        list
432        | Annotated[
433            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
434            Field(discriminator="kind"),
435        ]
436    )

A source of monomer assemblies.

kind: Literal['MONOMER'] = 'MONOMER'
class MonomerTrainBaseModelResult(pydantic.main.BaseModel):
439class MonomerTrainBaseModelResult(BaseModel):
440    """Result containing a trained monomer sampler."""
441
442    kind: Literal["MONOMER"] = Field(default="MONOMER")
443    sampler: ArtifactParam = Field(description="The trained sampler model that can be used for sequence generation.")

Result containing a trained monomer sampler.

kind: Literal['MONOMER'] = 'MONOMER'
sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler model that can be used for sequence generation.

class MonomerTrainScorerInputs(pydantic.main.BaseModel):
446class MonomerTrainScorerInputs(BaseModel):
447    kind: Literal["MONOMER"] = Field(default="MONOMER")
448    dataset: (
449        list
450        | Annotated[
451            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
452            Field(discriminator="kind"),
453        ]
454    ) = Field(description="The dataset containing assayed assemblies for training the scorer.")
455    base_model: ArtifactParam = Field(description="The pre-trained base model (sampler) to use for scorer training.")
kind: Literal['MONOMER'] = 'MONOMER'

The dataset containing assayed assemblies for training the scorer.

base_model: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The pre-trained base model (sampler) to use for scorer training.

class OASDatabaseSearch(pydantic.main.BaseModel):
458class OASDatabaseSearch(BaseModel):
459    type_: Literal["OAS_SEARCH"] = Field(default="OAS_SEARCH", alias="type")
460    seed_assemblies: list[VhVlAssembly] = Field(
461        description="The list of light/heavy chain assemblies to search for.", min_length=1, max_length=100
462    )
463    search_unpaired: bool = Field(default=True, description="Whether to search for unpaired heavy/light chains.")
464    search_paired: bool = Field(default=True, description="Whether to search for paired heavy/light chains.")
465    annotate_assembly_features: bool = Field(
466        default=True, description="Whether to infer CDR features based on OAS annotations."
467    )
type_: Literal['OAS_SEARCH'] = 'OAS_SEARCH'
seed_assemblies: list[VhVlAssembly] = PydanticUndefined

The list of light/heavy chain assemblies to search for.

search_unpaired: bool = True

Whether to search for unpaired heavy/light chains.

search_paired: bool = True

Whether to search for paired heavy/light chains.

annotate_assembly_features: bool = True

Whether to infer CDR features based on OAS annotations.

class ObjectivesAndConstraints(pydantic.main.BaseModel):
470class ObjectivesAndConstraints(BaseModel):
471    """Evaluation via a primary objective and/or constraints.
472
473    At least one of ``primary_objective`` or ``constraints`` must be provided. The output
474    property ordering is ``[primary_objective, *constraints]`` when a primary objective is
475    present; otherwise ``[*constraints]``.
476    """
477
478    primary_objective: PrimaryObjective | None = Field(
479        default=None,
480        description="The primary objective defining the optimisation direction and reference value. Used to compute reference-subtracted scores and normalise direction (higher = better).",
481    )
482    constraints: list[Constraint] = Field(
483        default_factory=list, description="Constraints to include in the score computation.", max_length=50
484    )

Evaluation via a primary objective and/or constraints.

At least one of primary_objective or constraints must be provided. The output property ordering is [primary_objective, *constraints] when a primary objective is present; otherwise [*constraints].

primary_objective: PrimaryObjective | None = None

The primary objective defining the optimisation direction and reference value. Used to compute reference-subtracted scores and normalise direction (higher = better).

constraints: list[Constraint] = PydanticUndefined

Constraints to include in the score computation.

class Parallel(pydantic.main.BaseModel):
487class Parallel(BaseModel):
488    """An ensemble of generators to use in parallel.
489
490    All generators in the ensemble run independently and each contribute an equal
491    number of candidate assemblies for evaluation. This does not guarantee that each
492    generator will contribute an equal number of assemblies to `selected_assemblies`,
493    as assemblies from some generators in `ensemble` may perform better than others.
494    """
495
496    type: Literal["PARALLEL"] = Field(default="PARALLEL")
497    ensemble: list[
498        Annotated[
499            Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator,
500            Field(description="The generation strategy for creating candidate sequences.", discriminator="type"),
501        ]
502    ] = Field(default_factory=list, description="The list of generators to run in parallel within this ensemble.")
503    alias: str | None = Field(
504        default=None,
505        description="Optional alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. If provided, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
506    )

An ensemble of generators to use in parallel.

All generators in the ensemble run independently and each contribute an equal number of candidate assemblies for evaluation. This does not guarantee that each generator will contribute an equal number of assemblies to selected_assemblies, as assemblies from some generators in ensemble may perform better than others.

type: Literal['PARALLEL'] = 'PARALLEL'
ensemble: list[typing.Annotated[Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator, FieldInfo(annotation=NoneType, required=True, description='The generation strategy for creating candidate sequences.', discriminator='type')]] = PydanticUndefined

The list of generators to run in parallel within this ensemble.

alias: str | None = None

Optional alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. If provided, this name will appear in the generator_provenance column for rows in selected_sequences which were produced by this generator.

class PreRanked(pydantic.main.BaseModel):
509class PreRanked(BaseModel):
510    """Configuration for selecting from pre-ranked assemblies.
511
512    With this option, the assemblies passed for selection are assumed to be ranked in descending
513    order of desirability. Selection is based on this order and subject to diversity constraints that
514    can be controlled via the `hit_redundancy` parameter.
515    """
516
517    type: Literal["PRE_RANKED"] = Field(default="PRE_RANKED")
518    hit_redundancy: int = Field(
519        default=3,
520        description='The maximum number of similar variants within the proposed set.\n\nWe say two variants are "similar" when their predicted performances are highly correlated.\nAt lower values this will mean on average fewer hits, but greater diversity within the set,\nwhile at maximum value (`hit_redundancy` equals the number of assemblies to select) the selection is purely greedy, with\nno requirement on diversity within the set.',
521    )

Configuration for selecting from pre-ranked assemblies.

With this option, the assemblies passed for selection are assumed to be ranked in descending order of desirability. Selection is based on this order and subject to diversity constraints that can be controlled via the hit_redundancy parameter.

type: Literal['PRE_RANKED'] = 'PRE_RANKED'
hit_redundancy: int = 3

The maximum number of similar variants within the proposed set.

We say two variants are "similar" when their predicted performances are highly correlated. At lower values this will mean on average fewer hits, but greater diversity within the set, while at maximum value (hit_redundancy equals the number of assemblies to select) the selection is purely greedy, with no requirement on diversity within the set.

class PrimaryObjective(pydantic.main.BaseModel):
524class PrimaryObjective(BaseModel):
525    """The primary objective of an optimization task."""
526
527    measure: Measure = Field(description="The measure to optimize.")
528    reference: float | RelativeTo = Field(
529        description="The reference relative to which the primary objective is defined. For multiplicative assays, an absolute reference has to be positive."
530    )

The primary objective of an optimization task.

measure: Measure = PydanticUndefined

The measure to optimize.

reference: float | RelativeTo = PydanticUndefined

The reference relative to which the primary objective is defined. For multiplicative assays, an absolute reference has to be positive.

class RangeAnnotation(pydantic.main.BaseModel):
533class RangeAnnotation(BaseModel):
534    ranges: dict[str, list[tuple[int, int]]] = Field(
535        description="A mapping from polymer names to annotation ranges. Each range is a tuple of (start, end). Indices are 0-based and inclusive for the start and exclusive for the end. For example, (0, 5) refers to positions 0 to 4."
536    )
ranges: dict[str, list[tuple[int, int]]] = PydanticUndefined

A mapping from polymer names to annotation ranges. Each range is a tuple of (start, end). Indices are 0-based and inclusive for the start and exclusive for the end. For example, (0, 5) refers to positions 0 to 4.

class RelativeTo(pydantic.main.BaseModel):
539class RelativeTo(BaseModel):
540    """A constraint or objective relative to a reference assembly."""
541
542    reference: MonomerAssembly | VhVlAssembly = Field(description="The reference assembly.")
543    margin: float | None = Field(
544        default=None,
545        description="The desired margin relative to the `reference` assembly.\n\n        Denoting the score of the `reference` assembly as `reference_score`, the effective threshold will be `reference_score + margin` for additive assays\n        and `reference_score * margin` for multiplicative assays. Note: for multiplicative assays, the `margin` must be positive.\n\n        As an example, to tighten a constraint on a multiplicative assay with direction `MAXIMIZE`, specify a `margin`\n        greater than 1.0. Alternatively, if the direction is `MINIMIZE`, specify a `margin` less than 1.0.\n        ",
546    )

A constraint or objective relative to a reference assembly.

reference: MonomerAssembly | VhVlAssembly = PydanticUndefined

The reference assembly.

margin: float | None = None

The desired margin relative to the reference assembly.

    Denoting the score of the `reference` assembly as `reference_score`, the effective threshold will be `reference_score + margin` for additive assays
    and `reference_score * margin` for multiplicative assays. Note: for multiplicative assays, the `margin` must be positive.

    As an example, to tighten a constraint on a multiplicative assay with direction `MAXIMIZE`, specify a `margin`
    greater than 1.0. Alternatively, if the direction is `MINIMIZE`, specify a `margin` less than 1.0.
class Requirement(pydantic.main.BaseModel):
549class Requirement(BaseModel):
550    """Assembly generation requirements specifying required and forbidden features on the generated assemblies.
551
552    Each requirement defines constraints for specific motifs in specific ranges of the assembly.
553    The `operator` field determines how motif-range pairs are combined:
554    - operator="all": *All* motif-range pairs must match
555    - operator="any": *At least one* motif-range pair must match
556    - operator="none": *No* motif-range pairs must match
557
558    When multiple requirements are provided in a list, *all* requirements must be satisfied.
559
560    Examples:
561    1. Block mutations to Methionine ("M") across the entire heavy and light chains to prevent oxidation:
562
563       Requirement(
564           motifs=["M"],
565           apply_to=RangeAnnotation(ranges={"vh": [(0, 120)], "vl": [(0, 110)]}),
566           operator="none",
567       )
568
569    2. Avoid deamidation motifs ("NG", "NS", "NT") in the heavy chain:
570
571       Requirement(
572           motifs=["NG", "NS", "NT"],
573           apply_to=RangeAnnotation(ranges={"vh": [(0, 120)]}),
574           operator="none",
575       )
576
577    3. Ensure Cysteines are present at positions 22 and 96 in the heavy chain:
578
579       Requirement(
580           motifs=["C"],
581           apply_to=RangeAnnotation(ranges={"vh": [(22, 23), (96, 97)]}),
582           operator="all",
583       )
584    """
585
586    apply_to: RangeAnnotation
587    motifs: list[Annotated[str, Field(description="A motif or regular expression of amino acids.")]]
588    operator: Literal["none", "all", "any"] = Field(
589        description="The choice of how to interpret the motif-range pairs as a single requirement."
590    )

Assembly generation requirements specifying required and forbidden features on the generated assemblies.

Each requirement defines constraints for specific motifs in specific ranges of the assembly. The operator field determines how motif-range pairs are combined:

  • operator="all": All motif-range pairs must match
  • operator="any": At least one motif-range pair must match
  • operator="none": No motif-range pairs must match

When multiple requirements are provided in a list, all requirements must be satisfied.

Examples:

  1. Block mutations to Methionine ("M") across the entire heavy and light chains to prevent oxidation:

Requirement( motifs=["M"], apply_to=RangeAnnotation(ranges={"vh": [(0, 120)], "vl": [(0, 110)]}), operator="none", )

  1. Avoid deamidation motifs ("NG", "NS", "NT") in the heavy chain:

    Requirement( motifs=["NG", "NS", "NT"], apply_to=RangeAnnotation(ranges={"vh": [(0, 120)]}), operator="none", )

  2. Ensure Cysteines are present at positions 22 and 96 in the heavy chain:

    Requirement( motifs=["C"], apply_to=RangeAnnotation(ranges={"vh": [(22, 23), (96, 97)]}), operator="all", )

apply_to: RangeAnnotation = PydanticUndefined
motifs: list[typing.Annotated[str, FieldInfo(annotation=NoneType, required=True, description='A motif or regular expression of amino acids.')]] = PydanticUndefined
operator: Literal['none', 'all', 'any'] = PydanticUndefined

The choice of how to interpret the motif-range pairs as a single requirement.

class SamplerConditioningParameters(cradle.sdk.types.tasks.common.ParametersBase):
593class SamplerConditioningParameters(ParametersBase):
594    task_type: ClassVar[str] = "condition_sampler/v2"
595
596    data: MonomerSamplerConditioningData | VhVlSamplerConditioningData = Field(
597        description="The training and validation data along with the pre-trained sampler model.", discriminator="kind"
598    )
599    primary_objective: Measure = Field(
600        description="The assay on which to condition the sampler model. Must correspond to an assay present in the datasets."
601    )

Class that marks top-level task inputs. Used for static checks.

task_type: ClassVar[str] = 'condition_sampler/v2'

The training and validation data along with the pre-trained sampler model.

primary_objective: Measure = PydanticUndefined

The assay on which to condition the sampler model. Must correspond to an assay present in the datasets.

class SamplerConditioningResult(cradle.sdk.types.tasks.common.ResultBase):
604class SamplerConditioningResult(ResultBase):
605    models: MonomerSamplerConditioningResult | VhVlSamplerConditioningResult = Field(
606        description="The conditioned sampler.", discriminator="kind"
607    )
608    report: ArtifactParam | None = Field(default=None, description="A report on the result of the task.")

Class that marks top-level task results. Used for static checks.

The conditioned sampler.

A report on the result of the task.

class SamplerInferenceParameters(cradle.sdk.types.tasks.common.ParametersBase):
611class SamplerInferenceParameters(ParametersBase):
612    """Parameters for the sampler inference endpoint.
613
614    Runs a trained sampler over a set of sequences and emits per-sequence sampler
615    scores into the ``cradle.inferences.sampler_predictions`` BigQuery table.
616    """
617
618    task_type: ClassVar[str] = "inference_sampler/v2"
619
620    sampler_input: MonomerSamplerInput | VhVlSamplerInput = Field(
621        description="Assemblies and sampler model to use for inference.", discriminator="kind"
622    )
623    hyperparameters: dict[str, Any] = Field(
624        default_factory=dict,
625        description="A dictionary of hyperparameter overrides to apply to the default hyperparameters used by the task.",
626    )

Parameters for the sampler inference endpoint.

Runs a trained sampler over a set of sequences and emits per-sequence sampler scores into the cradle.inferences.sampler_predictions BigQuery table.

task_type: ClassVar[str] = 'inference_sampler/v2'
sampler_input: MonomerSamplerInput | VhVlSamplerInput = PydanticUndefined

Assemblies and sampler model to use for inference.

hyperparameters: dict[str, typing.Any] = PydanticUndefined

A dictionary of hyperparameter overrides to apply to the default hyperparameters used by the task.

class SamplerInferenceResult(cradle.sdk.types.tasks.common.ResultBase):
629class SamplerInferenceResult(ResultBase):
630    pass

Class that marks top-level task results. Used for static checks.

class SamplingNoise(pydantic.main.BaseModel):
633class SamplingNoise(BaseModel):
634    """Configuration for MC-dropout score sampling. When omitted on the scorer input, un-noised scores are returned."""
635
636    num_samples: int = Field(
637        default=64, description="Number of score samples to draw per ensemble member and property."
638    )
639    dropout_p: float = Field(default=0.3, description="Dropout probability used to generate score samples.")
640    noise_seed: int | None = Field(
641        default=None,
642        description="Seed for noise generation. If None, a fixed default seed is used for reproducibility.",
643    )

Configuration for MC-dropout score sampling. When omitted on the scorer input, un-noised scores are returned.

num_samples: int = 64

Number of score samples to draw per ensemble member and property.

dropout_p: float = 0.3

Dropout probability used to generate score samples.

noise_seed: int | None = None

Seed for noise generation. If None, a fixed default seed is used for reproducibility.

class ScoreBasedFilterer(pydantic.main.BaseModel):
646class ScoreBasedFilterer(BaseModel):
647    """Filters assemblies based on whether predicted performance meets constraints.
648
649    The scorer evaluates assemblies and only those that meet all specified constraints are retained.
650    This can, for example, be used to incorporate in-silico metrics in assembly generation.
651    """
652
653    kind: Literal["SCORED_FILTERER"] = Field(default="SCORED_FILTERER")
654    scorer: MonomerScorerRef | VhVlScorerRef = Field(
655        description="The scorer used to evaluate assemblies for filtering.", discriminator="kind"
656    )
657    constraints: list[Constraint] = Field(
658        default_factory=list, description="List of constraints to apply during filtering.", max_length=50
659    )

Filters assemblies based on whether predicted performance meets constraints.

The scorer evaluates assemblies and only those that meet all specified constraints are retained. This can, for example, be used to incorporate in-silico metrics in assembly generation.

kind: Literal['SCORED_FILTERER'] = 'SCORED_FILTERER'
scorer: MonomerScorerRef | VhVlScorerRef = PydanticUndefined

The scorer used to evaluate assemblies for filtering.

constraints: list[Constraint] = PydanticUndefined

List of constraints to apply during filtering.

class ScoreBasedRanker(pydantic.main.BaseModel):
662class ScoreBasedRanker(BaseModel):
663    """Configuration for ranking and selecting generated assemblies."""
664
665    type: Literal["SCORE_BASED"] = Field(default="SCORE_BASED")
666    primary_objective: PrimaryObjective = Field(description="The primary optimization objective of `engineer`.")
667    constraints: list[Constraint] = Field(
668        default_factory=list, description="List of constraints `engineer` will attempt to satisfy.", max_length=50
669    )
670    scorer_config: MonomerScorerConfig | VhVlScorerConfig = Field(
671        description="The trained scoring model artifact used to score sequences, along with any optional control sequences to include in the final output for experimental validation.",
672        discriminator="kind",
673    )
674    hit_redundancy: int | None = Field(
675        default=None,
676        description='The maximum number of similar variants within the proposed set.\n\nWe say two variants are "similar" when their predicted performances are highly correlated.\nAt lower values this will mean on average fewer hits, but greater diversity within the set,\nwhile at maximum value (`hit_redundancy` equals the number of assemblies to select) the selection is purely greedy, with\nno requirement on diversity within the set. If set to None, it will be automatically set\nto a default value of `1 + num_assemblies//20`.',
677    )

Configuration for ranking and selecting generated assemblies.

type: Literal['SCORE_BASED'] = 'SCORE_BASED'
primary_objective: PrimaryObjective = PydanticUndefined

The primary optimization objective of engineer.

constraints: list[Constraint] = PydanticUndefined

List of constraints engineer will attempt to satisfy.

scorer_config: MonomerScorerConfig | VhVlScorerConfig = PydanticUndefined

The trained scoring model artifact used to score sequences, along with any optional control sequences to include in the final output for experimental validation.

hit_redundancy: int | None = None

The maximum number of similar variants within the proposed set.

We say two variants are "similar" when their predicted performances are highly correlated. At lower values this will mean on average fewer hits, but greater diversity within the set, while at maximum value (hit_redundancy equals the number of assemblies to select) the selection is purely greedy, with no requirement on diversity within the set. If set to None, it will be automatically set to a default value of 1 + num_assemblies//20.

class ScorerInferenceParameters(cradle.sdk.types.tasks.common.ParametersBase):
680class ScorerInferenceParameters(ParametersBase):
681    """Parameters for the scorer inference endpoint.
682
683    Runs inference using a trained scorer ensemble and emits per-sequence scores
684    into ``cradle.inferences.scorer_predictions``. When a noise configuration is provided
685    on the scorer input, produces MC-dropout score samples; otherwise returns un-noised
686    deterministic scores (``num_samples=1``). For each property the output is a flat array
687    of shape ``[num_models, num_samples]`` representing either the predicted value above the
688    property's reference, in direction-normalised log space (if `score_by` is provided) or
689    the raw scorer values otherwise.
690    """
691
692    task_type: ClassVar[str] = "inference_scorer/v2"
693
694    scorer_input: MonomerScorerInput | VhVlScorerInput = Field(
695        description="Assemblies and scorer model to use for inference.", discriminator="kind"
696    )
697    score_by: ObjectivesAndConstraints | None = Field(
698        description="Defines the properties to evaluate: a primary objective and/or constraints."
699    )
700    hyperparameters: dict[str, Any] = Field(
701        default_factory=dict,
702        description="A dictionary of hyperparameter overrides to apply to the default hyperparameters used by the task.",
703    )

Parameters for the scorer inference endpoint.

Runs inference using a trained scorer ensemble and emits per-sequence scores into cradle.inferences.scorer_predictions. When a noise configuration is provided on the scorer input, produces MC-dropout score samples; otherwise returns un-noised deterministic scores (num_samples=1). For each property the output is a flat array of shape [num_models, num_samples] representing either the predicted value above the property's reference, in direction-normalised log space (if score_by is provided) or the raw scorer values otherwise.

task_type: ClassVar[str] = 'inference_scorer/v2'
scorer_input: MonomerScorerInput | VhVlScorerInput = PydanticUndefined

Assemblies and scorer model to use for inference.

score_by: ObjectivesAndConstraints | None = PydanticUndefined

Defines the properties to evaluate: a primary objective and/or constraints.

hyperparameters: dict[str, typing.Any] = PydanticUndefined

A dictionary of hyperparameter overrides to apply to the default hyperparameters used by the task.

class ScorerInferenceResult(cradle.sdk.types.tasks.common.ResultBase):
706class ScorerInferenceResult(ResultBase):
707    pass

Class that marks top-level task results. Used for static checks.

class SearchParameters(cradle.sdk.types.tasks.common.ParametersBase):
710class SearchParameters(ParametersBase):
711    task_type: ClassVar[str] = "search/v2"
712
713    source: UnirefDatabaseSearch | OASDatabaseSearch = Field(
714        description="The source database to search against, along with the assemblies to search for, and database-specific configuration.",
715        discriminator="type_",
716    )

Class that marks top-level task inputs. Used for static checks.

task_type: ClassVar[str] = 'search/v2'
source: UnirefDatabaseSearch | OASDatabaseSearch = PydanticUndefined

The source database to search against, along with the assemblies to search for, and database-specific configuration.

class SearchResult(cradle.sdk.types.tasks.common.ResultBase):
719class SearchResult(ResultBase):
720    assembly_features: list[dict[str, AssemblyFeature]] = Field(
721        default_factory=list,
722        description="Parallel array (wrt to `seed_assemblies`) of features, keyed by feature name.",
723    )
724    homologs: TableResult
725    report: ArtifactParam | None = Field(default=None, description="A report on the result of the task.")

Class that marks top-level task results. Used for static checks.

assembly_features: list[dict[str, AssemblyFeature]] = PydanticUndefined

Parallel array (wrt to seed_assemblies) of features, keyed by feature name.

homologs: cradle.sdk.types.tasks.common.TableResult = PydanticUndefined

A report on the result of the task.

class SelectParameters(cradle.sdk.types.tasks.common.ParametersBase):
728class SelectParameters(ParametersBase):
729    """Parameters for the select task."""
730
731    task_type: ClassVar[str] = "select/v2"
732
733    assemblies: MonomerSource | VhVlSource = Field(description="The source of assemblies to select from.")
734    ranker: (
735        Annotated[
736            LikelihoodBasedRanker | ScoreBasedRanker,
737            Field(description="The ranking strategy for selecting candidate assemblies.", discriminator="type"),
738        ]
739        | PreRanked
740    ) = Field(
741        description="The configuration defining how candidate assemblies are evaluated for inclusion in `selected_assemblies`."
742    )
743    min_assemblies_to_select: int = Field(
744        description="The minimum number of assemblies to select. The number of selected candidates is dynamically determined and may be greater than this number. If an exact number of assemblies is desired, set `min_assemblies_to_select` and `max_assemblies_to_select` to the same value."
745    )
746    max_assemblies_to_select: int | None = Field(
747        default=None,
748        description="An optional (inclusive) upper limit on the number of assemblies to select. If provided, the task will select between `min_assemblies_to_select` and `max_assemblies_to_select` assemblies.",
749    )

Parameters for the select task.

task_type: ClassVar[str] = 'select/v2'
assemblies: MonomerSource | VhVlSource = PydanticUndefined

The source of assemblies to select from.

ranker: Union[Annotated[LikelihoodBasedRanker | ScoreBasedRanker, FieldInfo(annotation=NoneType, required=True, description='The ranking strategy for selecting candidate assemblies.', discriminator='type')], PreRanked] = PydanticUndefined

The configuration defining how candidate assemblies are evaluated for inclusion in selected_assemblies.

min_assemblies_to_select: int = PydanticUndefined

The minimum number of assemblies to select. The number of selected candidates is dynamically determined and may be greater than this number. If an exact number of assemblies is desired, set min_assemblies_to_select and max_assemblies_to_select to the same value.

max_assemblies_to_select: int | None = None

An optional (inclusive) upper limit on the number of assemblies to select. If provided, the task will select between min_assemblies_to_select and max_assemblies_to_select assemblies.

class SelectResult(cradle.sdk.types.tasks.common.ResultBase):
752class SelectResult(ResultBase):
753    """Result of the select task."""
754
755    selected_assemblies: TableResult = Field(
756        description="Table containing the selected assemblies output by `select` sorted in descending order of preference."
757    )

Result of the select task.

selected_assemblies: cradle.sdk.types.tasks.common.TableResult = PydanticUndefined

Table containing the selected assemblies output by select sorted in descending order of preference.

class Sequential(pydantic.main.BaseModel):
760class Sequential(BaseModel):
761    """An ensemble of generators to evaluate sequentially.
762
763    Each generator will have the opportunity to evaluate an equal number of candidate
764    assemblies. However, if earlier generators are able to satisfy the requirements of
765    the `ranker`, later generators may never be used. In this way this method of
766    ensembling expresses a strict preference among the generators in `ensemble`.
767    """
768
769    type: Literal["SEQUENTIAL"] = Field(default="SEQUENTIAL")
770    ensemble: list[
771        Annotated[
772            Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator,
773            Field(description="The generation strategy for creating candidate sequences.", discriminator="type"),
774        ]
775    ] = Field(default_factory=list, description="The list of generators to run in sequence within this ensemble.")
776    alias: str | None = Field(
777        default=None,
778        description="Optional alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. If provided, this name will appear in the `generator_provenance` column for rows in `selected_sequences` which were produced by this generator.",
779    )

An ensemble of generators to evaluate sequentially.

Each generator will have the opportunity to evaluate an equal number of candidate assemblies. However, if earlier generators are able to satisfy the requirements of the ranker, later generators may never be used. In this way this method of ensembling expresses a strict preference among the generators in ensemble.

type: Literal['SEQUENTIAL'] = 'SEQUENTIAL'
ensemble: list[typing.Annotated[Sequential | Parallel | ModelBasedGenerator | Explicit | CombinatorialGenerator, FieldInfo(annotation=NoneType, required=True, description='The generation strategy for creating candidate sequences.', discriminator='type')]] = PydanticUndefined

The list of generators to run in sequence within this ensemble.

alias: str | None = None

Optional alias to refer to this generator within the task. Useful for tracking provenance of assemblies generated by this generator. If provided, this name will appear in the generator_provenance column for rows in selected_sequences which were produced by this generator.

class TrainBaseModelParameters(cradle.sdk.types.tasks.common.ParametersBase):
782class TrainBaseModelParameters(ParametersBase):
783    """Parameters for the base model training (evotuning) task.
784
785    This task fine-tunes a pretrained language model on a set of homologous sequences using masked language modeling.
786    The resulting model can be used as a sampler for downstream generation tasks.
787    """
788
789    task_type: ClassVar[str] = "train_base_model/v2"
790
791    data: MonomerHomologsData | VhVlHomologsData = Field(
792        description="Homologous sequences for training the base model. The model learns the sequence distribution of the provided protein family.",
793        discriminator="kind",
794    )

Parameters for the base model training (evotuning) task.

This task fine-tunes a pretrained language model on a set of homologous sequences using masked language modeling. The resulting model can be used as a sampler for downstream generation tasks.

task_type: ClassVar[str] = 'train_base_model/v2'
data: MonomerHomologsData | VhVlHomologsData = PydanticUndefined

Homologous sequences for training the base model. The model learns the sequence distribution of the provided protein family.

class TrainBaseModelResult(cradle.sdk.types.tasks.common.ResultBase):
797class TrainBaseModelResult(ResultBase):
798    """Result of the base model training task."""
799
800    models: MonomerTrainBaseModelResult | VhVlTrainBaseModelResult = Field(
801        description="The trained sampler model.", discriminator="kind"
802    )
803    report: ArtifactParam | None = Field(default=None, description="Training report with metrics and diagnostics.")

Result of the base model training task.

The trained sampler model.

Training report with metrics and diagnostics.

class TrainParameters(cradle.sdk.types.tasks.common.ParametersBase):
806class TrainParameters(ParametersBase):
807    task_type: ClassVar[str] = "train/v2"
808
809    data: MonomerData | VhVlData = Field(
810        description="The training data, including homologs and assayed sequences.", discriminator="kind"
811    )
812    assays: list[Assay] = Field(
813        default_factory=list,
814        description="The assays used for sampler conditioning (on the `primary_objective`) and scorer finetuning and evaluation. Must correspond to assays present in `data.dataset`. If `data.dataset` is None, `assays` must be empty. Otherwise, it must contain at least one assay.",
815        max_length=50,
816    )
817    primary_objective: Measure | None = Field(
818        default=None,
819        description="The assay on which the sampler model is conditioned. Should correspond to an assay in `dataset`. If `data.dataset` is None, `primary_objective` must not be set. Otherwise, it must be set.",
820    )

Class that marks top-level task inputs. Used for static checks.

task_type: ClassVar[str] = 'train/v2'
data: MonomerData | VhVlData = PydanticUndefined

The training data, including homologs and assayed sequences.

assays: list[Assay] = PydanticUndefined

The assays used for sampler conditioning (on the primary_objective) and scorer finetuning and evaluation. Must correspond to assays present in data.dataset. If data.dataset is None, assays must be empty. Otherwise, it must contain at least one assay.

primary_objective: Measure | None = None

The assay on which the sampler model is conditioned. Should correspond to an assay in dataset. If data.dataset is None, primary_objective must not be set. Otherwise, it must be set.

class TrainResult(cradle.sdk.types.tasks.common.ResultBase):
823class TrainResult(ResultBase):
824    models: MonomerModels | VhVlModels = Field(description="The trained models.", discriminator="kind")
825    report: ArtifactParam | None = Field(description="A report on the result of the task.")

Class that marks top-level task results. Used for static checks.

models: MonomerModels | VhVlModels = PydanticUndefined

The trained models.

report: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

A report on the result of the task.

class TrainScorerParameters(cradle.sdk.types.tasks.common.ParametersBase):
828class TrainScorerParameters(ParametersBase):
829    task_type: ClassVar[str] = "train_scorer/v2"
830
831    data: MonomerTrainScorerInputs | VhVlTrainScorerInputs = Field(
832        description="The training data and pre-trained base model for scorer training.", discriminator="kind"
833    )
834    assays: list[Assay] = Field(
835        default_factory=list,
836        description="The assays used for scorer training and evaluation. Must correspond to assays present in `data.dataset`. Must contain at least one assay.",
837        max_length=50,
838    )

Class that marks top-level task inputs. Used for static checks.

task_type: ClassVar[str] = 'train_scorer/v2'
data: MonomerTrainScorerInputs | VhVlTrainScorerInputs = PydanticUndefined

The training data and pre-trained base model for scorer training.

assays: list[Assay] = PydanticUndefined

The assays used for scorer training and evaluation. Must correspond to assays present in data.dataset. Must contain at least one assay.

class TrainScorerResult(cradle.sdk.types.tasks.common.ResultBase):
841class TrainScorerResult(ResultBase):
842    scorer_model: MonomerScorerModel | VhVlScorerModel = Field(
843        description="The trained scorer model.", discriminator="kind"
844    )
845    report: ArtifactParam | None = Field(default=None, description="A report on the result of the task.")

Class that marks top-level task results. Used for static checks.

scorer_model: MonomerScorerModel | VhVlScorerModel = PydanticUndefined

The trained scorer model.

A report on the result of the task.

class UnirefDatabaseSearch(pydantic.main.BaseModel):
848class UnirefDatabaseSearch(BaseModel):
849    type_: Literal["UNIREF_SEARCH"] = Field(default="UNIREF_SEARCH", alias="type")
850    seed_assemblies: list[MonomerAssembly] = Field(
851        description="A list of monomeric assemblies to search for.", min_length=1, max_length=100
852    )
type_: Literal['UNIREF_SEARCH'] = 'UNIREF_SEARCH'
seed_assemblies: list[MonomerAssembly] = PydanticUndefined

A list of monomeric assemblies to search for.

class VhVlAssembly(pydantic.main.BaseModel):
855class VhVlAssembly(BaseModel):
856    """An assembly of a VH and a VL chain."""
857
858    vh: str | None = Field(default=None, description="The heavy chain sequence.")
859    vl: str | None = Field(default=None, description="The light chain sequence.")

An assembly of a VH and a VL chain.

vh: str | None = None

The heavy chain sequence.

vl: str | None = None

The light chain sequence.

class VhVlData(pydantic.main.BaseModel):
862class VhVlData(BaseModel):
863    kind: Literal["VHVL"] = Field(default="VHVL")
864    homologs: (
865        list
866        | Annotated[
867            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
868            Field(discriminator="kind"),
869        ]
870    ) = Field(description="The homologous assemblies used for training.")
871    dataset: (
872        list
873        | Annotated[
874            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
875            Field(discriminator="kind"),
876        ]
877        | None
878    ) = Field(
879        description="The assayed assemblies used for training. If None, predictor finetuning and generator conditioning will be skipped."
880    )
kind: Literal['VHVL'] = 'VHVL'

The homologous assemblies used for training.

The assayed assemblies used for training. If None, predictor finetuning and generator conditioning will be skipped.

class VhVlHomologsData(pydantic.main.BaseModel):
883class VhVlHomologsData(BaseModel):
884    """VH/VL homolog sequences for base model training."""
885
886    kind: Literal["VHVL"] = Field(default="VHVL")
887    homologs: (
888        list
889        | Annotated[
890            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
891            Field(discriminator="kind"),
892        ]
893    ) = Field(
894        description="Homologous antibody sequences used for training. These sequences should be evolutionarily related to the target antibody family."
895    )

VH/VL homolog sequences for base model training.

kind: Literal['VHVL'] = 'VHVL'

Homologous antibody sequences used for training. These sequences should be evolutionarily related to the target antibody family.

class VhVlModels(pydantic.main.BaseModel):
898class VhVlModels(BaseModel):
899    kind: Literal["VH_VL"] = Field(default="VH_VL")
900    sampler: ArtifactParam = Field(description="The VhVl sampler model.")
901    scorer: ArtifactParam | None = Field(description="The VhVl scorer model.")
902    conditioned_sampler: ArtifactParam | None = Field(
903        description="The VhVl sampler model conditioned on the primary objective."
904    )
kind: Literal['VH_VL'] = 'VH_VL'
sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The VhVl sampler model.

scorer: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

The VhVl scorer model.

conditioned_sampler: cradle.sdk.types.tasks.common.ArtifactParam | None = PydanticUndefined

The VhVl sampler model conditioned on the primary objective.

class VhVlSamplerConditioningData(pydantic.main.BaseModel):
907class VhVlSamplerConditioningData(BaseModel):
908    kind: Literal["VH_VL"] = Field(default="VH_VL")
909    train_dataset: (
910        list
911        | Annotated[
912            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
913            Field(discriminator="kind"),
914        ]
915    ) = Field(description="The training dataset containing assayed assemblies.")
916    val_dataset: (
917        list
918        | Annotated[
919            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
920            Field(discriminator="kind"),
921        ]
922        | None
923    ) = Field(
924        default=None,
925        description="The validation dataset containing assayed assemblies. If not set, the training dataset will be split to create a validation dataset.",
926    )
927    sampler: ArtifactParam = Field(description="The pre-trained sampler model to condition.")
kind: Literal['VH_VL'] = 'VH_VL'

The training dataset containing assayed assemblies.

The validation dataset containing assayed assemblies. If not set, the training dataset will be split to create a validation dataset.

sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The pre-trained sampler model to condition.

class VhVlSamplerConditioningResult(pydantic.main.BaseModel):
930class VhVlSamplerConditioningResult(BaseModel):
931    kind: Literal["VH_VL"] = Field(default="VH_VL")
932    conditioned_sampler: ArtifactParam = Field(description="The conditioned sampler model.")
kind: Literal['VH_VL'] = 'VH_VL'
conditioned_sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The conditioned sampler model.

class VhVlSamplerConfig(pydantic.main.BaseModel):
935class VhVlSamplerConfig(BaseModel):
936    """Configuration for a VhVl sampler."""
937
938    kind: Literal["VHVL_SAMPLER"] = Field(default="VHVL_SAMPLER")
939    sampler: ArtifactParam = Field(description="The trained sampler artifact used to compute assembly likelihoods.")
940    reference_assembly: VhVlAssembly = Field(
941        description="The reference assembly used as the denominator when computing assembly likelihood ratios."
942    )
943    controls: (
944        list
945        | Annotated[
946            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
947            Field(discriminator="kind"),
948        ]
949        | None
950    ) = Field(
951        default=None,
952        description="Optional control assemblies to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_assemblies` will be intentionally diverse from these assemblies. However these assemblies will *not* be included in the `selected_assemblies` output table, so -- if used -- take care to re-include them. ",
953    )

Configuration for a VhVl sampler.

kind: Literal['VHVL_SAMPLER'] = 'VHVL_SAMPLER'
sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler artifact used to compute assembly likelihoods.

reference_assembly: VhVlAssembly = PydanticUndefined

The reference assembly used as the denominator when computing assembly likelihood ratios.

Optional control assemblies to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as selected_assemblies will be intentionally diverse from these assemblies. However these assemblies will not be included in the selected_assemblies output table, so -- if used -- take care to re-include them.

class VhVlSamplerInput(pydantic.main.BaseModel):
956class VhVlSamplerInput(BaseModel):
957    kind: Literal["VHVL"] = Field(default="VHVL")
958    assemblies: (
959        list
960        | Annotated[
961            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
962            Field(discriminator="kind"),
963        ]
964    ) = Field(description="VH/VL assemblies to run inference on.")
965    sampler: ArtifactParam = Field(description="The trained sampler model.")
966    reference_assembly: VhVlAssembly | None = Field(
967        default=None,
968        description="Optional reference assembly for computing pseudo log-likelihood ratios. All assemblies must be the same length as the reference assembly. When omitted, raw pseudo log-likelihoods are returned.",
969    )
kind: Literal['VHVL'] = 'VHVL'

VH/VL assemblies to run inference on.

sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler model.

reference_assembly: VhVlAssembly | None = None

Optional reference assembly for computing pseudo log-likelihood ratios. All assemblies must be the same length as the reference assembly. When omitted, raw pseudo log-likelihoods are returned.

class VhVlSamplingTemplate(pydantic.main.BaseModel):
972class VhVlSamplingTemplate(BaseModel):
973    kind: Literal["VHVL"] = Field(default="VHVL")
974    assembly: VhVlAssembly = Field(description="The template sequence to use for generation.")
975    sampler: ArtifactParam = Field(description="The trained sampler artifact used to generate candidate sequences.")
kind: Literal['VHVL'] = 'VHVL'
assembly: VhVlAssembly = PydanticUndefined

The template sequence to use for generation.

sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler artifact used to generate candidate sequences.

class VhVlScorerConfig(pydantic.main.BaseModel):
978class VhVlScorerConfig(BaseModel):
979    """Configuration for a VhVl scorer."""
980
981    kind: Literal["VHVL_SCORER"] = Field(default="VHVL_SCORER")
982    scorer: ArtifactParam = Field(description="The trained scoring model artifact used to score sequences.")
983    controls: (
984        list
985        | Annotated[
986            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
987            Field(discriminator="kind"),
988        ]
989        | None
990    ) = Field(
991        default=None,
992        description="Optional control sequences to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as `selected_sequences` will be intentionally diverse from these sequences. However these sequences will *not* be included in the `selected_sequences` output table, so -- if used -- take care to re-include them. ",
993    )

Configuration for a VhVl scorer.

kind: Literal['VHVL_SCORER'] = 'VHVL_SCORER'
scorer: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained scoring model artifact used to score sequences.

Optional control sequences to include in the final output for experimental validation. These controls should generally be included in the assayed plate, as selected_sequences will be intentionally diverse from these sequences. However these sequences will not be included in the selected_sequences output table, so -- if used -- take care to re-include them.

class VhVlScorerInput(pydantic.main.BaseModel):
 996class VhVlScorerInput(BaseModel):
 997    kind: Literal["VHVL"] = Field(default="VHVL")
 998    assemblies: (
 999        list
1000        | Annotated[
1001            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
1002            Field(discriminator="kind"),
1003        ]
1004    ) = Field(description="VH/VL assemblies to run inference on.")
1005    scorer: ArtifactParam | CustomPredictorParam = Field(
1006        description="VH/VL  scorer model. Can be a referenceto a custom predictor."
1007    )
1008    noise: SamplingNoise | None = Field(
1009        default=None,
1010        description="MC-dropout noise configuration. When omitted, returns un-noised deterministic scores.",
1011    )
kind: Literal['VHVL'] = 'VHVL'

VH/VL assemblies to run inference on.

VH/VL scorer model. Can be a referenceto a custom predictor.

noise: SamplingNoise | None = None

MC-dropout noise configuration. When omitted, returns un-noised deterministic scores.

class VhVlScorerModel(pydantic.main.BaseModel):
1014class VhVlScorerModel(BaseModel):
1015    kind: Literal["VH_VL"] = Field(default="VH_VL")
1016    scorer: ArtifactParam = Field(description="The trained scorer model for antibody sequences.")
kind: Literal['VH_VL'] = 'VH_VL'
scorer: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained scorer model for antibody sequences.

class VhVlScorerRef(pydantic.main.BaseModel):
1019class VhVlScorerRef(BaseModel):
1020    """A reference to a VH/VL scorer model."""
1021
1022    kind: Literal["VHVL"] = Field(default="VHVL")
1023    scorer: ArtifactParam | CustomPredictorParam = Field(
1024        description="VH/VL scorer model. Can be a reference to a custom predictor."
1025    )

A reference to a VH/VL scorer model.

kind: Literal['VHVL'] = 'VHVL'

VH/VL scorer model. Can be a reference to a custom predictor.

class VhVlSource(pydantic.main.BaseModel):
1028class VhVlSource(BaseModel):
1029    """A source of VH/VL assemblies."""
1030
1031    kind: Literal["VHVL"] = Field(default="VHVL")
1032    source: (
1033        list
1034        | Annotated[
1035            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
1036            Field(discriminator="kind"),
1037        ]
1038    )

A source of VH/VL assemblies.

kind: Literal['VHVL'] = 'VHVL'
class VhVlTrainBaseModelResult(pydantic.main.BaseModel):
1041class VhVlTrainBaseModelResult(BaseModel):
1042    """Result containing a trained VH/VL sampler."""
1043
1044    kind: Literal["VHVL"] = Field(default="VHVL")
1045    sampler: ArtifactParam = Field(
1046        description="The trained sampler model that can be used for antibody sequence generation."
1047    )

Result containing a trained VH/VL sampler.

kind: Literal['VHVL'] = 'VHVL'
sampler: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The trained sampler model that can be used for antibody sequence generation.

class VhVlTrainScorerInputs(pydantic.main.BaseModel):
1050class VhVlTrainScorerInputs(BaseModel):
1051    kind: Literal["VHVL"] = Field(default="VHVL")
1052    dataset: (
1053        list
1054        | Annotated[
1055            TableSourceTable | TableSourceQuery | TableSourceTaskResult | TableSourceSnapshot | TableSourceLiteral,
1056            Field(discriminator="kind"),
1057        ]
1058    ) = Field(description="The dataset containing assayed assemblies for training the scorer.")
1059    base_model: ArtifactParam = Field(description="The pre-trained base model (sampler) to use for scorer training.")
kind: Literal['VHVL'] = 'VHVL'

The dataset containing assayed assemblies for training the scorer.

base_model: cradle.sdk.types.tasks.common.ArtifactParam = PydanticUndefined

The pre-trained base model (sampler) to use for scorer training.