Python wrapper for Benchling API with common functions used at MGTX DSC
Project description
mgtx-benchling-wrapper
A wrapper of the Benchling API with common functions and workflows used at MGTX DSC.
Installation 🚀
You can install this package using:
pip install mgtx-benchling-wrapper
Quickstart 🚩
After creating an app on your Benchling tenant, create a config.yaml file in your repo. The following are the contents of the config.yaml
BenchlingCredentials:
benchling_url: 'https://mytenant.benchling.com'
benchling_access_token: 'https://mytenant.benchling.com/api/v2/token'
app_client_id: 'your-app-client-id'
app_client_secret: 'encrypted-client-secret'
AssaySchema:
schema_id: "schema_api_id"
Project:
project_id: "project_api_id"
The app_client_secret should be encrypted. Create encryption.py Use cryptography as follows:
from cryptography.fernet import Fernet
def decrypt(value):
return f.decrypt(value.encode()).decode()
def encrypt(value):
return f.encrypt(value.encode()).decode()
if __name__ == "__main__":
# Run this to print an encrypted string of "my-value"
print(encrypt('your-app-client-secret))
The following is an example of the use of the assay_results_ingestion workflow.
import yaml
from encryption import decrypt
from mgtx_benchling_wrapper.context.benchling_context import BenchlingContext
from mgtx_benchling_wrapper.wrapper.facade import BenchlingWrapperFacade
from mgtx_benchling_wrapper.workflows.assays_result_ingestion import (
AssayResultIngestionWorkflow
)
def config():
with open("tests/config/test_config.yml") as f:
return yaml.safe_load(f)
#create the benchling context
ctx = BenchlingContext(
base_url=config()['BenchlingCredentials']['benchling_url'],
client_id=config()['BenchlingCredentials']['app_client_id'],
client_secret=decrypt(config()['BenchlingCredentials']['app_client_secret']),
token_url=config()['BenchlingCredentials']['benchling_access_token'],
)
#initialize the wrapper
wrapper = BenchlingWrapperFacade(ctx.benchling())
#retrieve assay_schema_id
schema_id = config()['AssaySchema']['schema_id']
#retrieve project_id
project_id = config()['Project']['project_id']
#initiate results ingestion workflow
results_ingestion = AssayResultIngestionWorkflow(wrapper)
#ingest results on benchling
list_missing_entities = results_ingestion.assay_results_ingestion_updated(
[dataframe_to_ingest],
schema_id,
project_id,
unique_identifiers =['assay_run_id', 'sample_id']
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mgtx_benchling_wrapper-0.1.0.tar.gz.
File metadata
- Download URL: mgtx_benchling_wrapper-0.1.0.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a6aacb29595ecdb702b6b3a97b3b15b7fcb2843bd9396987316c5a9a5b5fa81
|
|
| MD5 |
547bb1b7ccb7c9a14299c99c6f63644b
|
|
| BLAKE2b-256 |
0a36138e61e1de7d0961e33239864aad53fbfa42c90a311e2a66c589264dfb25
|
Provenance
The following attestation bundles were made for mgtx_benchling_wrapper-0.1.0.tar.gz:
Publisher:
publish.yml on MGTX-Data-Science/mgtx-benchling-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgtx_benchling_wrapper-0.1.0.tar.gz -
Subject digest:
3a6aacb29595ecdb702b6b3a97b3b15b7fcb2843bd9396987316c5a9a5b5fa81 - Sigstore transparency entry: 1351709871
- Sigstore integration time:
-
Permalink:
MGTX-Data-Science/mgtx-benchling-wrapper@2c3281447b839e58dd51a4f01abe22e9d94b7d0e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/MGTX-Data-Science
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c3281447b839e58dd51a4f01abe22e9d94b7d0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file mgtx_benchling_wrapper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mgtx_benchling_wrapper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 49.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce7d280ebc16187ac0ca4f160a90a045acf8fcd7d9e0cb26b9685940ffbb6407
|
|
| MD5 |
e395d7db1b97728a7bab710a049d3fd4
|
|
| BLAKE2b-256 |
d4491beb12a81f593789fb19d3ae723ab000c8484367051f82e6b6ebd65659a8
|
Provenance
The following attestation bundles were made for mgtx_benchling_wrapper-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on MGTX-Data-Science/mgtx-benchling-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgtx_benchling_wrapper-0.1.0-py3-none-any.whl -
Subject digest:
ce7d280ebc16187ac0ca4f160a90a045acf8fcd7d9e0cb26b9685940ffbb6407 - Sigstore transparency entry: 1351710030
- Sigstore integration time:
-
Permalink:
MGTX-Data-Science/mgtx-benchling-wrapper@2c3281447b839e58dd51a4f01abe22e9d94b7d0e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/MGTX-Data-Science
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c3281447b839e58dd51a4f01abe22e9d94b7d0e -
Trigger Event:
push
-
Statement type: