{ "info": { "author": "David Gomez-Peregrina, Pablo Mar\u00edn-Garc\u00eda", "author_email": "david.gomez@mgviz.org, pmarin@kanteron.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Topic :: Scientific/Engineering :: Bio-Informatics" ], "description": ".. contents::\n\nPyOpenCGA\n==========\n\nThis Python client package makes use of the comprehensive RESTful web services API implemented for the `OpenCGA`_ platform.\nOpenCGA is an open-source project that implements a high-performance, scalable and secure platform for Genomic data analysis and visualisation\n\nOpenCGA implements a secure and high performance platform for Big Data analysis and visualisation in current genomics.\nOpenCGA uses the most modern and advanced technologies to scale to petabytes of data. OpenCGA is designed and implemented to work with\nfew million genomes. It is built on top of three main components: Catalog, Variant and Alignment Storage and Analysis.\n\nMore info about this project in the `OpenCGA Docs`_\n\nInstallation\n------------\n\nCloning\n```````\nPyOpenCGA can be cloned in your local machine by executing in your terminal::\n\n $ git clone https://github.com/opencb/opencga.git\n\nOnce you have downloaded the project you can install the library. We recommend to install it inside a `virtual environment`_::\n\n $ cd opencga/tree/develop/opencga-client/src/main/python/pyOpenCGA\n $ python setup.py install\n\nPip install\n```````````\nRun the following command in the shell::\n\n $ pip install pyopencga\n\nUsage\n-----\n\nImport pyOpenCGA package\n````````````````````````\n\nThe first step is to import the ConfigClient and OpenCGAClient from pyOpenCGA:\n\n.. code-block:: python\n\n >>> from pyopencga.opencga_config import ConfigClient\n >>> from pyopencga.opencga_client import OpenCGAClient\n\nSetting up server host configuration\n````````````````````````````````````\n\nThe second step is to set up the OpenCGA host server configuration you can get a basic configuration dictionary specifying your OpenCGA server host:\n\n.. code-block:: python\n\n >>> host = 'http://bioinfodev.hpc.cam.ac.uk/opencga-test' # Use a server host where you have an account\n >>> cc = ConfigClient()\n >>> config_dict = cc.get_basic_config_dict(host)\n >>> print(config_dict)\n {'version': 'v1', 'rest': {'hosts': ['http://bioinfodev.hpc.cam.ac.uk/opencga-test']}} \n\nLog in to OpenCGA host server\n`````````````````````````````\n\nWith this configuration you can initialize the OpenCGAClient and log into an OpenCGA user account, specifying a user and password:\n\n.. code-block:: python\n\n >>> oc = OpenCGAClient(configuration=config_dict,user='user_id',pwd='user_password')\n\nFor scripting or using Jupyter Notebooks is preferable to load user credentials from an external JSON file.\n\nOnce you are logged in, it is mandatory to use the token of the session to propagate the access of the clients to the host server:\n\n.. code-block:: python\n\n >>> token = oc.session_id\n >>> print(token)\n eyJhbGciOi...\n\n >>> oc = OpenCGAClient(configuration=config_dict, session_id=token)\n\nExamples\n````````\n\nThe next step is to create the specific client for the data we want to query:\n\n.. code-block:: python\n\n >>> projects = oc.projects # Query for projects\n >>> studies = oc.studies # Query for studies \n >>> samples = oc.samples() # Query for samples\n >>> cohorts = oc.cohorts() # Query for cohorts\n\nNow you can start asking to the OpenCGA RESTful service with pyOpenCGA:\n\n.. code-block:: python\n\n >>> for project in projects.search(owner=user).results(): \n ... print(project['id'])\n project1\n project2\n [...]\n\nThere are four different ways to access to the query response data:\n\n.. code-block:: python\n\n >>> foo_client.method().first() # Returns the first QueryResult \n >>> foo_client.method().result(position=0) # Returns the result from all QueryResults in a given position\n >>> foo_client.method().results() # Iterates over all the results of all the QueryResults\n >>> foo_client.method().response # Returns the raw response of the QueryResponse\n\nData can be accessed specifying comma-separated IDs or a list of IDs:\n\n.. code-block:: python\n\n >>> samples = 'NA12877,NA12878,NA12879'\n >>> samples_list = ['NA12877','NA12878','NA12879']\n >>> sc = oc.samples\n\n >>> for result in sc.info(query_id=samples, study='user@project1:study1').results():\n ... print(result['id'], result['attributes']['OPENCGA_INDIVIDUAL']['disorders'])\n NA12877 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n NA12878 []\n NA12879 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n\n >>> for result in sc.info(query_id=samples_list, study='user@project1:study1').results():\n ... print(result['id'], result['attributes']['OPENCGA_INDIVIDUAL']['disorders'])\n NA12877 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n NA12878 []\n NA12879 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n\nOptional filters and extra options can be added as key-value parameters (where the values can be a comma-separated string or a list).\n\nWhat can I ask for?\n```````````````````\nThe best way to know which data can be retrieved for each client check `OpenCGA web services`_ swagger.\n\n\n.. _OpenCGA: https://github.com/opencb/opencga\n.. _OpenCGA Docs: http://docs.opencb.org/display/opencga\n.. _virtual environment: https://help.dreamhost.com/hc/en-us/articles/115000695551-Installing-and-using-virtualenv-with-Python-3 \n.. _OpenCGA web services: http://bioinfodev.hpc.cam.ac.uk/opencga/webservices/\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyOpenCGA", "keywords": "opencb opencga bioinformatics genomic database", "license": "Apache Software License", "maintainer": "", "maintainer_email": "", "name": "pyopencga", "package_url": "https://pypi.org/project/pyopencga/", "platform": "", "project_url": "https://pypi.org/project/pyopencga/", "project_urls": { "Bug Reports": "https://github.com/opencb/opencga/issues", "Documentation": "http://docs.opencb.org/display/opencga/Python", "Homepage": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyOpenCGA", "OpenCGA": "https://github.com/opencb/opencga", "OpenCGA Documentation": "http://docs.opencb.org/display/opencga", "Source": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyOpenCGA" }, "release_url": "https://pypi.org/project/pyopencga/1.4.0/", "requires_dist": [ "requests (>=2.7)", "pip (>=7.1.2)", "pathlib (>=1.0.1)", "pyyaml (>=3.12)" ], "requires_python": "", "summary": "A REST client for OpenCGA REST web services", "version": "1.4.0" }, "last_serial": 5305133, "releases": { "1.4.0": [ { "comment_text": "", "digests": { "md5": "47f11a18d6408cfc5148c6871fd2205d", "sha256": "fd4374fbfd5854f2b7c8345fd0c852a0f693842ca7962433c454690fb8c7b844" }, "downloads": -1, "filename": "pyopencga-1.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "47f11a18d6408cfc5148c6871fd2205d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 43799, "upload_time": "2019-05-23T00:39:01", "url": "https://files.pythonhosted.org/packages/1b/f0/5c59e3b1d7859b8b83eb93eb871227bea7b7c40a70a7a4cb7a282108a6d8/pyopencga-1.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5112d8fbcf8d8f5f275be6645157f95a", "sha256": "af054d92635bcc728cf55809b28ea471c0fbca8b3b334fd096d144b83dd3fd8f" }, "downloads": -1, "filename": "pyopencga-1.4.0.tar.gz", "has_sig": false, "md5_digest": "5112d8fbcf8d8f5f275be6645157f95a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26646, "upload_time": "2019-05-23T00:39:04", "url": "https://files.pythonhosted.org/packages/ac/63/573027d19d58ad9a03642776dcd3ac2cd77a86411396dc63d4a8de28bd4c/pyopencga-1.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47f11a18d6408cfc5148c6871fd2205d", "sha256": "fd4374fbfd5854f2b7c8345fd0c852a0f693842ca7962433c454690fb8c7b844" }, "downloads": -1, "filename": "pyopencga-1.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "47f11a18d6408cfc5148c6871fd2205d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 43799, "upload_time": "2019-05-23T00:39:01", "url": "https://files.pythonhosted.org/packages/1b/f0/5c59e3b1d7859b8b83eb93eb871227bea7b7c40a70a7a4cb7a282108a6d8/pyopencga-1.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5112d8fbcf8d8f5f275be6645157f95a", "sha256": "af054d92635bcc728cf55809b28ea471c0fbca8b3b334fd096d144b83dd3fd8f" }, "downloads": -1, "filename": "pyopencga-1.4.0.tar.gz", "has_sig": false, "md5_digest": "5112d8fbcf8d8f5f275be6645157f95a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26646, "upload_time": "2019-05-23T00:39:04", "url": "https://files.pythonhosted.org/packages/ac/63/573027d19d58ad9a03642776dcd3ac2cd77a86411396dc63d4a8de28bd4c/pyopencga-1.4.0.tar.gz" } ] }