GET experiment

get an experiment from MaveDB via the API

To begin, import the modeules below.

import attr, os
from pprint import PrettyPrinter
from mavetools.client.client import Client
from mavetools.models.experiment import Experiment

Pretty printer is used to format the output nicely.

pp = PrettyPrinter(indent=2)  # displayes results in readable format

Here your base_url is set to localhost, http://127.0.0.1:8000/api/. This default funcionality is what you would want to use when working with a local instance of MaveDB (e.g., a development branch). If working with production mavedb you would set base url to https://www.mavedb.org/api/.

In the cell below, comment out the base_url you will not be using.

base_url = 'http://127.0.0.1:8000/api/'
#base_url = 'https://www.mavedb.org/api/'

Set experiment_urn to match the experiment you want to get.

experiment_urn = 'urn:mavedb:00000001-a'

Next, you will need an auth_token to make POST requests to MaveDB. If you have one, substitute it in the example provided below. If you need one, please follow these instructions:

1. go to https://www.mavedb.org
2. login using your ORCID ID
3. go to settings
4. generate new auth token
5. copy auth token and pase it in the auth_token field below
# Generate a new auth_token in your profile and post it here
auth_token = 'R2skRbpBD3Rsf5dNHoQxDZevdEE74T5lCKMFyBhBwwPFH4ZfTrxDz7TZ0kbFLtEZ'

Here you instantiate the Client object. The Client object is the object by which the POST request is performed. The client object is instantiated with the value of base_url provided earlier, so make sure that is up-to-date. If base_url does not exist, base_url is defaulted to localhost, http://127.0.0.1:8000/api/.

client = Client(base_url, auth_token=auth_token) if base_url else Client(auth_token=auth_token)

GET the model instance by passing the model type (Experiment, in this instance) and the experiment_urn as arguments to the get_model_istance funtion that operates on the Client object. This will GET the model instance (resource) from the server via the approprate API endpoint.

experiment = client.get_model_instance(Experiment, experiment_urn)

Now, display the results!

pp.pprint(attr.asdict(experiment))
{ 'abstract_text': 'Although we now routinely sequence human genomes, we can '
                   'confidently identify only a fraction of the sequence '
                   'variants that have a functional impact. Here, we developed '
                   'a deep mutational scanning framework that produces '
                   'exhaustive maps for human missense variants by combining '
                   'random codon mutagenesis and multiplexed functional '
                   'variation assays with computational imputation and '
                   'refinement. We applied this framework to four proteins '
                   'corresponding to six human genes: UBE2I (encoding SUMO E2 '
                   'conjugase), SUMO1 (small ubiquitin-like modifier), TPK1 '
                   '(thiamin pyrophosphokinase), and CALM1/2/3 (three genes '
                   'encoding the protein calmodulin). The resulting maps '
                   'recapitulate known protein features and confidently '
                   'identify pathogenic variation. Assays potentially amenable '
                   'to deep mutational scanning are already available for 57% '
                   'of human disease genes, suggesting that DMS could '
                   'ultimately map functional variation for all human disease '
                   'genes.',
  'approved': None,
  'contributors': ['0000-0003-1628-9390'],
  'created_by': '0000-0003-1628-9390',
  'creation_date': '2018-06-26',
  'doi_ids': [],
  'experimentset': 'urn:mavedb:00000001',
  'extra_metadata': {},
  'keywords': [ {'text': 'E2'},
                {'text': 'sumoylation'},
                {'text': 'imputation'},
                {'text': 'complementation'}],
  'last_child_value': None,
  'method_text': 'A Deep Mutational Scan of UBE2I using functional '
                 'complementation in yeast was performed using two different '
                 'methods: DMS-BarSeq and DMS-TileSeq, both datasets were '
                 'combined and a machine-learning method was used to impute '
                 'the effects of missing variants and refine measurements of '
                 'lower confidence. See [Weile *et al.* '
                 '2017](http://msb.embopress.org/content/13/12/957) for '
                 'details.',
  'modification_date': '2019-08-08',
  'modified_by': '0000-0003-1628-9390',
  'private': None,
  'publish_date': '2018-06-26',
  'pubmed_ids': [ { 'dbname': 'PubMed',
                    'dbversion': None,
                    'identifier': '29269382',
                    'url': 'http://www.ncbi.nlm.nih.gov/pubmed/29269382'}],
  'scoresets': [ 'urn:mavedb:00000001-a-2',
                 'urn:mavedb:00000001-a-3',
                 'urn:mavedb:00000001-a-4',
                 'urn:mavedb:00000001-a-1'],
  'short_description': 'A Deep Mutational Scan of the human SUMO E2 conjugase '
                       'UBE2I using functional complementation in yeast.',
  'sra_ids': [ { 'dbname': 'SRA',
                 'dbversion': None,
                 'identifier': 'SRP109101',
                 'url': 'http://www.ebi.ac.uk/ena/data/view/SRP109101'},
               { 'dbname': 'SRA',
                 'dbversion': None,
                 'identifier': 'SRP109119',
                 'url': 'http://www.ebi.ac.uk/ena/data/view/SRP109119'}],
  'title': 'UBE2I yeast complementation',
  'urn': 'urn:mavedb:00000001-a'}