Giter VIP home page Giter VIP logo

bms-gen3-client's Introduction

bms-gen3-client

Includes API client wrapper for Gen3, supporting HTTP basic auth and eternal API keys.

Features

  • Eternal API keys via basic HTTP auth
  • Fetch projects data from Gen3 via Peregrine (Graph Model)

Install

Fetch code

$ git clone https://github.com/jacquayj/bms-gen3-client.git
$ cd bms-gen3-client

(optional) Create virtual environment

$ python3 -m venv .venv
$ source .venv/bin/activate

Installation

$ pip install -r requirements.txt
$ python setup.py install

Usage

from bms_gen3_client import Gen3Client

client = Gen3Client(
    "https://bms-gen3-dev.johnjacquay.com",
    api_user="my-account",
    api_pass="$2b$12$2CKlcJHgdJw0IaK.RktfveH5NFWW4KxrMFaKjPnbCdbLEJcBeDA6m"
)

# Fetch projects
projects = client.fetch_projects(limit=1000, offset=0)

# Raw GraphQL query using gen3.submission.Gen3Submission
client.submission.query("{project{code}}")

# Fetch object GUID by S3 URI
guid = client.get_guid_by_s3_uri("s3://my-bucket/my-obj.txt")

## INFO: 
# Access instantiated class 'gen3.submission.Gen3Submission' via 'client.submission'
# https://gen3sdk-python.readthedocs.io/en/latest/submission.html
#
# Access instantiated class 'gen3.file.Gen3File' via 'client.file'
# https://gen3sdk-python.readthedocs.io/en/latest/file.html


# Create a generic submission, see create_project example below for json_dict example of a project node
client.submission.submit_record(json_dict)

# Fetch the presigned AWS S3 URL for downloading data via GUID
download_url = client.file.get_presigned_url("dg.XXXX/e8dd1662-25d8-4c94-87f9-4c3d0e8d16e4")

# Create project
# https://gen3sdk-python.readthedocs.io/en/latest/submission.html
client.submission.create_project("bms_open", {
    "type": "project",
    "availability_type": "Restricted",
    "collaborators": [],
    "data_provider": "ABI",
    "dbgap_accession_number": "na",
    "indication": "Lung",
    "investigator_name": "fghj",
    "molecular_analysis_method": "Cytogenetics, NOS",
    "name": "dfgj",
    "project_barcode": "na",
    "project_description": "fghj",
    "project_type": "Non Clinical",
    "therapeutic_area": "Atherosclerosis NOS",
    "translational_program": "IPF",
    "trial": "CA111-555"
})

# Arbitrary get, post, put, delete requests
dictionary = client.authd_get("/api/v0/submission/_dictionary/_all").json()
projects = client.authd_post("/api/v0/submission/graphql", json={"query":"{project{code}}"}).json()

bms-gen3-client's People

Contributors

jacquayj avatar

Watchers

 avatar

Forkers

ktram80

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.