Skip to main content

An unofficial python wrapper for the Benchling API

Project description

BenchlingAPI

PyPI version

The (unofficial) python API wrapper for Benchling. For more information, see documentation at https://klavinslab.github.io/benchling-api/index.

Installation

pip install benchlingapi -U

Getting Started

Initialize a session using your Benchling-provided API key:

from benchlingapi import Session
session = Session("your_secret_benchling_api_key")

From there, you can access various models:

session.DNASequence
session.AASequence
session.Oligo
session.Folder
session.Project
session.Registry
session.Translation
session.EntitySchema
session.Batch
session.CustomEntity

Finding models:

# get one model
dna = session.DNASequence.one()

# find a specific model by its id
dna = session.DNASequence.find('sdg_4tg23')

# get the last 50 amino acids
proteins = session.AASequence.last(50)

# get a registry by name
registry = session.Registry.find_by_name("Klavins Lab Registry")

Updating models:

dna = session.DNASequence.one()
dna.name = "My new name"
dna.bases = "AGGTAGGGTAGGGCCAGAGA"

# update the sequence on the server
dna.update()

Saving new models:

folder = session.Folder.find_by_name("My API Folder")
dna = session.DNASequence(
    name = 'my new dna',
    bases = 'AGGTAGGATGGCCA',
    folder_id = folder.id,
    is_circular = False
)

# save the dna to your Benchling account
dna.save()

Registering models to your registry:

dna.set_schema("My DNA Schema")
dna.register()

See the documentation for more information: https://klavinslab.github.io/benchling-api/index

Testing

Testing is done using pytest. Tests will create live requests to a Benchling account. Since testing is done live, a Benchling account will need to be setup along with testing data.

To run tests, you must have a Benchling Account with an API key. Tests require a file in 'tests/secrets/config.json' with the following format:

{
  "credentials": {
    "api_key": "asdahhjwrthsdfgadfadfgadadsfa"
  },
  "sharelinks": [
    "https://benchling.com/s/seq-asdfadsfaee"
  ],
  "project": {
    "name": "API"
  },
  "trash_folder": {
    "name": "API_Trash"
  },
  "inventory_folder": {
    "name": "API_Inventory"
  }
}

On the Benchling side of things, in the account liked to the credentials["api_key"], you must have a project corresponding to the project["name"] value above. Within this project, you should have two folder corresponding to the trash_folder and inventory_folder values above. Additionally, you should have at least one example of an AminoAcid, DNASequence, CustomEntity, and Oligo stored within your inventory_folder. Tests will copy the examples from the inventory_folder for downstream tests. After the tests, conclude, inventory in the trash_folder will get archived.

Happy Cloning!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

benchlingapi-2.1.5.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

benchlingapi-2.1.5-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file benchlingapi-2.1.5.tar.gz.

File metadata

  • Download URL: benchlingapi-2.1.5.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.4 Darwin/18.6.0

File hashes

Hashes for benchlingapi-2.1.5.tar.gz
Algorithm Hash digest
SHA256 472ea1cc394fb4de8d7e05a3f10f4d14b963638e0b1dc6a5fee56afc9f50bc00
MD5 78a5bbc5d7c55f698525f7c67e0001b4
BLAKE2b-256 0c42b951e61f54b4d3f87c5635630a4dfd20538b497b7ec1d263837d9aaa4bb2

See more details on using hashes here.

File details

Details for the file benchlingapi-2.1.5-py3-none-any.whl.

File metadata

  • Download URL: benchlingapi-2.1.5-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.4 Darwin/18.6.0

File hashes

Hashes for benchlingapi-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4d89a48005df6f4ea771598ee864afbb9665ef3e6c4720bf89649959e25ea13a
MD5 aa96467b92e06a0bb25d56af2a6fe257
BLAKE2b-256 c77b24b86c9951de2690b02f78340a743d4d6c2bc9fa59bc5130fa93ed9425a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page