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:
EM Glossary v2.0.0: https://purls.helmholtz-metadaten.de/emg/v2.0.0/
OWL Ontology: Shipped with NexusLIMS at
nexusLIMS/schemas/references/em_glossary_2.0.owlLicense: CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
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 the EM Glossary label for an EMG ID. |
|
Get the EM Glossary definition for an EMG ID. |
|
Get the EM Glossary ID for a NexusLIMS field name. |
|
Get the human-readable display name for a field. |
|
Get the NexusLIMS description for a field. |
|
Check if a field has an EM Glossary ID mapping. |
|
Get the full EM Glossary URI for a field. |
|
Get a list of all fields with NexusLIMS mappings. |
|
Get a list of fields that have EM Glossary ID mappings. |
|
Get all EM Glossary terms from the OWL file. |
Data#
Path to the EM Glossary OWL file shipped with NexusLIMS |
|
Version of the packaged EM Glossary OWL file |
|
RDF Namespace for the EM Glossary |
|
RDF Namespace for OBO |
|
Mapping from NexusLIMS internal field names to EM Glossary terms
Format: |
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:
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:
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.
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.
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:
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.