<jupyter_start><jupyter_text>Initialising the client1&nbsp;&nbsp;Makes all necessary imports and initialise the Python CVA client2&nbsp;&nbsp;Count number of primary elements in CVA  Makes all necessary imports and initialise the Python CVA clientWhen initialising the client it is handy to set the log level to INFO in order to see the times that each query takes and how the URL is built.We will be importing some system libraries, the Pandas library which is used by pyark and will be explained later, some entities available in the Genomics England models in the package `protocols` and finally the `pyark` client.<jupyter_code>import getpass
import logging
import os
import sys
import pandas as pd
from collections import defaultdict, OrderedDict
import pyark
from pyark.cva_client import CvaClient
from protocols.protocol_7_2.reports import Program, Tier, Assembly
from protocols.protocol_7_2.cva import ReportEventType

# sets logging messages so the URLs that are called get printed
logging.basicConfig(level=logging.INFO)<jupyter_output><empty_output><jupyter_text>You need three things to initialise pyark: the CVA backend URL, your user name and your password. In this example these are loaded from environment variables.The client gets a token which will contain your authorisation level. The token renews automatically if necessary. The client will also make retries in case of request failures.<jupyter_code># initialise CVA client and subclients
# every subclient provides access to different sets of data exposed in the API
user = os.environ.get("CVA_USER")
password = os.environ.get("CVA_PASSWORD")
url = os.environ.get("CVA_URL_BASE", "http://localhost:8090")
cva = CvaClient(url_base=url, user=user, password=password)<jupyter_output>INFO:root:POST https://bio-test-cva.gel.zone/cva/api/0/authentication?
INFO:root:Response time : 16 ms<jupyter_text>Once the token is obtained we will have available a number of different subclients, each of those providing access to a different CVA entity or functionality.<jupyter_code>cases_client = cva.cases()
pedigrees_client = cva.pedigrees()
entities_client = cva.entities()
variants_client = cva.variants()
report_events_client = cva.report_events()
transactions_client = cva.transactions()<jupyter_output><empty_output><jupyter_text>Check the version of your client as follows.<jupyter_code>print("pyark version {}".format(pyark.VERSION))<jupyter_output>pyark version 4.0.4<jupyter_text>Count number of primary elements in CVAAs the simplest usage example we can count the number of entities in CVA.<jupyter_code># we can count the total number of cases
cases_client.count()
# or we can count the number of cases given some criteria
cases_client.count(program=Program.rare_disease, panelNames='intellectual disability')
# count the total number of report events
report_events_client.count()
# count the number of report events given some criteria
report_events_client.count(program=Program.rare_disease, type="questionnaire")
# count the total number of variants
variants_client.count()
# count the number of variants given some criteria
variants_client.count(assembly=Assembly.GRCh38, geneSymbols="BRCA2")<jupyter_output>INFO:root:GET https://bio-test-cva.gel.zone/cva/api/0/variants?count=True&assembly=GRCh38&geneSymbols=BRCA2
INFO:root:Response time : 32 ms
{'fraction_non_alphanumeric': 0.06979542719614922, 'fraction_numerical': 0.007521058965102286, 'mean_word_length': 6.591324200913242, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '495324', 'license': 'Apache-2.0', 'n_tokens_mistral': 962, 'n_tokens_neox': 938, 'n_words': 353, 'path': 'notebooks/client_initialisation.ipynb', 'repo_name': 'kevinpetersavage/pyark', 'size': '3324'}