somacore

1.0.29 · active · verified Fri Apr 17

somacore provides the Python-language API specification and base utilities for the SOMA (Scalable Open Multi-omics Array) system. It defines abstract base classes and protocols for core SOMA objects like Experiment, Measurement, DataFrame, and Arrays. As of version 1.0.29, it focuses on defining the SOMA data model for interoperability. The library is actively maintained with frequent updates, often aligning with updates to the broader SOMA specification.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates importing core `somacore` types and enumerations. It highlights that `somacore` provides abstract definitions and protocols for the SOMA data model, which are not directly instantiable. Instead, concrete implementations (like `tiledbsoma`) are required to create and manipulate SOMA objects. The example shows how to access the library version and inspect available enumeration values.

import somacore
from somacore import AxisType, OpenMode, SOMAObject

# somacore provides abstract base classes (Protocols)
# for SOMA objects and related concepts.
print(f"somacore version: {somacore.__version__}")

# You can import and inspect enumeration types
print(f"Available Axis Types: {list(AxisType)}")
print(f"Read mode for opening objects: {OpenMode.READ}")

# SOMAObject is a core Protocol (an Abstract Base Class for type hinting)
print(f"SOMAObject is a {type(SOMAObject).__name__}")

# You cannot instantiate these protocols directly;
# they are meant for type checking and as interfaces for implementations.
# For example, this would raise a TypeError:
# try:
#     obj = SOMAObject("some_uri")
# except TypeError as e:
#     print(f"\nCannot instantiate SOMAObject directly: {e}")

print("\nsomacore defines the SOMA API. For concrete implementations,")
print("refer to libraries like `tiledbsoma` which implement these protocols.")

view raw JSON →