nexusLIMS.schemas.em_glossary#

EM Glossary field name mappings for NexusLIMS metadata.

This module provides mappings between NexusLIMS internal field names, display names, and EM Glossary (EMG) standardized terminology. The EM Glossary is a community-driven ontology for electron microscopy metadata maintained by the Helmholtz Metadata Collaboration.

The module uses RDFLib to parse the EM Glossary OWL ontology file, providing access to term labels, definitions, and the full semantic structure.

EM Glossary Version: v2.0.0

References:

The mappings in this module enable:

  • Standardized field names across instruments and vendors

  • Cross-reference to EM Glossary IDs for semantic interoperability

  • Human-readable display names for XML output

  • Dynamic loading from the OWL ontology using RDFLib

Examples:

Get EM Glossary ID for a field:

>>> from nexusLIMS.schemas.em_glossary import get_emg_id
>>> get_emg_id("acceleration_voltage")
'EMG_00000004'

Get display name for XML:

>>> from nexusLIMS.schemas.em_glossary import get_display_name
>>> get_display_name("acceleration_voltage")
'Voltage'

Get EMG label from ID:

>>> from nexusLIMS.schemas.em_glossary import get_emg_label
>>> get_emg_label("EMG_00000004")
'Acceleration Voltage'

Get EMG definition:

>>> from nexusLIMS.schemas.em_glossary import get_emg_definition
>>> defn = get_emg_definition("EMG_00000004")
>>> print(defn)
The potential difference between anode and cathode.

Check if field has EMG mapping:

>>> from nexusLIMS.schemas.em_glossary import has_emg_id
>>> has_emg_id("acceleration_voltage")
True
>>> has_emg_id("custom_vendor_field")
False

Module Contents#

Functions#

get_emg_label

Get the EM Glossary label for an EMG ID.

get_emg_definition

Get the EM Glossary definition for an EMG ID.

get_emg_id

Get the EM Glossary ID for a NexusLIMS field name.

get_display_name

Get the human-readable display name for a field.

get_description

Get the NexusLIMS description for a field.

has_emg_id

Check if a field has an EM Glossary ID mapping.

get_emg_uri

Get the full EM Glossary URI for a field.

get_all_mapped_fields

Get a list of all fields with NexusLIMS mappings.

get_fields_with_emg_ids

Get a list of fields that have EM Glossary ID mappings.

get_all_emg_terms

Get all EM Glossary terms from the OWL file.

Data#

EMG_OWL_PATH

Path to the EM Glossary OWL file shipped with NexusLIMS

EMG_VERSION

Version of the packaged EM Glossary OWL file

EMG

RDF Namespace for the EM Glossary

OBO

RDF Namespace for OBO

NEXUSLIMS_TO_EMG_MAPPINGS

Mapping from NexusLIMS internal field names to EM Glossary terms Format: internal_field_name -> (display_name, emg_label or None, description) The emg_label is used to look up the EMG_ID from the OWL file

API#

nexusLIMS.schemas.em_glossary.EMG_OWL_PATH#

Path to the EM Glossary OWL file shipped with NexusLIMS

nexusLIMS.schemas.em_glossary.EMG_VERSION#

‘v2.0.0’

Version of the packaged EM Glossary OWL file

nexusLIMS.schemas.em_glossary.EMG#

‘Namespace(…)’

RDF Namespace for the EM Glossary

nexusLIMS.schemas.em_glossary.OBO#

‘Namespace(…)’

RDF Namespace for OBO

nexusLIMS.schemas.em_glossary.NEXUSLIMS_TO_EMG_MAPPINGS#

Type: typing.Dict[str, tuple[str, str | None, str]]

Mapping from NexusLIMS internal field names to EM Glossary terms Format: internal_field_name -> (display_name, emg_label or None, description) The emg_label is used to look up the EMG_ID from the OWL file

nexusLIMS.schemas.em_glossary.get_emg_label(emg_id: str) str | None[source]#

Get the EM Glossary label for an EMG ID.

Looks up the human-readable label from the OWL ontology file.

Parameters:

emg_id (str) – EM Glossary ID (e.g., “EMG_00000004”)

Returns:

EMG label, or None if ID not found

Return type:

str or None

Examples:

>>> get_emg_label("EMG_00000004")
'Acceleration Voltage'
>>> get_emg_label("EMG_00000050")
'Working Distance'
>>> get_emg_label("EMG_99999999") is None
True
nexusLIMS.schemas.em_glossary.get_emg_definition(emg_id: str) str | None[source]#

Get the EM Glossary definition for an EMG ID.

Looks up the formal definition from the OWL ontology file.

Parameters:

emg_id (str) – EM Glossary ID (e.g., “EMG_00000004”)

Returns:

EMG definition, or None if ID not found or no definition available

Return type:

str or None

Examples:

>>> defn = get_emg_definition("EMG_00000004")
>>> print(defn)
The potential difference between anode and cathode.
>>> get_emg_definition("EMG_99999999") is None
True
nexusLIMS.schemas.em_glossary.get_emg_id(field_name: str) str | None[source]#

Get the EM Glossary ID for a NexusLIMS field name.

Looks up the field in NEXUSLIMS_TO_EMG_MAPPINGS, then resolves the EMG label to an ID from the OWL ontology.

Parameters:

field_name (str) – Internal field name (e.g., “acceleration_voltage”)

Returns:

EM Glossary ID string (e.g., “EMG_00000004”), or None if not mapped

Return type:

str or None

Examples:

>>> get_emg_id("acceleration_voltage")
'EMG_00000004'
>>> get_emg_id("working_distance")
'EMG_00000050'
>>> get_emg_id("custom_field") is None
True

Notes:

Not all NexusLIMS fields have EM Glossary equivalents. This is expected as EMG is a growing ontology and some fields are vendor-specific or outside the scope of EMG’s current coverage (v2.0.0).

nexusLIMS.schemas.em_glossary.get_display_name(field_name: str) str[source]#

Get the human-readable display name for a field.

Returns the display name used in XML output and user-facing documentation. If the field is not in the mapping, returns a title-cased version of the field name with underscores replaced by spaces.

Parameters:

field_name (str) – Internal field name (e.g., “acceleration_voltage”)

Returns:

Display name for the field

Return type:

str

Examples:

>>> get_display_name("acceleration_voltage")
'Voltage'
>>> get_display_name("working_distance")
'Working Distance'
>>> get_display_name("custom_field")
'Custom Field'

Notes:

For unmapped fields, the function applies a simple transformation: replace underscores with spaces and title-case the result. This ensures all fields have reasonable display names even without explicit mappings.

nexusLIMS.schemas.em_glossary.get_description(field_name: str) str | None[source]#

Get the NexusLIMS description for a field.

Returns a brief description of what the field represents from the NexusLIMS mappings. For EMG formal definitions, use get_emg_definition().

Parameters:

field_name (str) – Internal field name (e.g., “acceleration_voltage”)

Returns:

Field description, or None if not mapped

Return type:

str or None

Examples:

>>> desc = get_description("acceleration_voltage")
>>> print(desc)
Accelerating voltage of the electron/ion beam
>>> get_description("unknown_field") is None
True
nexusLIMS.schemas.em_glossary.has_emg_id(field_name: str) bool[source]#

Check if a field has an EM Glossary ID mapping.

Returns True if the field has a corresponding EMG ID in v2.0.0, False otherwise. This is useful for determining whether semantic annotations are available.

Parameters:

field_name (str) – Internal field name (e.g., “acceleration_voltage”)

Returns:

True if field has EMG ID, False otherwise

Return type:

bool

Examples:

>>> has_emg_id("acceleration_voltage")
True
>>> has_emg_id("magnification")
False
>>> has_emg_id("custom_field")
False
nexusLIMS.schemas.em_glossary.get_emg_uri(field_name: str) str | None[source]#

Get the full EM Glossary URI for a field.

Returns the complete PURL (Persistent URL) for the field’s EM Glossary v2.0.0 entry. This enables Tier 3 semantic web integration and linkage to the full EMG ontology.

Parameters:

field_name (str) – Internal field name (e.g., “acceleration_voltage”)

Returns:

Full EMG PURL, or None if field has no EMG ID

Return type:

str or None

Examples:

>>> get_emg_uri("acceleration_voltage")
'https://purls.helmholtz-metadaten.de/emg/v2.0.0/EMG_00000004'
>>> get_emg_uri("working_distance")
'https://purls.helmholtz-metadaten.de/emg/v2.0.0/EMG_00000050'
>>> get_emg_uri("custom_field") is None
True

Notes:

The returned URI is a PURL that redirects to the canonical EMG ontology entry. These URIs are suitable for use in RDF/OWL ontologies and semantic web applications.

nexusLIMS.schemas.em_glossary.get_all_mapped_fields() list[str][source]#

Get a list of all fields with NexusLIMS mappings.

Returns a sorted list of all internal field names that have entries in the NEXUSLIMS_TO_EMG_MAPPINGS dictionary.

Returns:

Sorted list of field names with mappings

Return type:

list[str]

Examples:

>>> fields = get_all_mapped_fields()
>>> "acceleration_voltage" in fields
True
>>> len(fields) > 0
True
nexusLIMS.schemas.em_glossary.get_fields_with_emg_ids() list[str][source]#

Get a list of fields that have EM Glossary ID mappings.

Returns only fields with actual EMG IDs (non-None values), excluding fields that have display names but no EMG equivalents.

Returns:

Sorted list of field names with EMG IDs

Return type:

list[str]

Examples:

>>> fields = get_fields_with_emg_ids()
>>> "acceleration_voltage" in fields
True
>>> "magnification" in fields  # Has display name but no EMG ID
False
nexusLIMS.schemas.em_glossary.get_all_emg_terms() Dict[str, Dict[str, str]][source]#

Get all EM Glossary terms from the OWL file.

Returns the complete mapping of EMG IDs to labels and definitions loaded from the ontology. Useful for discovering available EMG terms.

Returns:

Mapping from EMG_ID -> {‘label’: str, ‘definition’: str | None}

Return type:

dict[str, dict[str, str]]

Examples:

>>> terms = get_all_emg_terms()
>>> "EMG_00000004" in terms
True
>>> terms["EMG_00000004"]["label"]
'Acceleration Voltage'
>>> print(terms["EMG_00000004"]["definition"])
The potential difference between anode and cathode.