{ "info": { "author": "antonior,dapregi,ernesto-ocampo", "author_email": "antonio.rueda-martin@genomicsengland.co.uk,daniel.perez-gil@genomicsengland.co.uk,kenan.mcgrath@genomicsengland.co.uk", "bugtrack_url": null, "classifiers": [], "description": ".. contents::\n\nPyCGA\n==========\n\n- This Python package makes use of the exhaustive RESTful Web service API that has been implemented for the `OpenCGA`_ database.\n\n- It provides easy access to OpenCGA, an open-source project that aims to provide a Big Data storage engine and analysis framework for genomic scale data analysis of hundreds of terabytes or even petabytes.\n\n- More info about this project in the `OpenCGA Wiki`_\n\nInstallation\n------------\n\nCloning\n```````\nPyCGA 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::\n\n $ cd opencga/tree/develop/opencga-client/src/main/python\n $ python setup.py install\n\nUsage\n-----\n\nGetting started\n```````````````\nThe first step is to set up the OpenCGA server configuration:\n\n.. code-block:: python\n\n >>> configuration = {\n \"version\": \"v1\",\n \"rest\": {\n \"hosts\": [\"http://100.15.26.35:8080/opencga\"]\n }\n }\n\nThe configuration can be stored in a JSON or YML file as well:\n\n.. code-block:: python\n\n >>> configuration = '/path/to/config/opencga_configuration.json'\n\nThe second step is to import the module and initialize the OpenCGAClient. Configuration, user and password must be specified:\n\n.. code-block:: python\n\n >>> from pyCGA.opencgarestclients import OpenCGAClient\n >>> oc = OpenCGAClient(configuration=configuration, user='user_example', pwd='pass_example')\n\nIf user and password are not desired to be written down in a script, session id can be used instead:\n\n.. code-block:: python\n\n >>> from pyCGA.opencgarestclients import OpenCGAClient\n >>> oc = OpenCGAClient(configuration=configuration, user='user_example', pwd='pass_example') # Remove after getting session id\n >>> print oc.session_id # Remove after getting session id\n \"I4MG3fXJIZARl1LhwZ\"\n >>> oc = OpenCGAClient(configuration=configuration, session_id='I4MG3fXJIZARl1LhwZ')\n\nThe next step is to create the specific client for the data we want to query:\n\n.. code-block:: python\n\n >>> samples = oc.samples() # Query for samples\n >>> files = oc.files() # Query for files\n >>> cohorts = oc.cohorts() # Query for cohorts\n\nNow you can start asking to the OpenCGA RESTful service by providing a query ID:\n\n.. code-block:: python\n\n >>> sample_search = samples.search(study='study1', name='sample1').get()\n >>> print sample_search\n \"[{'acl': [{'member': '@gel', u'permissions': ['VIEW', 'VIEW_ANNOTATIONS']}...\"\n\nResponses are retrieved as JSON formatted data. Therefore, fields can be queried by key:\n\n.. code-block:: python\n\n >>> creation_date = oc.samples.search(study='study1', name='sample1').get()[0]['creationDate']\n \"20170204822738\"\n\nFirst levels in the JSON output can be accessed as attributes:\n\n.. code-block:: python\n\n >>> creation_date = samples.search(study='study1', name='sample1').get().creationDate\n \"20170204122738\"\n\n >>> annotation = cohorts.search(study='study1', name='cohort1').get().annotationSets\n >>> print annotation[0]['annotations'][0]['value']['sex']\n \"F\"\n\nRegex are allowed in some fields. This is specially useful when searching by name:\n\n.. code-block:: python\n\n >>> cohort_name = cohorts.search(study=study_id, name='~LP3000506-DNA_J01').get().name\n >>> print cohort_name\n \"LP3000506-DNA_J01_LP3000924-DNA_Z02_0\"\n\nData can be accessed specifying comma-separated IDs or a list of IDs:\n\n.. code-block:: python\n\n >>> creation_date = oc.samples.search(study='study1', name='sample1').get()[0]['creationDate']\n \"20170204822738\"\n\n >>> creation_date = oc.samples.search(study='study1', name='sample1').get()[1]['creationDate']\n \"20170204822738\"\n\n >>> creation_date = samples.search(study='study1', name='sample1,sample2').get().creationDate\n [\"20170204122738\", \"20170204123049\"]\n\nOptional filters and extra options can be added as key-value parameters (value can be a comma-separated string or a list):\n\n.. code-block:: python\n\n >>> # e.g. \"exclude\" parameter\n >>> attributes = oc.files.search(study='study1', name='~sample', bioformat='VARIANT', status='READY', exclude='attributes').get().attributes\n >>> print attributes\n [{}, {}, {}, {}, {}, {}, {}, {}]\n\n >>> # e.g. \"limit\" parameter\n >>> files = oc.files.search(study='study1', name='~sample', bioformat='VARIANT', status='READY', limit=1).get()\n >>> print len(files)\n 1\n\nSpecial mention for \"analysis_variant\" endpoint, which returns an iterator:\n\n.. code-block:: python\n\n >>> variant_iterator = oc.analysis_variant.query(pag_size=100, data={'studies': 'study1', 'gene': 'BRCA2'}, limit=1)\n >>> for variant in var_iterator:\n >>> print v.get().type\n \"SNV\"\n\nWhat can I ask for?\n```````````````````\nThe best way to know which data can be retrieved for each client is either checking out the `RESTful web services`_ section of the OpenCGA Wiki or the `OpenCGA web services`_\n\n\n.. _OpenCGA: https://github.com/opencb/opencga\n.. _OpenCGA Wiki: https://github.com/opencb/opencga/wiki\n.. _RESTful web services: https://github.com/opencb/opencga/wiki/RESTful-Web-Services\n.. _OpenCGA web services: http://bioinfodev.hpc.cam.ac.uk/opencga/webservices/\n\n\n", "description_content_type": "", "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", "keywords": "opencb opencga bioinformatics genomic database", "license": "Apache Software License", "maintainer": "", "maintainer_email": "", "name": "pyCGA", "package_url": "https://pypi.org/project/pyCGA/", "platform": "", "project_url": "https://pypi.org/project/pyCGA/", "project_urls": { "Homepage": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python" }, "release_url": "https://pypi.org/project/pyCGA/1.3.0/", "requires_dist": [ "PyYAML", "avro (==1.7.7)", "pathlib (>=1.0.1)", "pip (>=7.1.2)", "requests (>=2.7)", "requests-toolbelt (>=0.7.0)" ], "requires_python": "", "summary": "A REST client for OpenCGA web services", "version": "1.3.0" }, "last_serial": 3854001, "releases": { "1.3.0": [ { "comment_text": "", "digests": { "md5": "9b6b79c273c8d092dae0a548840dcbaa", "sha256": "7c860b51d4eb7bf729f904a595ac2343bb8b21f3e96f236a6955c5d07d6e80bc" }, "downloads": -1, "filename": "pyCGA-1.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "9b6b79c273c8d092dae0a548840dcbaa", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 22329, "upload_time": "2018-05-11T12:38:28", "url": "https://files.pythonhosted.org/packages/12/d4/1ed3b2834d168cca55635aeb0df165d3ffbcbf12a1c143618a96d62e05df/pyCGA-1.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d8f5cb2155cf3a05234d4fdad04e6d8f", "sha256": "89d90352167d3b170ee0b0d9455930ebe0f7a7a6fe01c1b4bb566470797f7692" }, "downloads": -1, "filename": "pyCGA-1.3.0.tar.gz", "has_sig": false, "md5_digest": "d8f5cb2155cf3a05234d4fdad04e6d8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18657, "upload_time": "2018-05-11T12:38:30", "url": "https://files.pythonhosted.org/packages/4b/59/53bcf899d80fce08be9e092c4db7e5ca261195f9bef066addb383b56f4b5/pyCGA-1.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9b6b79c273c8d092dae0a548840dcbaa", "sha256": "7c860b51d4eb7bf729f904a595ac2343bb8b21f3e96f236a6955c5d07d6e80bc" }, "downloads": -1, "filename": "pyCGA-1.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "9b6b79c273c8d092dae0a548840dcbaa", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 22329, "upload_time": "2018-05-11T12:38:28", "url": "https://files.pythonhosted.org/packages/12/d4/1ed3b2834d168cca55635aeb0df165d3ffbcbf12a1c143618a96d62e05df/pyCGA-1.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d8f5cb2155cf3a05234d4fdad04e6d8f", "sha256": "89d90352167d3b170ee0b0d9455930ebe0f7a7a6fe01c1b4bb566470797f7692" }, "downloads": -1, "filename": "pyCGA-1.3.0.tar.gz", "has_sig": false, "md5_digest": "d8f5cb2155cf3a05234d4fdad04e6d8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18657, "upload_time": "2018-05-11T12:38:30", "url": "https://files.pythonhosted.org/packages/4b/59/53bcf899d80fce08be9e092c4db7e5ca261195f9bef066addb383b56f4b5/pyCGA-1.3.0.tar.gz" } ] }