|
9 | 9 |
|
10 | 10 | from pandas.core.frame import DataFrame
|
11 | 11 |
|
| 12 | +try: |
| 13 | + from typing import TypedDict, NotRequired |
| 14 | +except ImportError: |
| 15 | + from typing_extensions import TypedDict, NotRequired |
| 16 | + |
12 | 17 | import cellengine as ce
|
13 | 18 | from cellengine.resources.attachment import Attachment
|
14 | 19 | from cellengine.resources.compensation import Compensation, UNCOMPENSATED, Compensations
|
|
31 | 36 | )
|
32 | 37 |
|
33 | 38 |
|
| 39 | +ImportOpts = TypedDict( |
| 40 | + "ImportOpts", |
| 41 | + { |
| 42 | + "populations": NotRequired[bool], |
| 43 | + "illustrations": NotRequired[Union[bool, List[str]]], |
| 44 | + "compensations": NotRequired[Union[bool, List[str]]], |
| 45 | + "savedStatisticExports": NotRequired[Union[bool, List[str]]], |
| 46 | + "annotations": NotRequired[Union[bool, List[str]]], |
| 47 | + }, |
| 48 | +) |
| 49 | + |
| 50 | + |
34 | 51 | class Experiment:
|
35 | 52 | """The main container for an analysis. Don't construct directly; use
|
36 | 53 | [`Experiment.create`][cellengine.Experiment.create] or
|
@@ -374,6 +391,47 @@ def save_revision(self, description: str) -> None:
|
374 | 391 | self._properties["revisions"] = r.get("revisions")
|
375 | 392 | self._properties["deepUpdated"] = r.get("deepUpdated")
|
376 | 393 |
|
| 394 | + def import_resources( |
| 395 | + self, |
| 396 | + src_experiment_id: str, |
| 397 | + what: ImportOpts, |
| 398 | + channel_map: Optional[Dict[str, str]] = {}, |
| 399 | + dst_population_id: Optional[str] = None, |
| 400 | + ) -> None: |
| 401 | + """ |
| 402 | + Imports resources from another experiment. |
| 403 | +
|
| 404 | + Args: |
| 405 | + src_experiment_id (str): The ID of the source experiment. |
| 406 | + what (ImportOpts): A dictionary with the following optional keys: |
| 407 | + - populations: Whether to import populations. |
| 408 | + - illustrations: Whether to import illustrations (True = all, |
| 409 | + False = none), or a list of specific illustration IDs to import. |
| 410 | + - compensations: Whether to import compensations (True = all, |
| 411 | + False = none), or a list of specific compensation IDs to import. |
| 412 | + - savedStatisticExports: Whether to import saved statistic exports |
| 413 | + (True = all, False = none), or a list of specific export IDs to |
| 414 | + import. |
| 415 | + - annotations: Whether to import annotations (True = all, |
| 416 | + False = none), or a list of specific annotation names to import. |
| 417 | + channel_map (Dict[str, str]): A dictionary Object mapping channel |
| 418 | + names from source experiment to destination experiment for |
| 419 | + imported gates. Gates using channels not present in the map or |
| 420 | + with channels set to the value "" will not be imported. |
| 421 | + Populations are only imported if all of their required gates are |
| 422 | + imported (i.e. the entire set of parents must be imported). This |
| 423 | + does not affect compensation import. |
| 424 | + dst_population_id (str): The ID of the destination parent population. |
| 425 | + If not provided, the root population is used. |
| 426 | +
|
| 427 | + Use `experiment.gates` and similar to access the imported resources. |
| 428 | + *Note: If it would be useful for this method to return the imported |
| 429 | + resources, open a GitHub issue letting us know.* |
| 430 | + """ |
| 431 | + ce.APIClient().import_experiment_resources( |
| 432 | + self._id, src_experiment_id, what, channel_map, dst_population_id |
| 433 | + ) |
| 434 | + |
377 | 435 | # Attachments
|
378 | 436 |
|
379 | 437 | @property
|
|
0 commit comments