Skip to content

Phenotypes

Phenotypes

Bases: Endpoint

Queries phenotypes/ endpoints

Functions

get(**kwargs)

Queries phenotypes/, with optional query parameters

Other Parameters:

Name Type Description
search string

Keyword search

collections list

IDs of collections

tags list

IDs of tags

datasources list

IDs of datasources

Returns:

Name Type Description
Response list

List of phenotypes matching query parameters

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> # Get all phenotypes
>>> client.phenotypes.get()
>>> # Search phenotypes
>>> client.phenotypes.get(search='asthma', collections=19)

get_versions(id)

Queries phenotypes/{id}/get-versions/

Parameters:

Name Type Description Default
id str

ID of entity to query, in format PH[\d+]

required

Returns:

Name Type Description
Response list

Version list of queried phenotype

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> client.phenotypes.get_versions('PH1')

get_detail(id, version_id=None)

Queries phenotypes/{id}/detail/ or phenotypes/{id}/version/{version_id}/detail if version_id is supplied

Parameters:

Name Type Description Default
id str

ID of entity to query, in format PH[\d+]

required
version_id int

version ID of entity

None

Returns:

Name Type Description
Response list

Details of queried phenotype

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> # Get detail of phenotype, PH1
>>> client.phenotypes.get_detail('PH1')
>>> # Get detail of version 2 of phenotype, PH1
>>> client.phenotypes.get_detail('PH1', version_id=2)

get_codelist(id, version_id=None)

Queries phenotypes/{id}/export/codes/ or phenotypes/{id}/version/{version_id}/export/codes if version_id is supplied

Parameters:

Name Type Description Default
id str

ID of entity to query, in format PH[\d+]

required
version_id int

version ID of entity

None

Returns:

Name Type Description
Response list

Codelist of queried phenotype

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> # Get codelist of phenotype, PH1
>>> client.phenotypes.get_codelist('PH1')
>>> # Get codelist of version 2 of phenotype, PH1
>>> client.phenotypes.get_codelist('PH1', version_id=2)

save_definition_file(path, id, version_id=None)

Saves the YAML definition of the queried phenotype to file

Parameters:

Name Type Description Default
path str

Location to save the YAML file

required
id str

ID of entity to query, in format PH[\d+]

required
version_id int

version ID of entity

None

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> # Get codelist of phenotype, PH1
>>> client.phenotypes.save_definition_file('./path/to/file.yaml', 'PH1')
>>> # Get codelist of version 2 of phenotype, PH1
>>> client.phenotypes.save_definition_file('./path/to/file.yaml', 'PH1', version_id=2)

create(path)

Uploads the specified phenotype definition file to the ConceptLibrary and creates a new phenotype

Parameters:

Name Type Description Default
path str

Location where the definition file is saved on your local machine

required

Returns:

Name Type Description
Response list

Details of the newly created phenotype

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> client.phenotypes.create('./path/to/file.yaml')

update(path)

Uses the specified phenotype definition file to update an already existing phenotype

Parameters:

Name Type Description Default
path str

Location where the definition file is saved on your local machine

required

Returns:

Name Type Description
Response list

Details of the updated phenotype

Examples:

>>> from pyconceptlibraryclient import Client
>>> client = Client(public=False)
>>> client.phenotypes.create('./path/to/file.yaml')