gpf.person_sets package

Submodules

gpf.person_sets.person_sets module

Provide classes for grouping of individuals by some criteria.

This module provides functionality for grouping individuals from a study or study group into various sets based on what value they have in a given mapping.

exception gpf.person_sets.person_sets.AttributeQueriesUnsupportedException[source]

Bases: Exception

class gpf.person_sets.person_sets.ChildrenBySex(male: set[tuple[str, str]], female: set[tuple[str, str]], unspecified: set[tuple[str, str]])[source]

Bases: object

Statistics about children in a PersonSet.

female: set[tuple[str, str]]
male: set[tuple[str, str]]
unspecified: set[tuple[str, str]]
class gpf.person_sets.person_sets.ChildrenStats(male: int, female: int, unspecified: int)[source]

Bases: object

Statistics about children in a PersonSet.

female: int
male: int
property total: int
unspecified: int
class gpf.person_sets.person_sets.PSCQuery(psc_id: str, selected_person_sets: set[str])[source]

Bases: object

Person set collection query.

psc_id: str
selected_person_sets: set[str]
class gpf.person_sets.person_sets.PersonSet(psid: str, name: str, values: tuple[str, ...], color: str, persons: dict[tuple[str, str], Person])[source]

Bases: object

Set of individuals mapped to a common value in the source.

color: str
static from_json(json: dict[str, Any], families: FamiliesData) PersonSet[source]

Construct person set from a JSON dict.

get_children() list[Person][source]

Return all children in the person set.

get_children_by_sex() ChildrenBySex[source]

Return all children in the person set splitted by sex.

get_children_count() int[source]
get_children_stats() ChildrenStats[source]

Return statistics about children in the person set.

id: str
name: str
persons: dict[tuple[str, str], Person]
to_json() dict[str, Any][source]
values: tuple[str, ...]
class gpf.person_sets.person_sets.PersonSetCollection(config: PersonSetCollectionConfig, person_sets: dict[str, PersonSet], default: PersonSet, families: FamiliesData)[source]

Bases: object

The collection of all possible person sets in a given source.

collect_person_collection_attributes(person: Person, pheno_fetcher: Callable | None) tuple[str, ...][source]

Collect all configured attributes for a Person.

static combine(collections: list[PersonSetCollection], families: FamiliesData) PersonSetCollection[source]

Combine a list of PersonSetCollection objects into a single one.

config_json() dict[str, Any][source]

Produce a JSON configuration for this PersonSetCollection object.

default: PersonSet
domain_json() dict[str, Any][source]

Produce a JSON to represent domain of this PersonSetCollection.

families: FamiliesData
static from_families(psc_config: PersonSetCollectionConfig, families_data: FamiliesData, pheno_fetcher: Callable | None = None) PersonSetCollection[source]

Produce a PersonSetCollection from a config and pedigree.

static get_person_color(person: Person, psc: PersonSetCollection | None) str[source]

Get the hex color value for a Person in a PersonSetCollection.

get_person_set(person_id: tuple[str, str]) PersonSet | None[source]
get_person_set_of_person(fpid: tuple[str, str]) PersonSet | None[source]

Retrieve the PersonSet associated with the given person identifier.

Args:
fpid (tuple[str, str]): The person identifier consisting of two

strings - family ID and person ID.

Returns:
Optional[PersonSet]: The PersonSet associated with the given

person identifier, or None if not found.

get_query_person_set_ids(query: PSCQuery) set[str][source]

Extract person set IDs from a person set collection query.

get_stats() dict[str, dict[str, int]][source]

Return a dictionary with statistics for each PersonSet.

The statistics are a dictionary containing the amount of parents and children in the set.

id: str
is_pedigree_only() bool[source]
legend_json() list[dict[str, Any]][source]
static merge_configs(person_set_collections: list[PersonSetCollection]) PersonSetCollectionConfig[source]

Merge the configurations of a list of PersonSetCollection objects.

Only supports merging PersonSetCollection objects with matching ids. The method will not merge the PersonSet objects’ values.

name: str
person_sets: dict[str, PersonSet]
query_fpids(query: PSCQuery) set[tuple[str, str]] | None[source]

Query the PersonSetCollection for the selected person sets.

query_person_ids(query: PSCQuery) set[str] | None[source]

Query the PersonSetCollection for the selected person sets.

static remove_empty_person_sets(person_set_collection: PersonSetCollection) PersonSetCollection[source]

Remove all empty person sets in a PersonSetCollection in place.

transform_ps_query_to_attribute_queries(query: PSCQuery) dict[str, str][source]

Transform person set collection query into query variants.

class gpf.person_sets.person_sets.PersonSetCollectionConfig(*, id: str, name: str, sources: list[SourceConfig], domain: list[PersonSetConfig], default: PersonSetConfig)[source]

Bases: BaseModel

Configuration for a collection of person sets.

default: PersonSetConfig
domain: list[PersonSetConfig]
id: str
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
sources: list[SourceConfig]
class gpf.person_sets.person_sets.PersonSetConfig(*, id: str, name: str, values: tuple[str, ...], color: str)[source]

Bases: BaseModel

Configuration for a person set.

color: str
id: str
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
values: tuple[str, ...]
class gpf.person_sets.person_sets.SourceConfig(*, from_: Literal['pedigree', 'phenodb'], source: str)[source]

Bases: BaseModel

Configuration for a source.

from_: Literal['pedigree', 'phenodb']
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: str
gpf.person_sets.person_sets.parse_person_set_collection_config(psc_config: dict[str, Any]) PersonSetCollectionConfig[source]

Parse a person set collection configuration.

gpf.person_sets.person_sets.parse_person_set_collections_study_config(config: dict[str, Any]) dict[str, PersonSetCollectionConfig][source]

Parse a person sets configuration.

gpf.person_sets.person_sets.parse_person_set_config(psc_id: str, domain: dict[str, Any]) PersonSetConfig[source]

Parse a person set configuration.

Module contents

class gpf.person_sets.ChildrenBySex(male: set[tuple[str, str]], female: set[tuple[str, str]], unspecified: set[tuple[str, str]])[source]

Bases: object

Statistics about children in a PersonSet.

female: set[tuple[str, str]]
male: set[tuple[str, str]]
unspecified: set[tuple[str, str]]
class gpf.person_sets.ChildrenStats(male: int, female: int, unspecified: int)[source]

Bases: object

Statistics about children in a PersonSet.

female: int
male: int
property total: int
unspecified: int
class gpf.person_sets.PSCQuery(psc_id: str, selected_person_sets: set[str])[source]

Bases: object

Person set collection query.

psc_id: str
selected_person_sets: set[str]
class gpf.person_sets.PersonSet(psid: str, name: str, values: tuple[str, ...], color: str, persons: dict[tuple[str, str], Person])[source]

Bases: object

Set of individuals mapped to a common value in the source.

color: str
static from_json(json: dict[str, Any], families: FamiliesData) PersonSet[source]

Construct person set from a JSON dict.

get_children() list[Person][source]

Return all children in the person set.

get_children_by_sex() ChildrenBySex[source]

Return all children in the person set splitted by sex.

get_children_count() int[source]
get_children_stats() ChildrenStats[source]

Return statistics about children in the person set.

id: str
name: str
persons: dict[tuple[str, str], Person]
to_json() dict[str, Any][source]
values: tuple[str, ...]
class gpf.person_sets.PersonSetCollection(config: PersonSetCollectionConfig, person_sets: dict[str, PersonSet], default: PersonSet, families: FamiliesData)[source]

Bases: object

The collection of all possible person sets in a given source.

collect_person_collection_attributes(person: Person, pheno_fetcher: Callable | None) tuple[str, ...][source]

Collect all configured attributes for a Person.

static combine(collections: list[PersonSetCollection], families: FamiliesData) PersonSetCollection[source]

Combine a list of PersonSetCollection objects into a single one.

config_json() dict[str, Any][source]

Produce a JSON configuration for this PersonSetCollection object.

default: PersonSet
domain_json() dict[str, Any][source]

Produce a JSON to represent domain of this PersonSetCollection.

families: FamiliesData
static from_families(psc_config: PersonSetCollectionConfig, families_data: FamiliesData, pheno_fetcher: Callable | None = None) PersonSetCollection[source]

Produce a PersonSetCollection from a config and pedigree.

static get_person_color(person: Person, psc: PersonSetCollection | None) str[source]

Get the hex color value for a Person in a PersonSetCollection.

get_person_set(person_id: tuple[str, str]) PersonSet | None[source]
get_person_set_of_person(fpid: tuple[str, str]) PersonSet | None[source]

Retrieve the PersonSet associated with the given person identifier.

Args:
fpid (tuple[str, str]): The person identifier consisting of two

strings - family ID and person ID.

Returns:
Optional[PersonSet]: The PersonSet associated with the given

person identifier, or None if not found.

get_query_person_set_ids(query: PSCQuery) set[str][source]

Extract person set IDs from a person set collection query.

get_stats() dict[str, dict[str, int]][source]

Return a dictionary with statistics for each PersonSet.

The statistics are a dictionary containing the amount of parents and children in the set.

id: str
is_pedigree_only() bool[source]
legend_json() list[dict[str, Any]][source]
static merge_configs(person_set_collections: list[PersonSetCollection]) PersonSetCollectionConfig[source]

Merge the configurations of a list of PersonSetCollection objects.

Only supports merging PersonSetCollection objects with matching ids. The method will not merge the PersonSet objects’ values.

name: str
person_sets: dict[str, PersonSet]
query_fpids(query: PSCQuery) set[tuple[str, str]] | None[source]

Query the PersonSetCollection for the selected person sets.

query_person_ids(query: PSCQuery) set[str] | None[source]

Query the PersonSetCollection for the selected person sets.

static remove_empty_person_sets(person_set_collection: PersonSetCollection) PersonSetCollection[source]

Remove all empty person sets in a PersonSetCollection in place.

transform_ps_query_to_attribute_queries(query: PSCQuery) dict[str, str][source]

Transform person set collection query into query variants.

class gpf.person_sets.PersonSetCollectionConfig(*, id: str, name: str, sources: list[SourceConfig], domain: list[PersonSetConfig], default: PersonSetConfig)[source]

Bases: BaseModel

Configuration for a collection of person sets.

default: PersonSetConfig
domain: list[PersonSetConfig]
id: str
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
sources: list[SourceConfig]
class gpf.person_sets.PersonSetConfig(*, id: str, name: str, values: tuple[str, ...], color: str)[source]

Bases: BaseModel

Configuration for a person set.

color: str
id: str
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
values: tuple[str, ...]
class gpf.person_sets.SourceConfig(*, from_: Literal['pedigree', 'phenodb'], source: str)[source]

Bases: BaseModel

Configuration for a source.

from_: Literal['pedigree', 'phenodb']
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: str
gpf.person_sets.parse_person_set_collection_config(psc_config: dict[str, Any]) PersonSetCollectionConfig[source]

Parse a person set collection configuration.

gpf.person_sets.parse_person_set_collections_study_config(config: dict[str, Any]) dict[str, PersonSetCollectionConfig][source]

Parse a person sets configuration.

gpf.person_sets.parse_person_set_config(psc_id: str, domain: dict[str, Any]) PersonSetConfig[source]

Parse a person set configuration.