Assays
Generate snailz assays.
DateTimeEncoder
Bases: JSONEncoder
Encode date and datetime objects as JSON.
Source code in snailz/assays.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
default(obj)
Encode date or datetime.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
date | datetime
|
what to encode. |
required |
Returns:
Type | Description |
---|---|
str
|
String representation. |
Source code in snailz/assays.py
18 19 20 21 22 23 24 25 26 27 28 |
|
assays(options)
Main driver for assay generation.
- Load previously-generated samples and staff.
- Generate experiments for some samples, each performed by one or more staff.
- Save.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Namespace
|
options object. |
required |
Source code in snailz/assays.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
_reload_mutant_status(options)
Re-create sample genomic information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Namespace
|
controlling options. |
required |
Returns:
Type | Description |
---|---|
list
|
List of Booleans showing which samples are for mutant snails. |
Source code in snailz/assays.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
_reload_staff(options)
Re-load staff information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options
|
Namespace
|
controlling options. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
Dataframe with staff information. |
Source code in snailz/assays.py
67 68 69 70 71 72 73 74 75 76 |
|
_make_experiments(params, mutant_status, staff_ids)
Create experiments and their data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
AssayParams
|
assay generation parameters. |
required |
mutant_status
|
list
|
list showing which samples are mutants. |
required |
staff_ids
|
list
|
list of staff IDs. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary holding data to serialize. |
Source code in snailz/assays.py
79 80 81 82 83 84 85 86 87 88 89 90 91 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 |
|
_invalidate_plates(params, staff_ids, plates)
Invalidate a random set of plates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
AssayParams
|
assay generation parameters. |
required |
staff_ids
|
int
|
list of staff IDs. |
required |
plates
|
list
|
list of generated plates. |
required |
Returns:
Type | Description |
---|---|
list
|
List of dictionaries describing invalidated plates. |
Source code in snailz/assays.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
_make_random_filename_generator(params)
Create a random filename generator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
AssayParams
|
assay generation parameters. |
required |
Returns:
Type | Description |
---|---|
callable
|
Unique random filename each time generator is invoked. |
Source code in snailz/assays.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
_random_experiment_duration(params, kind)
Choose random start date and end date for experiment.
The start date is uniformly selected from the experiment period.
The end date is the same as or later than the start date,
and None
if the experiment hasn't finished.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
AssayParams
|
assay generation parameters. |
required |
kind
|
str
|
experimental procedure used. |
required |
Returns:
Type | Description |
---|---|
tuple
|
A pair with a start date and either an end date or |
Source code in snailz/assays.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
_random_plates(params, kind, sample_id, start_id, start_date, filename_gen)
Generate random plate data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
AssayParams
|
assay generation parameters. |
required |
kind
|
str
|
experimental procedure used. |
required |
sample_id
|
int
|
sample used in the experiment. |
required |
start_id
|
int
|
starting ID of plates. |
required |
start_date
|
date
|
when experiment started. |
required |
filename_gen
|
str
|
random filename generator |
required |
Returns:
Type | Description |
---|---|
list
|
List of dictionaries of plate data. |
Source code in snailz/assays.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
_random_date_interval(start_date, end_date)
Choose a random date (inclusive).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_date
|
date
|
earliest allowed date. |
required |
end_date
|
date
|
last possible date. |
required |
Returns:
Type | Description |
---|---|
date
|
Randomly-selected date. |
Source code in snailz/assays.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
_round_date(raw)
Round time to whole day.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw
|
datetime | None
|
starting datetime (or |
required |
Returns:
Type | Description |
---|---|
date | None
|
Input rounded to nearest whole day (or |
Source code in snailz/assays.py
246 247 248 249 250 251 252 253 254 255 |
|
_save(outfile, result)
Save or show generated data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
outfile
|
str
|
where to write (or |
required |
result
|
dict
|
data to write. |
required |
Source code in snailz/assays.py
257 258 259 260 261 262 263 264 265 266 267 268 |
|