### Installing or Updating medconb-client Package Source: https://github.com/bayer-group/medconb-client/blob/main/docs/installation.md This command installs or updates the `medconb-client` package directly into your Python environment. The `--force-reinstall` flag ensures a fresh installation, and `-U` (or `--upgrade`) updates the package if it's already present. ```Bash pip install --force-reinstall -U medconb-client ``` -------------------------------- ### Installing MedConB Client Library (Shell) Source: https://github.com/bayer-group/medconb-client/blob/main/README.md This command installs or updates the MedConB client library in your Python environment. It uses `pip` to ensure the latest version is installed and any existing installation is forcefully reinstalled. ```Shell pip install --force-reinstall -U medconb-client ``` -------------------------------- ### Initializing MedConB Client in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet demonstrates how to initialize the MedConB client in Python. It requires an API endpoint URL and a Bearer token, which is assumed to be retrieved by a `get_token` function. The `Client` object is then used for subsequent API calls. ```Python from medconb_client import Client endpoint = "https://api.medconb.example.com/graphql/" token = get_token() client = Client(endpoint, token) ``` -------------------------------- ### Retrieving Codelist by ID using MedConB Client in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet shows how to retrieve a specific codelist from MedConB using its unique ID. The `get_codelist` method of the client returns a `Codelist` object, which can then be used to access its ID, name, description, and associated codesets. The example also demonstrates printing details of the retrieved codelist. ```Python codelist = client.get_codelist( codelist_id="9c4ad312-3008-4d95-9b16-6f9b21ec1ad9" ) print(f""" Codelist ID: {codelist.id} Codelist Name: {codelist.name} Codelist Description: {codelist.description} It contains codes from the following ontologies: {", ".join([codeset.ontology for codeset in codelist.codesets])} """) ``` -------------------------------- ### Listing Workspace Collections and Retrieving Codelist in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet demonstrates how to retrieve an overview of the user's MedConB workspace using `client.get_workspace()`. It then filters for the first codelist collection and retrieves the first codelist within that collection by its ID, showcasing how to navigate the workspace structure. ```Python workspace_info = client.get_workspace() # get first collection of codelists (skip phenotypes) collection_info = next( collection for collection in workspace_info.collections if collection.itemType == "Codelist" ) codelist = client.get_codelist(collection_info.items[0].id) ``` -------------------------------- ### Retrieving Codelist by Name and Collection (Python) Source: https://github.com/bayer-group/medconb-client/blob/main/README.md This example shows how to retrieve a specific codelist using its name and the name of its containing codelist collection. The `get_codelist_by_name` method queries the API for the matching codelist. ```Python codelist = client.get_codelist_by_name( codelist_name="Coronary Artery Disease", codelist_collection_name="Pacific AF [Sample]", ) ``` -------------------------------- ### Retrieving Codelist by Name from Phenotype in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet illustrates how to retrieve a codelist by name when it is part of a phenotype. To ensure correct identification, both the `phenotype_collection_name` and `phenotype_name` must be provided in addition to the `codelist_name` when calling `get_codelist_by_name`. ```Python codelist = client.get_codelist_by_name( codelist_name="Coronary Artery Disease", phenotype_collection_name="[Sample] PACIFIC AF ECA", phenotype_name="Coronary Artery Disease", ) ``` -------------------------------- ### Retrieving Codelist Descriptions using get_codelist in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet demonstrates how to retrieve a codelist including its descriptive text by setting the `with_description` parameter to `True` when calling the `client.get_codelist` method. This operation can be time-consuming for large codelists (>1000 codes) due to the additional data retrieval. It requires an initialized `client` object and a `codelist_id`. The output is a `codelist` object containing codes and their descriptions. ```python codelist = client.get_codelist(codelist_id, with_description=True) ``` -------------------------------- ### Searching Public Marketplace for Codelists in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet shows how to search the MedConB public marketplace for available codelists using the `client.search_public_codelists` method. It demonstrates a basic query to find codelists where the name contains 'blood', illustrating how to filter results based on search criteria. ```Python found_codelists = client.search_public_codelists(query="name:'blood'") ``` -------------------------------- ### Converting Codelist to Pandas DataFrame in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet demonstrates how to easily convert a retrieved MedConB codelist into a Pandas DataFrame. The `to_pandas()` method on `codelist.codesets` transforms the codelist's codesets into a DataFrame with 'ontology', 'code', and 'description' columns, facilitating data analysis. ```Python codelist.codesets.to_pandas() ``` -------------------------------- ### Retrieving Codelist by Name from Collection in Python Source: https://github.com/bayer-group/medconb-client/blob/main/docs/examples.md This snippet demonstrates how to retrieve a codelist by its name when it resides within a specific collection. Since codelist names are not globally unique, specifying the `codelist_collection_name` is necessary to accurately locate the desired codelist using the `get_codelist_by_name` method. ```Python codelist = client.get_codelist_by_name( codelist_name="Coronary Artery Disease", codelist_collection_name="Pacific AF [Sample]", ) ``` -------------------------------- ### Initializing MedConB Client (Python) Source: https://github.com/bayer-group/medconb-client/blob/main/README.md This snippet demonstrates how to initialize the MedConB client. It requires an API endpoint URL and an authentication token, which are then used to create a `Client` instance for interacting with the MedConB API. ```Python from medconb_client import Client endpoint = "https://api.medconb.example.com/graphql/" token = get_token() client = Client(endpoint, token) ``` -------------------------------- ### Retrieving Codelist by Name and Phenotype (Python) Source: https://github.com/bayer-group/medconb-client/blob/main/README.md This snippet illustrates an alternative way to retrieve a codelist by name, specifying the phenotype collection name and phenotype name. This provides a more granular way to identify the desired codelist within the API. ```Python codelist = client.get_codelist_by_name( codelist_name="Coronary Artery Disease", phenotype_collection_name="[Sample] PACIFIC AF ECA", phenotype_name="Coronary Artery Disease", ) ``` -------------------------------- ### Retrieving Codelist from Workspace Collections (Python) Source: https://github.com/bayer-group/medconb-client/blob/main/README.md This snippet shows how to retrieve information about collections within the user's workspace, filter for codelist collections, and then fetch a specific codelist by its ID from the first item in the identified collection. ```Python workspace_info = client.get_workspace() collection_info = next( collection for collection in workspace_info.collections if collection.itemType == "Codelist" ) codelist = client.get_codelist(collection_info.items[0].id) ``` -------------------------------- ### Retrieving Codelist by ID (Python) Source: https://github.com/bayer-group/medconb-client/blob/main/README.md This code demonstrates how to fetch a codelist directly using its unique identifier. The `get_codelist` method takes the `codelist_id` as a parameter to retrieve the specific codelist. ```Python codelist = client.get_codelist( codelist_id="9c4ad312-3008-4d95-9b16-6f9b21ec1ad9" ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.