pyOpenCGA basic variant and interpretation usage


[NOTE] The server methods used by pyopencga client are defined in the following swagger URL:

[NOTE] Current implemented methods are registered at the following spreadsheet:

Loading pyOpenCGA


In [ ]:
# Initialize PYTHONPATH for pyopencga
import sys
import os
from pprint import pprint

cwd = os.getcwd()
print("current_dir: ...."+cwd[-10:])

base_modules_dir = os.path.dirname(cwd)
print("base_modules_dir: ...."+base_modules_dir[-10:])

sys.path.append(base_modules_dir)

In [ ]:
from pyopencga.opencga_config import ConfigClient
from pyopencga.opencga_client import OpenCGAClient
import json

Setting credentials for LogIn

Credentials

Plese add the credentials for opencga login into a file in json format and read them from there.

i.e: file: __user_config.json flie_content: {"user":"xxx","pwd":"yyy"}


In [ ]:
## Reading user config/credentials to connect to server
user_config_json = "./__user_config.json"
with open(user_config_json,"r") as f:
    user_credentials = json.loads(f.read())
    
print('User: {}***'.format(user_credentials["user"][:3]))

In [ ]:
user = user_credentials["user"]
passwd = user_credentials["pwd"]

Creating ConfigClient for server connection configuration


In [ ]:
## Creating ConfigClient
host = 'http://bioinfodev.hpc.cam.ac.uk/opencga-test'
cc = ConfigClient()
config_dict = cc.get_basic_config_dict(host)
print("Config information:\n",config_dict)

LogIn with user credentials


In [ ]:
oc = OpenCGAClient(configuration=config_dict, 
                   user=user, 
                   pwd=passwd)

In [ ]:
## Getting the session id / token
token = oc.session_id
print("Session token:\n{}...".format(token[:10]))

In [ ]:
oc = OpenCGAClient(configuration=config_dict, 
                   session_id=token)

You are now connected to OpenCGA

Working with variants and interpretations

[TODO]