Parser¶
This module provides elements for parsing data manually, i.e. getting a handful list of samples and extract specific structures (colony, lineage, cell) from such samples.
Parser
: handles how to parse an experiment with a given filterset
-
class
tunacell.base.parser.
Parser
(exp=None, filter_set=None)¶ Defines how user wants to parse data.
Parameters: - exp (
Experiment
instance) – - filter_set (
FilterSet
instance) – this is the set of filters used to read/build data, used for for iterators (usually, only .cell_filter and .container_filter are used)
-
add_sample
(*args)¶ Add sample to sample list.
Parameters: args (list) – list of items such as: integer, strings, couple, and/or dict An integer denotes the number of sample_ids to be chosen randomly (if many integers are given, only the first is used) A string will result in loading the corresponding Container, with a cell identifier randomly chosen. A couple (str, cellID) denotes (container_label, cell_identifier) A dictionary should provide ‘container’ key, and ‘cellID’ key
-
clear_samples
()¶ Erase all samples.
-
get_cell
(sample_id)¶ Get
Cell
instance corresponding to sample_id.Parameters: sample_id (dict) – element of self.samples Returns: cell – corresponding to sample_id Return type: Cell
instance
-
get_colony
(sample_id)¶ Get
Colony
instance corresponding to sample_id.Parameters: sample_id (dict) – element of self.samples Returns: colony – corresponding to sample_id Return type: Colony
instance
-
get_container
(sample_id)¶ Get
Container
instance corresponding to sample_id.Parameters: sample_id (dict) – element of self.samples Returns: container Return type: Container
instance
-
get_lineage
(sample_id)¶ Get
Lineage
instance corresponding to sample_id.Parameters: sample_id (dict) – element of self.samples Returns: lineage – corresponding to sample_id Return type: :class:` Lineage` instance
-
get_sample
(index, level='cell')¶ Return sample corresponding to index.
Parameters: - index (int) – index of sample id in self.samples
- level (str {'cell'|'lineage'|'colony'}) –
Returns: structure level corresponding to sample id
Return type: out
-
info_samples
()¶ Table output showing stored samples.
-
iter_cells
(mode='samples', size=None)¶ Iterate through valid cells.
Parameters: - mode (str {'samples'} (default 'samples')) – whether to iterate over all cells (up to number limitation), or over registered samples
- size (int (default None)) – limit the number of lineages to size. Works only in mode=’all’
Yields: cell (
Cell
instance) – filtering removed outlier cells, containers, colonies, and lineages
-
iter_colonies
(mode='samples', size=None)¶ Iterate through valid colonies.
Parameters: - mode (str {'samples'} (default 'samples')) – whether to iterate over all colonies (up to number limitation), or over registered samples
- size (int (default None)) – limit the number of colonies to size.
Yields: colony (
Colony
instance) – filtering removed outlier cells, containers, and colonies
-
iter_containers
(mode='samples', size=None)¶ Iterate through valid containers.
Parameters: - mode (str {'samples'} (default 'samples')) – iterates over containers pointed by parser.samples
- size (int (default None)) – number of containers to be parsed
Yields: container (
tunacell.core.Container
instance) – filtering removed outlier cells, containers
-
iter_lineages
(mode='samples', size=None)¶ Iterate through valid lineages.
Parameters: - mode (str {''samples'} (default 'samples')) – whether to iterate over all lineages (up to number limitation), or over registered samples
- size (int (default None)) – limit the number of lineages to size.
Yields: lineage (
Lineage
instance) – filtering removed outlier cells, containers, colonies, and lineages
-
load_experiment
(path, filetype='text')¶ Loads an experiment from path to file.
Parameters: - path (str) – path to root directory (‘text’), or to datafile (‘h5’)
- filetype (str {'text', 'h5}) –
-
remove_sample
(index, verbose=True)¶ Remove sample of index in sample list.
-
set_filter
(fset)¶ Set build filter.
Parameters: fset ( FilterSet
instance) –
- exp (