modos.helpers.schema ==================== .. py:module:: modos.helpers.schema .. autoapi-nested-parse:: Introspection utilities for the MODO schema. This module provides helpers for accessing the schema structure and for converting instances to different representations. Attributes ---------- .. autoapisummary:: modos.helpers.schema.SCHEMA_PATH Classes ------- .. autoapisummary:: modos.helpers.schema.UserElementType modos.helpers.schema.ElementType Functions --------- .. autoapisummary:: modos.helpers.schema.class_from_name modos.helpers.schema.dict_to_instance modos.helpers.schema.is_full_id modos.helpers.schema.set_haspart_relationship modos.helpers.schema.update_haspart_id modos.helpers.schema.set_data_path modos.helpers.schema.is_uri modos.helpers.schema.load_schema modos.helpers.schema.load_prefixmap modos.helpers.schema.get_slots modos.helpers.schema.instance_to_graph modos.helpers.schema.get_slot_range modos.helpers.schema.get_enum_values modos.helpers.schema.get_haspart_property Module Contents --------------- .. py:data:: SCHEMA_PATH .. py:function:: class_from_name(name) .. py:function:: dict_to_instance(element) .. py:function:: is_full_id(element_id) Checks if an element_id contains the element type as prefix. .. rubric:: Examples >>> is_full_id("sample1") False >>> is_full_id("data/test") True >>> is_full_id("/assay/test_assay") True .. py:function:: set_haspart_relationship(child_class, child_path, parent_group) Add element to the hasPart attribute of a parent zarr group .. py:function:: update_haspart_id(element) update the id of the has_part property of an element to use the full id including its type .. py:function:: set_data_path(element, source_file = None) Set the data_path attribute, if it is not specified to the modo root. .. py:class:: UserElementType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Enumeration of element types exposed to the user. .. py:attribute:: SAMPLE :value: 'sample' .. py:attribute:: ASSAY :value: 'assay' .. py:attribute:: DATA_ENTITY :value: 'data' .. py:attribute:: REFERENCE_GENOME :value: 'reference' .. py:method:: get_target_class() Return the target class for the element type. .. py:method:: from_object(obj) :classmethod: Return the element type from an object. .. py:class:: ElementType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Enumeration of all element types. .. py:attribute:: SAMPLE :value: 'sample' .. py:attribute:: ASSAY :value: 'assay' .. py:attribute:: DATA_ENTITY :value: 'data' .. py:attribute:: REFERENCE_GENOME :value: 'reference' .. py:attribute:: REFERENCE_SEQUENCE :value: 'sequence' .. py:method:: get_target_class() Return the target class for the element type. .. py:method:: from_object(obj) :classmethod: Return the element type from an object. .. py:method:: from_model_name(name) :classmethod: Return the element type from an object name. .. py:function:: is_uri(text) Checks if input is a valid URI. .. py:function:: load_schema() Return a view over the schema structure. .. py:function:: load_prefixmap() Load the prefixmap. .. py:function:: get_slots(target_class, required_only=False) Return a list of required slots for a class. .. py:function:: instance_to_graph(instance) .. py:function:: get_slot_range(slot_name) Return the class-independent range of a slot. .. py:function:: get_enum_values(enum_name) .. py:function:: get_haspart_property(child_class) Return the name of the "has_part" property for a target class. If no such property is in the schema, return None. .. rubric:: Examples >>> get_haspart_property('AlignmentSet') 'has_data' >>> get_haspart_property('Assay') 'has_assay'