Introduction
In your Mantle Database, data is stored as entities. Each entity in your Mantle Database has a name and a data type. Each data type has a set of required properties and optional properties. You can view all of the entities of a data type as a table in your Mantle Database. Each entity is a row in a table, and the properties are columns of the table. There a multiple data types, such asrnaseq_fastq
or image_directory
.
Each value of each property is one of:
- string
- integer
- double (float)
- boolean
- file
Interacting with a single data entity
Getting an entity by its unique ID
Get an entity by its unique ID
Accessing an entity’s name and unique ID
If you got an entity by its unique ID and want to know its name:Get the name of an entity
Example output
Example output
Get the unique ID of an entity
Example output
Example output
Getting entity properties
To conveniently access the values of all of an entity’s properties, you can represent the entity as a Pandas series:Get entity properties as Pandas series
Example output
Example output
Downloading files from an entity
Files that are properties of entities are stored in Amazon S3. To use the files, you need to download them to your local working environment, whether you are in a Mantle Notebook or using a script on your own computer. Download files from file properties using thedownload_s3
method,
which takes as arguments the key of the property and the local path to
which the file will be downloaded.
Download files from properties
Querying for a group of entities and returning a DataFrame
To get a Pandas DataFrame where datasets are represented as rows, you can query for a group of datasets and turn them into a DataFrame.Query for datasets by data type
Convert iterable of entities to Pandas DataFrame
Creating a new data entity in your Mantle Database
To create a new entity in your Mantle Database, you must provide a name and a data type, and the required properties (each data type has a set of required properties and optional properties). The properties of the entity are expressed as key-value pairs. You can check what the properties of a data type are using the Mantle Database UI.
Example: create a new custom_file entity
Note that to use a file as a property, you need to pass a nested dictionary that instructs Mantle to upload a file from a local file path to Amazon S3:This is different from other properties, where you only need to pass the value.
Example: create a new rnaseq_fastq entity
The
local
keyword in Mantle relates to whether you’re asking the system
to create a new entity in the database via an API request.
In this version of the SDK, local
is set to True
by default to be consistent with earlier versions.
However, for most purposes, setting it to False
is appropriate.
When set to False
, the entity is automatically pushed to Mantle.