Introduction

A Mantle analysis object encapsulates an analysis notebook and links to the notebook’s inputs, as well as its output datasets and files.

Getting an analysis by unique ID

Get an analysis by its unique ID

import mantlebio

mantle = mantlebio.MantleClient()

analysis = mantle.analysis.get("analysis-id")

Adding inputs to analyses

Adding a Mantle dataset as an input to an analysis

Mantle datasets can be retrieved using their unique ID and added as inputs to an analysis.

Get dataset by ID and add it as an input to an analysis

import mantlebio

mantle = mantlebio.MantleClient()

analysis = mantle.analysis.get("analysis-id")

dataset = mantle.dataset.get("dataset-id")

analysis.add_input("my_dataset_input", dataset)

Adding a file input to an analysis

Track file inputs in your analysis by adding file inputs, specifying a key to identify the input and the file’s local path.

Add a file input to an analysis
import mantlebio
import os

mantle = mantlebio.MantleClient()

analysis = mantle.analysis.get("analysis-id")

analysis.add_file_input("my_file_input", f"{os.getcwd()}/some_input.txt")

Adding a Python string or Boolean input to an analysis

Track string or Boolean inputs by specifying the input key and value.

Add a Python string or Boolean input to an analysis

import mantlebio

mantle = mantlebio.MantleClient()

analysis = mantle.analysis.get("analysis-id")

analysis.add_input("my_string_input", "some string")
analysis.add_input("my_boolean_input", True)

Adding outputs to analyses

Adding a dataset output to an analysis

Add dataset outputs to an analysis to track the generated outputs, providing a key to identify the output as well as the output file’s path.

Add dataset output

import mantlebio

mantle = mantlebio.MantleClient()

# Create a dataset
dataset = mantle.dataset.create(
    name="4XP1",
    local=False,
    properties={
        "description": "X-ray structure of Drosophila dopamine transporter bound to neurotransmitter dopamine",
        "resolution": 2.5,
        "r_value": 0.2,
    }
)

# Add dataset output to an analysis
analysis = mantle.analysis.get("analysis-id")

analysis.add_output('my_output_dataset', dataset)

Adding a file output to an analysis

Add file outputs to an analysis to track the generated outputs, providing a key to identify the output as well as the output file’s path.

Add a file output to an analysis
import mantlebio

mantle = mantlebio.MantleClient()

analysis = mantle.analysis.get("analysis-id")

analysis.add_file_output("my_file_output", f"{os.getcwd()}/some_output.txt")

Adding a Python string or Boolean output to an analysis

Track string or Boolean outputs by specifying the output key and value.

Add a Python string or Boolean output to an analysis

import mantlebio

mantle = mantlebio.MantleClient()

analysis = mantle.analysis.get("analysis-id")

analysis.add_output("my_string_output", "some string")
analysis.add_output("my_boolean_output", True)