Parameters - Snailz Docs

Skip to content

# Parameters

Parameter classes.

## `AssayParams`

Bases: `BaseModel`

Parameters for assay generation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`baseline` | `float` | Baseline reading value | `1.0`
`degrade` | `float` | Rate at which sample responses decrease per day after first day (0..1) | `0.05`
`delay` | `int` | Maximum number of days between specimen collection and assay | `5`
`mutant` | `float` | Mutant reading value (must be positive) | `5.0`
`rel_stdev` | `float` | Relative standard deviation in readings | `0.2`
`plate_size` | `int` | Size of assay plate (must be positive) | `4`
`image_noise` | `int` | Plate image noise (grayscale 0-255) | `32`
`p_duplicate_assay` | `float` | Probably that an assay is repeated | `0.05`

Source code in `src/snailz/parameters.py`

    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    class AssayParams(BaseModel):
        """Parameters for assay generation."""

        baseline: float = Field(default=1.0, ge=0.0, description="Baseline reading value")
        degrade: float = Field(
            default=0.05,
            ge=0.0,
            le=1.0,
            description="Rate at which sample responses decrease per day after first day (0..1)",
        )
        delay: int = Field(
            default=5,
            gt=0,
            description="Maximum number of days between specimen collection and assay",
        )
        mutant: float = Field(
            default=5.0, gt=0.0, description="Mutant reading value (must be positive)"
        )
        rel_stdev: float = Field(
            default=0.2, ge=0.0, description="Relative standard deviation in readings"
        )
        plate_size: int = Field(
            default=DEFAULT_PLATE_SIZE,
            gt=0,
            description="Size of assay plate (must be positive)",
        )
        image_noise: int = Field(
            default=32,
            ge=0,
            le=255,
            description="Plate image noise (grayscale 0-255)",
        )
        p_duplicate_assay: float = Field(
            default=0.05, ge=0, description="Probably that an assay is repeated"
        )

        model_config = {"extra": "forbid"}

        @model_validator(mode="after")
        def validate_fields(self):
            """Validate requirements on fields."""
            if self.mutant < self.baseline:
                raise ValueError("mutant value must be greater than baseline")
            return self

### `validate_fields()`

Validate requirements on fields.

Source code in `src/snailz/parameters.py`

    59
    60
    61
    62
    63
    64
    @model_validator(mode="after")
    def validate_fields(self):
        """Validate requirements on fields."""
        if self.mutant < self.baseline:
            raise ValueError("mutant value must be greater than baseline")
        return self

## `MachineParams`

Bases: `BaseModel`

Parameters for machine generation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`number` | `int` | Number of machines | `5`
`variation` | `float` | Camera variation | `0.15`

Source code in `src/snailz/parameters.py`

    67
    68
    69
    70
    71
    72
    73
    class MachineParams(BaseModel):
        """Parameters for machine generation."""

        number: int = Field(default=5, gt=0, description="Number of machines")
        variation: float = Field(default=0.15, ge=0, description="Camera variation")

        model_config = {"extra": "forbid"}

## `PersonParams`

Bases: `BaseModel`

Parameters for people generation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`locale` | `str` | Locale for names | `'et_EE'`
`number` | `int` | Number of people | `5`

Source code in `src/snailz/parameters.py`

    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    class PersonParams(BaseModel):
        """Parameters for people generation."""

        locale: str = Field(default=DEFAULT_LOCALE, description="Locale for names")
        number: int = Field(default=5, gt=0, description="Number of people")

        model_config = {"extra": "forbid"}

        @field_validator("locale")
        def validate_fields(cls, v):
            """Validate that the locale is available in faker."""
            if v not in faker.config.AVAILABLE_LOCALES:
                raise ValueError(f"Unknown locale {v}")
            return v

### `validate_fields(v)`

Validate that the locale is available in faker.

Source code in `src/snailz/parameters.py`

    84
    85
    86
    87
    88
    89
    @field_validator("locale")
    def validate_fields(cls, v):
        """Validate that the locale is available in faker."""
        if v not in faker.config.AVAILABLE_LOCALES:
            raise ValueError(f"Unknown locale {v}")
        return v

## `SpecimenParams`

Bases: `BaseModel`

Parameters for specimen generation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`prob_species` | `list[float]` | Proability of each species (first is mutatable) | `[0.6, 0.4]`
`mean_masses` | `list[float]` | Mean mass for each species | `[10.0, 20.0]`
`genome_length` | `int` | Length of specimen genomes | `20`
`start_date` | `date` | Start date for specimen collection | `datetime.date(2024, 3, 1)`
`mut_mass_scale` | `float` | Scaling factor for mutant snail mass | `2.0`
`mass_rel_stdev` | `float` | Relative standard deviation in mass | `0.5`
`max_mutations` | `int` | Maximum number of mutations in specimens (must be between 0 and length) | `5`
`daily_growth` | `float` | Mass increase per day | `0.01`
`p_missing_location` | `float` | Probability that location is missing | `0.05`

Source code in `src/snailz/parameters.py`

     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    class SpecimenParams(BaseModel):
        """Parameters for specimen generation."""

        prob_species: list[float] = Field(
            default=[0.6, 0.4],
            description="Proability of each species (first is mutatable)",
        )
        mean_masses: list[float] = Field(
            default=[10.0, 20.0], description="Mean mass for each species"
        )
        genome_length: int = Field(
            default=20, gt=0, description="Length of specimen genomes"
        )
        start_date: date = Field(
            default=DEFAULT_START_DATE,
            description="Start date for specimen collection",
        )
        mut_mass_scale: float = Field(
            default=2.0, gt=0, description="Scaling factor for mutant snail mass"
        )
        mass_rel_stdev: float = Field(
            default=0.5, gt=0, description="Relative standard deviation in mass"
        )
        max_mutations: int = Field(
            default=5,
            ge=0,
            description="Maximum number of mutations in specimens (must be between 0 and length)",
        )
        daily_growth: float = Field(
            default=0.01,
            ge=0,
            description="Mass increase per day",
        )
        p_missing_location: float = Field(
            default=0.05, ge=0, description="Probability that location is missing"
        )

        model_config = {"extra": "forbid"}

        @model_validator(mode="after")
        def validate_fields(self):
            """Check parameter validity."""
            if len(self.prob_species) != len(self.mean_masses):
                raise ValueError("prob_species and mean_masses length mis-match")
            return self

### `validate_fields()`

Check parameter validity.

Source code in `src/snailz/parameters.py`

    131
    132
    133
    134
    135
    136
    @model_validator(mode="after")
    def validate_fields(self):
        """Check parameter validity."""
        if len(self.prob_species) != len(self.mean_masses):
            raise ValueError("prob_species and mean_masses length mis-match")
        return self

## `SurveyParams`

Bases: `BaseModel`

Parameters for survey generation.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`number` | `int` | Number of surveys | `3`
`size` | `int` | Survey size | `15`
`start_date` | `date` | Start date for specimen collection | `datetime.date(2024, 3, 1)`
`max_interval` | `int` | Maximum interval between samples | `7`

Source code in `src/snailz/parameters.py`

    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    class SurveyParams(BaseModel):
        """Parameters for survey generation."""

        number: int = Field(default=3, gt=0, description="Number of surveys")
        size: int = Field(
            default=utils.DEFAULT_SURVEY_SIZE, gt=0, description="Survey size"
        )
        start_date: date = Field(
            default=DEFAULT_START_DATE,
            description="Start date for specimen collection",
        )
        max_interval: int = Field(
            gt=0, default=7, description="Maximum interval between samples"
        )

        model_config = {"extra": "forbid"}

## `ScenarioParams`

Bases: `BaseModel`

Represent all parameters combined.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`seed` | `int` | RNG seed | `7493418`
`assay` | `AssayParams` | parameters for assay generation | `AssayParams(baseline=1.0, degrade=0.05, delay=5, mutant=5.0, rel_stdev=0.2, plate_size=4, image_noise=32, p_duplicate_assay=0.05)`
`machine` | `MachineParams` | parameters for machine generation | `MachineParams(number=5, variation=0.15)`
`person` | `PersonParams` | parameters for people generation | `PersonParams(locale='et_EE', number=5)`
`specimen` | `SpecimenParams` | parameters for specimen generation | `SpecimenParams(prob_species=[0.6, 0.4], mean_masses=[10.0, 20.0], genome_length=20, start_date=datetime.date(2024, 3, 1), mut_mass_scale=2.0, mass_rel_stdev=0.5, max_mutations=5, daily_growth=0.01, p_missing_location=0.05)`
`survey` | `SurveyParams` | parameters for survey generation | `SurveyParams(number=3, size=15, start_date=datetime.date(2024, 3, 1), max_interval=7)`

Source code in `src/snailz/parameters.py`

    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    class ScenarioParams(BaseModel):
        """Represent all parameters combined."""

        seed: int = Field(default=7493418, ge=0, description="RNG seed")
        assay: AssayParams = Field(
            default=AssayParams(), description="parameters for assay generation"
        )
        machine: MachineParams = Field(
            default=MachineParams(), description="parameters for machine generation"
        )
        person: PersonParams = Field(
            default=PersonParams(), description="parameters for people generation"
        )
        specimen: SpecimenParams = Field(
            default=SpecimenParams(),
            description="parameters for specimen generation",
        )
        survey: SurveyParams = Field(
            default=SurveyParams(), description="parameters for survey generation"
        )

        model_config = {"extra": "forbid"}