From d06bd0d4fd67e0d34b36647a7a5488bec2ec9bc4 Mon Sep 17 00:00:00 2001 From: Tobias O Date: Tue, 7 Apr 2026 19:46:12 +1200 Subject: [PATCH] [Feature] Minimal IUCLID export (#338) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an initial implementation that creates a working minimal .i6z document. It passes schema validation and can be imported into IUCLID. Caveat: IUCLID files target individual compounds. Pathway is not actually covered by the format. It can be added in either soil or water and soil OECD endpoints. **I currently only implemented the soil endpoint for all data.** This sort of works, and I can report all degradation products in a pathway (not a nice view, but we can report many transformation products and add a diagram attachment in the future). Adding additional information is an absolute pain, as we need to explicitly map each type of information to the relevant OECD field. I use the XSD scheme for validation, but unfortunately the IUCLID parser is not fully compliant and requires a specific order, etc. The workflow is: finding the AI structure from the XSD scheme -> make the scheme validation pass -> upload to IUCLID to get obscure error messages -> guess what could be wrong -> repeat 💣 New specifications get released once per year, so we will have to update accordingly. I believe that this should be a more expensive feature, as it requires significant effort to uphold. Currently implemented for root compound only in SOIL: - Soil Texture 2 - Soil Texture 1 - pH value - Half-life per soil sample / scenario (mapped to disappearance; not sure about that). - CEC - Organic Matter (only Carbon) - Moisture content - Humidity image.png image.png image.png Reviewed-on: https://git.envipath.com/enviPath/enviPy/pulls/338 Co-authored-by: Tobias O Co-committed-by: Tobias O --- .pre-commit-config.yaml | 4 +- envipath/settings.py | 6 + epapi/tests/v1/test_schema_generation.py | 1 - epapi/v1/dal.py | 10 +- epapi/v1/interfaces/__init__.py | 3 + epapi/v1/interfaces/iuclid/__init__.py | 0 epapi/v1/interfaces/iuclid/dto.py | 58 + epapi/v1/interfaces/iuclid/projections.py | 142 + epapi/v1/router.py | 6 + epdb/models.py | 4 +- epiuclid/__init__.py | 0 epiuclid/api.py | 22 + epiuclid/apps.py | 6 + epiuclid/builders/__init__.py | 0 epiuclid/builders/base.py | 105 + epiuclid/builders/endpoint_study.py | 259 + epiuclid/builders/reference_substance.py | 54 + epiuclid/builders/substance.py | 37 + epiuclid/schemas/loader.py | 90 + .../domain/v10/REFERENCE_SUBSTANCE-10.0.xsd | 237 + .../schemas/v10/domain/v10/SUBSTANCE-10.0.xsd | 266 + .../v10/domain/v10/commonTypesDomainV10.xsd | 24395 +++++++++++ ...STUDY_RECORD-BiodegradationInSoil-10.0.xsd | 1393 + .../v10/oecd/v10/commonTypesOecdV10.xsd | 34308 ++++++++++++++++ epiuclid/schemas/v10/platform-attachment.xsd | 73 + .../schemas/v10/platform-container-v2.xsd | 92 + epiuclid/schemas/v10/platform-fields.xsd | 611 + epiuclid/schemas/v10/platform-metadata.xsd | 138 + .../v10/platform-modification-history.xsd | 39 + epiuclid/schemas/v10/xlink.xsd | 231 + epiuclid/schemas/v10/xml.xsd | 145 + epiuclid/serializers/__init__.py | 0 epiuclid/serializers/i6z.py | 118 + epiuclid/serializers/manifest.py | 120 + epiuclid/serializers/pathway_mapper.py | 493 + epiuclid/tests/__init__.py | 0 epiuclid/tests/factories.py | 102 + epiuclid/tests/test_api.py | 92 + epiuclid/tests/test_builders.py | 521 + epiuclid/tests/test_i6z.py | 199 + epiuclid/tests/test_iuclid_export.py | 86 + epiuclid/tests/test_pathway_mapper.py | 512 + epiuclid/tests/test_xsd_validation.py | 148 + epiuclid/tests/xml_assertions.py | 22 + pyproject.toml | 4 + templates/actions/objects/pathway.html | 8 + tests/views/test_pathway_views.py | 40 +- tests/views/test_user_views.py | 28 +- uv.lock | 2188 +- 49 files changed, 66402 insertions(+), 1014 deletions(-) create mode 100644 epapi/v1/interfaces/__init__.py create mode 100644 epapi/v1/interfaces/iuclid/__init__.py create mode 100644 epapi/v1/interfaces/iuclid/dto.py create mode 100644 epapi/v1/interfaces/iuclid/projections.py create mode 100644 epiuclid/__init__.py create mode 100644 epiuclid/api.py create mode 100644 epiuclid/apps.py create mode 100644 epiuclid/builders/__init__.py create mode 100644 epiuclid/builders/base.py create mode 100644 epiuclid/builders/endpoint_study.py create mode 100644 epiuclid/builders/reference_substance.py create mode 100644 epiuclid/builders/substance.py create mode 100644 epiuclid/schemas/loader.py create mode 100644 epiuclid/schemas/v10/domain/v10/REFERENCE_SUBSTANCE-10.0.xsd create mode 100644 epiuclid/schemas/v10/domain/v10/SUBSTANCE-10.0.xsd create mode 100644 epiuclid/schemas/v10/domain/v10/commonTypesDomainV10.xsd create mode 100644 epiuclid/schemas/v10/oecd/v10/ENDPOINT_STUDY_RECORD-BiodegradationInSoil-10.0.xsd create mode 100644 epiuclid/schemas/v10/oecd/v10/commonTypesOecdV10.xsd create mode 100644 epiuclid/schemas/v10/platform-attachment.xsd create mode 100644 epiuclid/schemas/v10/platform-container-v2.xsd create mode 100644 epiuclid/schemas/v10/platform-fields.xsd create mode 100644 epiuclid/schemas/v10/platform-metadata.xsd create mode 100644 epiuclid/schemas/v10/platform-modification-history.xsd create mode 100644 epiuclid/schemas/v10/xlink.xsd create mode 100644 epiuclid/schemas/v10/xml.xsd create mode 100644 epiuclid/serializers/__init__.py create mode 100644 epiuclid/serializers/i6z.py create mode 100644 epiuclid/serializers/manifest.py create mode 100644 epiuclid/serializers/pathway_mapper.py create mode 100644 epiuclid/tests/__init__.py create mode 100644 epiuclid/tests/factories.py create mode 100644 epiuclid/tests/test_api.py create mode 100644 epiuclid/tests/test_builders.py create mode 100644 epiuclid/tests/test_i6z.py create mode 100644 epiuclid/tests/test_iuclid_export.py create mode 100644 epiuclid/tests/test_pathway_mapper.py create mode 100644 epiuclid/tests/test_xsd_validation.py create mode 100644 epiuclid/tests/xml_assertions.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dd88d794..325feff6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,10 +5,12 @@ repos: rev: v3.2.0 hooks: - id: trailing-whitespace + exclude: epiuclid/schemas/ - id: end-of-file-fixer + exclude: epiuclid/schemas/ - id: check-yaml - id: check-added-large-files - exclude: ^static/images/|fixtures/ + exclude: ^static/images/|^epiuclid/schemas/|^fixtures/ - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.13.3 diff --git a/envipath/settings.py b/envipath/settings.py index 73c8b90f..427a26d9 100644 --- a/envipath/settings.py +++ b/envipath/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django.contrib.postgres", # 3rd party "django_extensions", "oauth2_provider", @@ -362,6 +363,10 @@ if SENTRY_ENABLED: before_send=before_send, ) +IUCLID_EXPORT_ENABLED = os.environ.get("IUCLID_EXPORT_ENABLED", "False") == "True" +if IUCLID_EXPORT_ENABLED: + INSTALLED_APPS.append("epiuclid") + # compile into digestible flags FLAGS = { "MODEL_BUILDING": MODEL_BUILDING_ENABLED, @@ -370,6 +375,7 @@ FLAGS = { "SENTRY": SENTRY_ENABLED, "ENVIFORMER": ENVIFORMER_PRESENT, "APPLICABILITY_DOMAIN": APPLICABILITY_DOMAIN_ENABLED, + "IUCLID_EXPORT": IUCLID_EXPORT_ENABLED, } # path of the URL are checked via "startswith" diff --git a/epapi/tests/v1/test_schema_generation.py b/epapi/tests/v1/test_schema_generation.py index 4350ff7b..2dfc4e25 100644 --- a/epapi/tests/v1/test_schema_generation.py +++ b/epapi/tests/v1/test_schema_generation.py @@ -74,7 +74,6 @@ class TestSchemaGeneration: assert all(isinstance(g, str) for g in groups), ( f"{model_name}: all groups should be strings, got {groups}" ) - assert len(groups) > 0, f"{model_name}: should have at least one group" @pytest.mark.parametrize("model_name,model_cls", list(registry.list_models().items())) def test_form_data_matches_schema(self, model_name: str, model_cls: Type[BaseModel]): diff --git a/epapi/v1/dal.py b/epapi/v1/dal.py index 98ee342a..10085e96 100644 --- a/epapi/v1/dal.py +++ b/epapi/v1/dal.py @@ -1,10 +1,14 @@ -from django.db.models import Model -from epdb.logic import PackageManager -from epdb.models import CompoundStructure, User, Package, Compound, Scenario from uuid import UUID +from django.conf import settings as s +from django.db.models import Model +from epdb.logic import PackageManager +from epdb.models import CompoundStructure, User, Compound, Scenario + from .errors import EPAPINotFoundError, EPAPIPermissionDeniedError +Package = s.GET_PACKAGE_MODEL() + def get_compound_for_read(user, compound_uuid: UUID): """ diff --git a/epapi/v1/interfaces/__init__.py b/epapi/v1/interfaces/__init__.py new file mode 100644 index 00000000..fbcd5c7e --- /dev/null +++ b/epapi/v1/interfaces/__init__.py @@ -0,0 +1,3 @@ +""" +Service interfaces: each subdirectory defines the full boundary contract between enviPy and feature-flagged apps. DTOs and projections are shared concerns to avoid direct ORM access. +""" diff --git a/epapi/v1/interfaces/iuclid/__init__.py b/epapi/v1/interfaces/iuclid/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/epapi/v1/interfaces/iuclid/dto.py b/epapi/v1/interfaces/iuclid/dto.py new file mode 100644 index 00000000..a1231dac --- /dev/null +++ b/epapi/v1/interfaces/iuclid/dto.py @@ -0,0 +1,58 @@ +from dataclasses import dataclass, field +from uuid import UUID + + +@dataclass(frozen=True) +class PathwayCompoundDTO: + pk: int + name: str + smiles: str | None = None + cas_number: str | None = None + ec_number: str | None = None + + +@dataclass(frozen=True) +class PathwayScenarioDTO: + scenario_uuid: UUID + name: str + additional_info: list = field(default_factory=list) # EnviPyModel instances + + +@dataclass(frozen=True) +class PathwayNodeDTO: + node_uuid: UUID + compound_pk: int + name: str + depth: int + smiles: str | None = None + cas_number: str | None = None + ec_number: str | None = None + additional_info: list = field(default_factory=list) # EnviPyModel instances + scenarios: list[PathwayScenarioDTO] = field(default_factory=list) + + +@dataclass(frozen=True) +class PathwayEdgeDTO: + edge_uuid: UUID + start_compound_pks: list[int] = field(default_factory=list) + end_compound_pks: list[int] = field(default_factory=list) + probability: float | None = None + + +@dataclass(frozen=True) +class PathwayModelInfoDTO: + model_name: str | None = None + model_uuid: UUID | None = None + software_name: str | None = None + software_version: str | None = None + + +@dataclass(frozen=True) +class PathwayExportDTO: + pathway_uuid: UUID + pathway_name: str + compounds: list[PathwayCompoundDTO] = field(default_factory=list) + nodes: list[PathwayNodeDTO] = field(default_factory=list) + edges: list[PathwayEdgeDTO] = field(default_factory=list) + root_compound_pks: list[int] = field(default_factory=list) + model_info: PathwayModelInfoDTO | None = None diff --git a/epapi/v1/interfaces/iuclid/projections.py b/epapi/v1/interfaces/iuclid/projections.py new file mode 100644 index 00000000..1f663987 --- /dev/null +++ b/epapi/v1/interfaces/iuclid/projections.py @@ -0,0 +1,142 @@ +from uuid import UUID + +from epdb.logic import PackageManager +from epdb.models import Pathway + +from epapi.v1.errors import EPAPINotFoundError, EPAPIPermissionDeniedError + +from .dto import ( + PathwayCompoundDTO, + PathwayEdgeDTO, + PathwayExportDTO, + PathwayModelInfoDTO, + PathwayNodeDTO, + PathwayScenarioDTO, +) + + +def get_pathway_for_iuclid_export(user, pathway_uuid: UUID) -> PathwayExportDTO: + """Return pathway data projected into DTOs for the IUCLID export consumer.""" + try: + pathway = ( + Pathway.objects.select_related("package", "setting", "setting__model") + .prefetch_related( + "node_set__default_node_label__compound__external_identifiers__database", + "node_set__scenarios", + "edge_set__start_nodes__default_node_label__compound", + "edge_set__end_nodes__default_node_label__compound", + ) + .get(uuid=pathway_uuid) + ) + except Pathway.DoesNotExist: + raise EPAPINotFoundError(f"Pathway with UUID {pathway_uuid} not found") + + if not user or user.is_anonymous or not PackageManager.readable(user, pathway.package): + raise EPAPIPermissionDeniedError("Insufficient permissions to access this pathway.") + + nodes: list[PathwayNodeDTO] = [] + edges: list[PathwayEdgeDTO] = [] + compounds_by_pk: dict[int, PathwayCompoundDTO] = {} + root_compound_pks: list[int] = [] + + for node in pathway.node_set.all().order_by("depth", "pk"): + cs = node.default_node_label + if cs is None: + continue + compound = cs.compound + + cas_number = None + ec_number = None + for ext_id in compound.external_identifiers.all(): + db_name = ext_id.database.name if ext_id.database else None + if db_name == "CAS" and cas_number is None: + cas_number = ext_id.identifier_value + elif db_name == "EC" and ec_number is None: + ec_number = ext_id.identifier_value + + ai_for_node = [] + scenario_entries: list[PathwayScenarioDTO] = [] + for scenario in sorted(node.scenarios.all(), key=lambda item: item.pk): + ai_for_scenario = list(scenario.get_additional_information(direct_only=True)) + ai_for_node.extend(ai_for_scenario) + scenario_entries.append( + PathwayScenarioDTO( + scenario_uuid=scenario.uuid, + name=scenario.name, + additional_info=ai_for_scenario, + ) + ) + + nodes.append( + PathwayNodeDTO( + node_uuid=node.uuid, + compound_pk=compound.pk, + name=compound.name, + depth=node.depth, + smiles=cs.smiles, + cas_number=cas_number, + ec_number=ec_number, + additional_info=ai_for_node, + scenarios=scenario_entries, + ) + ) + + if node.depth == 0 and compound.pk not in root_compound_pks: + root_compound_pks.append(compound.pk) + + if compound.pk not in compounds_by_pk: + compounds_by_pk[compound.pk] = PathwayCompoundDTO( + pk=compound.pk, + name=compound.name, + smiles=cs.smiles, + cas_number=cas_number, + ec_number=ec_number, + ) + + for edge in pathway.edge_set.all(): + start_compounds = { + n.default_node_label.compound.pk + for n in edge.start_nodes.all() + if n.default_node_label is not None + } + end_compounds = { + n.default_node_label.compound.pk + for n in edge.end_nodes.all() + if n.default_node_label is not None + } + + probability = None + if edge.kv and edge.kv.get("probability") is not None: + try: + probability = float(edge.kv.get("probability")) + except (TypeError, ValueError): + probability = None + + edges.append( + PathwayEdgeDTO( + edge_uuid=edge.uuid, + start_compound_pks=sorted(start_compounds), + end_compound_pks=sorted(end_compounds), + probability=probability, + ) + ) + + model_info = None + if pathway.setting and pathway.setting.model: + model = pathway.setting.model + model_info = PathwayModelInfoDTO( + model_name=model.get_name(), + model_uuid=model.uuid, + software_name="enviPath", + software_version=None, + ) + + return PathwayExportDTO( + pathway_uuid=pathway.uuid, + pathway_name=pathway.get_name(), + compounds=list(compounds_by_pk.values()), + nodes=nodes, + edges=edges, + root_compound_pks=root_compound_pks, + model_info=model_info, + ) diff --git a/epapi/v1/router.py b/epapi/v1/router.py index d9529756..32cdd5c4 100644 --- a/epapi/v1/router.py +++ b/epapi/v1/router.py @@ -14,6 +14,7 @@ from .endpoints import ( additional_information, settings, ) +from envipath import settings as s # Main router with authentication router = Router( @@ -34,3 +35,8 @@ router.add_router("", models.router) router.add_router("", structure.router) router.add_router("", additional_information.router) router.add_router("", settings.router) + +if s.IUCLID_EXPORT_ENABLED: + from epiuclid.api import router as iuclid_router + + router.add_router("", iuclid_router) diff --git a/epdb/models.py b/epdb/models.py index 5e011ae6..779d8f99 100644 --- a/epdb/models.py +++ b/epdb/models.py @@ -4251,7 +4251,7 @@ class AdditionalInformation(models.Model): # Generic FK must be complete or empty models.CheckConstraint( name="ck_addinfo_gfk_pair", - check=( + condition=( (Q(content_type__isnull=True) & Q(object_id__isnull=True)) | (Q(content_type__isnull=False) & Q(object_id__isnull=False)) ), @@ -4259,7 +4259,7 @@ class AdditionalInformation(models.Model): # Disallow "floating" info models.CheckConstraint( name="ck_addinfo_not_both_null", - check=Q(scenario__isnull=False) | Q(content_type__isnull=False), + condition=Q(scenario__isnull=False) | Q(content_type__isnull=False), ), ] diff --git a/epiuclid/__init__.py b/epiuclid/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/epiuclid/api.py b/epiuclid/api.py new file mode 100644 index 00000000..5fc39072 --- /dev/null +++ b/epiuclid/api.py @@ -0,0 +1,22 @@ +from uuid import UUID + +from django.http import HttpResponse +from ninja import Router +from epapi.v1.interfaces.iuclid.projections import get_pathway_for_iuclid_export + +from .serializers.i6z import I6ZSerializer +from .serializers.pathway_mapper import PathwayMapper + +router = Router(tags=["iuclid"]) + + +@router.get("/pathway/{uuid:pathway_uuid}/export/iuclid") +def export_pathway_iuclid(request, pathway_uuid: UUID): + export = get_pathway_for_iuclid_export(request.user, pathway_uuid) + bundle = PathwayMapper().map(export) + i6z_bytes = I6ZSerializer().serialize(bundle) + return HttpResponse( + i6z_bytes, + content_type="application/zip", + headers={"Content-Disposition": f'attachment; filename="pathway-{pathway_uuid}.i6z"'}, + ) diff --git a/epiuclid/apps.py b/epiuclid/apps.py new file mode 100644 index 00000000..1fa7867f --- /dev/null +++ b/epiuclid/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class EpiuclidConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "epiuclid" diff --git a/epiuclid/builders/__init__.py b/epiuclid/builders/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/epiuclid/builders/base.py b/epiuclid/builders/base.py new file mode 100644 index 00000000..3be592c8 --- /dev/null +++ b/epiuclid/builders/base.py @@ -0,0 +1,105 @@ +import xml.etree.ElementTree as ET +from datetime import datetime, timezone + +# IUCLID 6 XML namespaces +NS_PLATFORM_CONTAINER = "http://iuclid6.echa.europa.eu/namespaces/platform-container/v2" +NS_PLATFORM_METADATA = "http://iuclid6.echa.europa.eu/namespaces/platform-metadata/v1" +NS_PLATFORM_FIELDS = "http://iuclid6.echa.europa.eu/namespaces/platform-fields/v1" +NS_XLINK = "http://www.w3.org/1999/xlink" + +# Register namespace prefixes for clean output +ET.register_namespace("i6c", NS_PLATFORM_CONTAINER) +ET.register_namespace("i6m", NS_PLATFORM_METADATA) +ET.register_namespace("i6", NS_PLATFORM_FIELDS) +ET.register_namespace("xlink", NS_XLINK) + +IUCLID_VERSION = "6.0.0" +DEFINITION_VERSION = "10.0" +CREATION_TOOL = "enviPath" + + +def _tag(ns: str, local: str) -> str: + return f"{{{ns}}}{local}" + + +def _sub(parent: ET.Element, ns: str, local: str, text: str | None = None) -> ET.Element: + """Create a sub-element under parent. Only sets text if not None.""" + elem = ET.SubElement(parent, _tag(ns, local)) + if text is not None: + elem.text = str(text) + return elem + + +def _sub_if(parent: ET.Element, ns: str, local: str, text: str | None = None) -> ET.Element | None: + """Create a sub-element only when text is not None.""" + if text is None: + return None + return _sub(parent, ns, local, text) + + +def build_platform_metadata( + document_key: str, + document_type: str, + name: str, + document_sub_type: str | None = None, + parent_document_key: str | None = None, + order_in_section_no: int | None = None, +) -> ET.Element: + """Build the element for an i6d document.""" + pm = ET.Element(_tag(NS_PLATFORM_CONTAINER, "PlatformMetadata")) + + now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + + _sub(pm, NS_PLATFORM_METADATA, "iuclidVersion", IUCLID_VERSION) + _sub(pm, NS_PLATFORM_METADATA, "documentKey", document_key) + _sub(pm, NS_PLATFORM_METADATA, "documentType", document_type) + _sub(pm, NS_PLATFORM_METADATA, "definitionVersion", DEFINITION_VERSION) + _sub(pm, NS_PLATFORM_METADATA, "creationDate", now) + _sub(pm, NS_PLATFORM_METADATA, "lastModificationDate", now) + _sub(pm, NS_PLATFORM_METADATA, "name", name) + if document_sub_type: + _sub(pm, NS_PLATFORM_METADATA, "documentSubType", document_sub_type) + if parent_document_key: + _sub(pm, NS_PLATFORM_METADATA, "parentDocumentKey", parent_document_key) + if order_in_section_no is not None: + _sub(pm, NS_PLATFORM_METADATA, "orderInSectionNo", str(order_in_section_no)) + _sub(pm, NS_PLATFORM_METADATA, "i5Origin", "false") + _sub(pm, NS_PLATFORM_METADATA, "creationTool", CREATION_TOOL) + + return pm + + +def build_document( + document_key: str, + document_type: str, + name: str, + content_element: ET.Element, + document_sub_type: str | None = None, + parent_document_key: str | None = None, + order_in_section_no: int | None = None, +) -> str: + """Build a complete i6d document XML string.""" + root = ET.Element(_tag(NS_PLATFORM_CONTAINER, "Document")) + + pm = build_platform_metadata( + document_key=document_key, + document_type=document_type, + name=name, + document_sub_type=document_sub_type, + parent_document_key=parent_document_key, + order_in_section_no=order_in_section_no, + ) + root.append(pm) + + content_wrapper = _sub(root, NS_PLATFORM_CONTAINER, "Content") + content_wrapper.append(content_element) + + _sub(root, NS_PLATFORM_CONTAINER, "Attachments") + _sub(root, NS_PLATFORM_CONTAINER, "ModificationHistory") + + return ET.tostring(root, encoding="unicode", xml_declaration=True) + + +def document_key(uuid) -> str: + """Format a UUID as an IUCLID document key (uuid/0 for raw data).""" + return f"{uuid}/0" diff --git a/epiuclid/builders/endpoint_study.py b/epiuclid/builders/endpoint_study.py new file mode 100644 index 00000000..a58bee35 --- /dev/null +++ b/epiuclid/builders/endpoint_study.py @@ -0,0 +1,259 @@ +import xml.etree.ElementTree as ET +from uuid import uuid4 + +from epiuclid.serializers.pathway_mapper import IUCLIDEndpointStudyRecordData, SoilPropertiesData + +from .base import ( + NS_PLATFORM_FIELDS, + _sub, + _tag, + build_document, + document_key, +) + +NS_ESR_BIODEG = ( + "http://iuclid6.echa.europa.eu/namespaces/ENDPOINT_STUDY_RECORD-BiodegradationInSoil/10.0" +) +ET.register_namespace("", NS_ESR_BIODEG) + +DOC_SUBTYPE = "BiodegradationInSoil" +PICKLIST_OTHER_CODE = "1342" +SOIL_TYPE_CODE_BY_KEY = { + "CLAY": "257", + "CLAY_LOAM": "258", + "LOAM": "1026", + "LOAMY_SAND": "1027", + "SAND": "1522", + "SANDY_CLAY_LOAM": "1523", + "SANDY_LOAM": "1524", + "SANDY_CLAY": "1525", + "SILT": "1549", + "SILT_LOAM": "1550", + "SILTY_CLAY": "1551", + "SILTY_CLAY_LOAM": "1552", +} +SOIL_CLASSIFICATION_CODE_BY_KEY = { + "USDA": "1649", + "DE": "314", + "INTERNATIONAL": "1658", +} + + +class EndpointStudyRecordBuilder: + def build(self, data: IUCLIDEndpointStudyRecordData) -> str: + esr = ET.Element(f"{{{NS_ESR_BIODEG}}}ENDPOINT_STUDY_RECORD.{DOC_SUBTYPE}") + + soil_entries = list(data.soil_properties_entries) + if not soil_entries and data.soil_properties is not None: + soil_entries = [data.soil_properties] + + has_materials = bool( + data.model_name_and_version + or data.software_name_and_version + or data.model_remarks + or soil_entries + ) + if has_materials: + materials = _sub(esr, NS_ESR_BIODEG, "MaterialsAndMethods") + + if soil_entries: + self._build_soil_structured_full(materials, soil_entries) + + if data.model_name_and_version or data.software_name_and_version or data.model_remarks: + model_info = _sub(materials, NS_ESR_BIODEG, "ModelAndSoftware") + + for model_name in data.model_name_and_version: + _sub(model_info, NS_ESR_BIODEG, "ModelNameAndVersion", model_name) + + for software_name in data.software_name_and_version: + _sub(model_info, NS_ESR_BIODEG, "SoftwareNameAndVersion", software_name) + + for remark in data.model_remarks: + _sub(model_info, NS_ESR_BIODEG, "Remarks", remark) + + has_results = ( + data.half_lives or data.transformation_products or data.temperature is not None + ) + if has_results: + results = _sub(esr, NS_ESR_BIODEG, "ResultsAndDiscussion") + + if data.half_lives or data.temperature is not None: + dt_parent = _sub(results, NS_ESR_BIODEG, "DTParentCompound") + + if data.half_lives: + for hl in data.half_lives: + entry = ET.SubElement(dt_parent, _tag(NS_ESR_BIODEG, "entry")) + entry.set(_tag(NS_PLATFORM_FIELDS, "uuid"), str(uuid4())) + + if hl.soil_no_code: + soil_no = _sub(entry, NS_ESR_BIODEG, "SoilNo") + _sub(soil_no, NS_ESR_BIODEG, "value", hl.soil_no_code) + + value_range = _sub(entry, NS_ESR_BIODEG, "Value") + _sub(value_range, NS_ESR_BIODEG, "unitCode", "2329") # days + _sub(value_range, NS_ESR_BIODEG, "lowerValue", str(hl.dt50_start)) + _sub(value_range, NS_ESR_BIODEG, "upperValue", str(hl.dt50_end)) + + temperature = ( + hl.temperature if hl.temperature is not None else data.temperature + ) + if temperature is not None: + temp_range = _sub(entry, NS_ESR_BIODEG, "Temp") + _sub(temp_range, NS_ESR_BIODEG, "unitCode", "2493") # degree Celsius + _sub(temp_range, NS_ESR_BIODEG, "lowerValue", str(temperature[0])) + _sub(temp_range, NS_ESR_BIODEG, "upperValue", str(temperature[1])) + + _sub(entry, NS_ESR_BIODEG, "KineticParameters", hl.model) + else: + # Temperature without half-lives: single entry with only Temp + assert data.temperature is not None + entry = ET.SubElement(dt_parent, _tag(NS_ESR_BIODEG, "entry")) + entry.set(_tag(NS_PLATFORM_FIELDS, "uuid"), str(uuid4())) + temp_range = _sub(entry, NS_ESR_BIODEG, "Temp") + _sub(temp_range, NS_ESR_BIODEG, "unitCode", "2493") # degree Celsius + _sub(temp_range, NS_ESR_BIODEG, "lowerValue", str(data.temperature[0])) + _sub(temp_range, NS_ESR_BIODEG, "upperValue", str(data.temperature[1])) + + if data.transformation_products: + tp_details = _sub(results, NS_ESR_BIODEG, "TransformationProductsDetails") + for tp in data.transformation_products: + entry = ET.SubElement(tp_details, _tag(NS_ESR_BIODEG, "entry")) + entry.set(_tag(NS_PLATFORM_FIELDS, "uuid"), str(tp.uuid)) + + _sub( + entry, + NS_ESR_BIODEG, + "IdentityOfCompound", + document_key(tp.product_reference_uuid), + ) + + if tp.parent_reference_uuids: + parents = _sub(entry, NS_ESR_BIODEG, "ParentCompoundS") + for parent_uuid in tp.parent_reference_uuids: + _sub(parents, NS_PLATFORM_FIELDS, "key", document_key(parent_uuid)) + + if tp.kinetic_formation_fraction is not None: + _sub( + entry, + NS_ESR_BIODEG, + "KineticFormationFraction", + str(tp.kinetic_formation_fraction), + ) + + doc_key = document_key(data.uuid) + return build_document( + document_key=doc_key, + document_type="ENDPOINT_STUDY_RECORD", + document_sub_type=DOC_SUBTYPE, + name=data.name, + content_element=esr, + parent_document_key=document_key(data.substance_uuid), + order_in_section_no=1, + ) + + @staticmethod + def _build_soil_structured_full( + materials: ET.Element, + props_entries: list[SoilPropertiesData], + ) -> None: + study_design = _sub(materials, NS_ESR_BIODEG, "StudyDesign") + + soil_classification = None + for props in props_entries: + soil_classification = EndpointStudyRecordBuilder._soil_classification(props) + if soil_classification: + break + + if soil_classification: + soil_classification_el = _sub(study_design, NS_ESR_BIODEG, "SoilClassification") + value, other = EndpointStudyRecordBuilder._picklist_value_and_other( + soil_classification, + SOIL_CLASSIFICATION_CODE_BY_KEY, + ) + if value: + _sub(soil_classification_el, NS_ESR_BIODEG, "value", value) + if other: + _sub(soil_classification_el, NS_ESR_BIODEG, "other", other) + + soil_props = _sub(study_design, NS_ESR_BIODEG, "SoilProperties") + + for props in props_entries: + entry = ET.SubElement(soil_props, _tag(NS_ESR_BIODEG, "entry")) + entry.set(_tag(NS_PLATFORM_FIELDS, "uuid"), str(uuid4())) + + if props.soil_no_code: + soil_no = _sub(entry, NS_ESR_BIODEG, "SoilNo") + _sub(soil_no, NS_ESR_BIODEG, "value", props.soil_no_code) + + soil_type = props.soil_type.strip() if props.soil_type else None + if soil_type: + soil_type_el = _sub(entry, NS_ESR_BIODEG, "SoilType") + value, other = EndpointStudyRecordBuilder._picklist_value_and_other( + soil_type, + SOIL_TYPE_CODE_BY_KEY, + ) + if value: + _sub(soil_type_el, NS_ESR_BIODEG, "value", value) + if other: + _sub(soil_type_el, NS_ESR_BIODEG, "other", other) + + if props.clay is not None: + clay_el = _sub(entry, NS_ESR_BIODEG, "Clay") + _sub(clay_el, NS_ESR_BIODEG, "lowerValue", str(props.clay)) + + if props.silt is not None: + silt_el = _sub(entry, NS_ESR_BIODEG, "Silt") + _sub(silt_el, NS_ESR_BIODEG, "lowerValue", str(props.silt)) + + if props.sand is not None: + sand_el = _sub(entry, NS_ESR_BIODEG, "Sand") + _sub(sand_el, NS_ESR_BIODEG, "lowerValue", str(props.sand)) + + if props.org_carbon is not None: + orgc_el = _sub(entry, NS_ESR_BIODEG, "OrgC") + _sub(orgc_el, NS_ESR_BIODEG, "lowerValue", str(props.org_carbon)) + + if props.ph_lower is not None or props.ph_upper is not None: + ph_el = _sub(entry, NS_ESR_BIODEG, "Ph") + if props.ph_lower is not None: + _sub(ph_el, NS_ESR_BIODEG, "lowerValue", str(props.ph_lower)) + if props.ph_upper is not None: + _sub(ph_el, NS_ESR_BIODEG, "upperValue", str(props.ph_upper)) + + ph_method = props.ph_method.strip() if props.ph_method else None + if ph_method: + _sub(entry, NS_ESR_BIODEG, "PHMeasuredIn", ph_method) + + if props.cec is not None: + cec_el = _sub(entry, NS_ESR_BIODEG, "CEC") + _sub(cec_el, NS_ESR_BIODEG, "lowerValue", str(props.cec)) + + if props.moisture_content is not None: + moisture_el = _sub(entry, NS_ESR_BIODEG, "MoistureContent") + _sub(moisture_el, NS_ESR_BIODEG, "lowerValue", str(props.moisture_content)) + + @staticmethod + def _soil_classification(props: SoilPropertiesData) -> str | None: + if props.soil_classification: + value = props.soil_classification.strip() + if value: + return value + if props.soil_type: + return "USDA" + return None + + @staticmethod + def _picklist_value_and_other( + raw_value: str, + code_map: dict[str, str], + ) -> tuple[str | None, str | None]: + value = raw_value.strip() + if not value: + return None, None + + key = value.upper().replace("-", "_").replace(" ", "_") + code = code_map.get(key) + if code is not None: + return code, None + + return PICKLIST_OTHER_CODE, value.replace("_", " ") diff --git a/epiuclid/builders/reference_substance.py b/epiuclid/builders/reference_substance.py new file mode 100644 index 00000000..716b9d85 --- /dev/null +++ b/epiuclid/builders/reference_substance.py @@ -0,0 +1,54 @@ +import xml.etree.ElementTree as ET + +from epiuclid.serializers.pathway_mapper import IUCLIDReferenceSubstanceData + +from .base import ( + _sub, + _sub_if, + build_document, + document_key, +) + +NS_REFERENCE_SUBSTANCE = "http://iuclid6.echa.europa.eu/namespaces/REFERENCE_SUBSTANCE/10.0" +ET.register_namespace("", NS_REFERENCE_SUBSTANCE) + + +class ReferenceSubstanceBuilder: + def build(self, data: IUCLIDReferenceSubstanceData) -> str: + ref = ET.Element(f"{{{NS_REFERENCE_SUBSTANCE}}}REFERENCE_SUBSTANCE") + + _sub(ref, NS_REFERENCE_SUBSTANCE, "ReferenceSubstanceName", data.name) + _sub_if(ref, NS_REFERENCE_SUBSTANCE, "IupacName", data.iupac_name) + if data.cas_number: + inventory = _sub(ref, NS_REFERENCE_SUBSTANCE, "Inventory") + _sub(inventory, NS_REFERENCE_SUBSTANCE, "CASNumber", data.cas_number) + + has_structural_info = any( + [ + data.molecular_formula, + data.molecular_weight is not None, + data.smiles, + data.inchi, + data.inchi_key, + ] + ) + if has_structural_info: + structural = _sub(ref, NS_REFERENCE_SUBSTANCE, "MolecularStructuralInfo") + _sub_if(structural, NS_REFERENCE_SUBSTANCE, "MolecularFormula", data.molecular_formula) + + if data.molecular_weight is not None: + mw = _sub(structural, NS_REFERENCE_SUBSTANCE, "MolecularWeightRange") + _sub(mw, NS_REFERENCE_SUBSTANCE, "lowerValue", f"{data.molecular_weight:.2f}") + _sub(mw, NS_REFERENCE_SUBSTANCE, "upperValue", f"{data.molecular_weight:.2f}") + + _sub_if(structural, NS_REFERENCE_SUBSTANCE, "SmilesNotation", data.smiles) + _sub_if(structural, NS_REFERENCE_SUBSTANCE, "InChl", data.inchi) + _sub_if(structural, NS_REFERENCE_SUBSTANCE, "InChIKey", data.inchi_key) + + doc_key = document_key(data.uuid) + return build_document( + document_key=doc_key, + document_type="REFERENCE_SUBSTANCE", + name=data.name, + content_element=ref, + ) diff --git a/epiuclid/builders/substance.py b/epiuclid/builders/substance.py new file mode 100644 index 00000000..162f01f8 --- /dev/null +++ b/epiuclid/builders/substance.py @@ -0,0 +1,37 @@ +import xml.etree.ElementTree as ET + +from epiuclid.serializers.pathway_mapper import IUCLIDSubstanceData + +from .base import ( + _sub, + build_document, + document_key, +) + +NS_SUBSTANCE = "http://iuclid6.echa.europa.eu/namespaces/SUBSTANCE/10.0" +ET.register_namespace("", NS_SUBSTANCE) + + +class SubstanceBuilder: + def build(self, data: IUCLIDSubstanceData) -> str: + substance = ET.Element(f"{{{NS_SUBSTANCE}}}SUBSTANCE") + + _sub(substance, NS_SUBSTANCE, "Templates") + _sub(substance, NS_SUBSTANCE, "ChemicalName", data.name) + + if data.reference_substance_uuid: + ref_sub = _sub(substance, NS_SUBSTANCE, "ReferenceSubstance") + _sub( + ref_sub, + NS_SUBSTANCE, + "ReferenceSubstance", + document_key(data.reference_substance_uuid), + ) + + doc_key = document_key(data.uuid) + return build_document( + document_key=doc_key, + document_type="SUBSTANCE", + name=data.name, + content_element=substance, + ) diff --git a/epiuclid/schemas/loader.py b/epiuclid/schemas/loader.py new file mode 100644 index 00000000..5475112b --- /dev/null +++ b/epiuclid/schemas/loader.py @@ -0,0 +1,90 @@ +"""Load and cache IUCLID XSD schemas with cross-reference resolution. + +The bundled XSD schemas use bare ``schemaLocation`` filenames (e.g. +``platform-fields.xsd``, ``commonTypesDomainV10.xsd``) that don't match the +actual directory layout. This module builds an explicit namespace → file-path +mapping so that ``xmlschema`` can resolve every import. +""" + +from __future__ import annotations + +from functools import lru_cache +from pathlib import Path + +import xmlschema + +_SCHEMA_ROOT = Path(__file__).resolve().parent / "v10" + +# Namespace → relative file-path (from _SCHEMA_ROOT) for schemas that are +# referenced by bare filename from subdirectories that don't contain them. +_NS_LOCATIONS: dict[str, str] = { + "http://iuclid6.echa.europa.eu/namespaces/platform-fields/v1": "platform-fields.xsd", + "http://iuclid6.echa.europa.eu/namespaces/platform-metadata/v1": "platform-metadata.xsd", + "http://iuclid6.echa.europa.eu/namespaces/platform-container/v2": "platform-container-v2.xsd", + "http://iuclid6.echa.europa.eu/namespaces/platform-attachment/v1": "platform-attachment.xsd", + "http://iuclid6.echa.europa.eu/namespaces/platform-modification-history/v1": ( + "platform-modification-history.xsd" + ), + "http://www.w3.org/1999/xlink": "xlink.xsd", + "http://www.w3.org/XML/1998/namespace": "xml.xsd", + "http://iuclid6.echa.europa.eu/namespaces/domain/v10": ("domain/v10/commonTypesDomainV10.xsd"), + "http://iuclid6.echa.europa.eu/namespaces/oecd/v10": ("oecd/v10/commonTypesOecdV10.xsd"), +} + +# doc_type → (subdir, filename-pattern) +_DOC_TYPE_PATHS: dict[str, tuple[str, str]] = { + "SUBSTANCE": ("domain/v10", "SUBSTANCE-10.0.xsd"), + "REFERENCE_SUBSTANCE": ("domain/v10", "REFERENCE_SUBSTANCE-10.0.xsd"), +} + + +def _absolute_locations() -> list[tuple[str, str]]: + """Return (namespace, absolute-file-URI) pairs for all known schemas.""" + return [(ns, (_SCHEMA_ROOT / rel).as_uri()) for ns, rel in _NS_LOCATIONS.items()] + + +def _esr_path(subtype: str) -> Path: + """Return the path to an Endpoint Study Record schema.""" + return _SCHEMA_ROOT / "oecd" / "v10" / f"ENDPOINT_STUDY_RECORD-{subtype}-10.0.xsd" + + +def _doc_type_path(doc_type: str, subtype: str | None = None) -> Path: + if doc_type == "ENDPOINT_STUDY_RECORD": + if not subtype: + raise ValueError("subtype is required for ENDPOINT_STUDY_RECORD schemas") + return _esr_path(subtype) + info = _DOC_TYPE_PATHS.get(doc_type) + if info is None: + raise ValueError(f"Unknown document type: {doc_type}") + subdir, filename = info + return _SCHEMA_ROOT / subdir / filename + + +@lru_cache(maxsize=32) +def get_content_schema(doc_type: str, subtype: str | None = None) -> xmlschema.XMLSchema: + """Return a compiled XSD schema for validating content elements. + + Parameters + ---------- + doc_type: + IUCLID document type (``SUBSTANCE``, ``REFERENCE_SUBSTANCE``, + ``ENDPOINT_STUDY_RECORD``). + subtype: + Required for ``ENDPOINT_STUDY_RECORD`` (e.g. ``BiodegradationInSoil``). + """ + path = _doc_type_path(doc_type, subtype) + return xmlschema.XMLSchema(str(path), locations=_absolute_locations()) + + +@lru_cache(maxsize=1) +def get_document_schema() -> xmlschema.XMLSchema: + """Return a compiled XSD schema for the ``platform-container-v2`` wrapper. + + This validates the full ```` element (PlatformMetadata + Content + + Attachments + ModificationHistory). Content is validated with + ``processContents="strict"`` via ``xs:any``, but only if the content + namespace has been loaded. For full content validation, use + :func:`get_content_schema` separately. + """ + path = _SCHEMA_ROOT / "platform-container-v2.xsd" + return xmlschema.XMLSchema(str(path), locations=_absolute_locations()) diff --git a/epiuclid/schemas/v10/domain/v10/REFERENCE_SUBSTANCE-10.0.xsd b/epiuclid/schemas/v10/domain/v10/REFERENCE_SUBSTANCE-10.0.xsd new file mode 100644 index 00000000..f19627c3 --- /dev/null +++ b/epiuclid/schemas/v10/domain/v10/REFERENCE_SUBSTANCE-10.0.xsd @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epiuclid/schemas/v10/domain/v10/SUBSTANCE-10.0.xsd b/epiuclid/schemas/v10/domain/v10/SUBSTANCE-10.0.xsd new file mode 100644 index 00000000..4a0b9c2b --- /dev/null +++ b/epiuclid/schemas/v10/domain/v10/SUBSTANCE-10.0.xsd @@ -0,0 +1,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epiuclid/schemas/v10/domain/v10/commonTypesDomainV10.xsd b/epiuclid/schemas/v10/domain/v10/commonTypesDomainV10.xsd new file mode 100644 index 00000000..83556464 --- /dev/null +++ b/epiuclid/schemas/v10/domain/v10/commonTypesDomainV10.xsd @@ -0,0 +1,24395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epiuclid/schemas/v10/oecd/v10/ENDPOINT_STUDY_RECORD-BiodegradationInSoil-10.0.xsd b/epiuclid/schemas/v10/oecd/v10/ENDPOINT_STUDY_RECORD-BiodegradationInSoil-10.0.xsd new file mode 100644 index 00000000..753abe7f --- /dev/null +++ b/epiuclid/schemas/v10/oecd/v10/ENDPOINT_STUDY_RECORD-BiodegradationInSoil-10.0.xsd @@ -0,0 +1,1393 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epiuclid/schemas/v10/oecd/v10/commonTypesOecdV10.xsd b/epiuclid/schemas/v10/oecd/v10/commonTypesOecdV10.xsd new file mode 100644 index 00000000..cc4c0cf3 --- /dev/null +++ b/epiuclid/schemas/v10/oecd/v10/commonTypesOecdV10.xsd @@ -0,0 +1,34308 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epiuclid/schemas/v10/platform-attachment.xsd b/epiuclid/schemas/v10/platform-attachment.xsd new file mode 100644 index 00000000..299e7e29 --- /dev/null +++ b/epiuclid/schemas/v10/platform-attachment.xsd @@ -0,0 +1,73 @@ + + + + XML Schema Definition of the IUCLID6 Attachment entity + + + + + Defines the attachment metadata information + + + + + + The unique identifier of the attachment + + + + + The name of the uploaded attachment + + + + + The date that the attachment was created + + + + + The last modification date of the attachment + + + + + The remarks provided by the user during the attachment uploading + + + + + The MD5 hash of the uploaded attachment content + + + + + The media type of the attachment content + + + + + Indicates that the actual attachment file is not included in the i6z file + + + + + The name/location of the attachment binary under the "attachments" directory inside the i6z archive file + + + + + + + + + + + + Specifies the unique identifier of an attachment that is directly linked to a IUCLID6 document + + + diff --git a/epiuclid/schemas/v10/platform-container-v2.xsd b/epiuclid/schemas/v10/platform-container-v2.xsd new file mode 100644 index 00000000..01ed61d2 --- /dev/null +++ b/epiuclid/schemas/v10/platform-container-v2.xsd @@ -0,0 +1,92 @@ + + + + + + + XML Schema Definition of the IUCLID6 Document entity + + + + Contains top-level information concerning the IUCLID6 document along with the document's actual chemical information content + + + + + + Contains the top-level information of a IUCLID6 document such as document identifier, name, type and subtype, etc. +

+ The elements are included in the platform-metadata.xsd
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + Contains the chemical information of the specific IUCLID6 document. +

+The content is dynamic and is defined in the corresponding .xsd per document definition identifier. +in the form of "document_type"-"document_subtype"-"version".xsd. +Example: ENDPOINT_STUDY_RECORD-Density-4.0.xsd
+
+ + + + + +
+ + + Lists the attachments that are directly linked to the document. The content of this section is an unbounded list of references to attachment identifiers that this document is linked to. +

+The elements are included in the platform-attachment.xsd
+
+ + + + + + +
+ + + Lists the entries of the document's modification history. Every entry is a single operation that took place on the specific document and specifies the date of the action, the user that run the action, the submitting legal entity of the user and the modification remarks if any. + +

+The elements are included in the platform-modification-history.xsd
+
+ + + + + +
+
+
+
+
diff --git a/epiuclid/schemas/v10/platform-fields.xsd b/epiuclid/schemas/v10/platform-fields.xsd new file mode 100644 index 00000000..89c390c2 --- /dev/null +++ b/epiuclid/schemas/v10/platform-fields.xsd @@ -0,0 +1,611 @@ + + + + + XML Schema Definition of the main IUCLID6 data types + + + + + + Specifies the content of the section types field under Category document + + + + + + + + + + + + + + + + Specifies the content of the chemical inventory field + + + + + + + + + + Contains the elements constituting the AddressField type + + + + + + + + + + + + + + + + + + Holds the key of the attachment content attached to the specific field + + + + + + + Holds the list of the attachment content identifiers/keys attached to the specific field + + + + + + + + + The value of IUCLID6 boolean fields + + + + + + + Elements that constitute the regulatory programme legislation information of a data protection field + + + + + + + + + + The multilingual version of the legislation type + + + + + + + + + + The elements constituting the data protection field type + + + + + + + + + + + The multilingual version of the data protection field type + + + + + + + + + + + The value of IUCLID6 date/timestamp fields + + + + + + + Holds the key of the IUCLID6 document that is referenced by the specific field + + + + + + + Multilingual version of the document reference field + + + + + + + + + The value of IUCLID6 numeric fields + + + + + + + Specifies the elements constituting the IUCLID6 physical quantity fields + + + + + + + Restricts the eligible values of the "lowerQualifier" element + + + + + + + + + + + Restricts the eligible values of the "upperQualifier" element + + + + + + + + + + + Restricts the eligible values of the "halfBoundedQualifier" element + + + + + + + + + + + + + Groups the qualifiers along with the decimal values of the physical quantity range field + + + + + + + + + + + + Groups the qualifiers along with the integer values of the physical quantity range field + + + + + + + + + + + + Groups the qualifier along with the decimal value of the half bounded physical quantity range field + + + + + + + + + + Groups the qualifier along with the integer value of the half bounded physical quantity range field + + + + + + + + + + Lists the elements constituting the decimal physical quantity range field + + + + + + + + + + + The multilingual version of the physical quantity range field + + + + + + + + + + + Lists the elements constituting the integer physical quantity range field + + + + + + + + + + + The multilingual version of the physical quantity range field with integer value + + + + + + + + + + + Lists the elements constituting the decimal, hald-bounded physical quantity range field + + + + + + + + + + + The multilingual version of the half bounded physical quantity range field + + + + + + + + + + + Lists the elements constituting the integer, half bounded physical quantity range field + + + + + + + + + + + The multilingual version of the half bounded physical quantity range field with integer value + + + + + + + + + + + Indicates that a field holds textual content + + + + + + + Indicates that a field holds multilingual textual content + + + + + + + + + + + Indicates that a field holds textual content with a maximum of 255 characters + + + + + + + + + Indicates that a field holds multilingual textual content with a maximum of 255 characters + + + + + + + + + + + Indicates that a field holds textual content with a maximum of 32768 characters + + + + + + + + + Indicates that a field holds multilingual textual content with a maximum of 32768 characters + + + + + + + + + + + Indicates that a field holds textual content with a maximum of 2000 characters + + + + + + + + + Indicates that a field holds multilingual textual content with a maximum of 2000 characters + + + + + + + + + + + Lists the elements (phrase code and other text) constituting the IUCLID6 picklist field + + + + + + + + + + The multilingual version of the picklist field + + + + + + + + + + Lists the elements (phrase code, other text and remarks) constituting the IUCLID6 picklist field - remarks information can be up to 255 characters + + + + + + + + + + + The multilingual version of the picklist field including remarks information up to 255 characters + + + + + + + + + + + Lists the elements (phrase code, other text and remarks) constituting the IUCLID6 picklist field - remarks information can be up to 32768 characters + + + + + + + + + + + The multilingual version of the picklist field including remarks information up to 32768 characters + + + + + + + + + + + Lists the elements (phrase code, other text and remarks) constituting the IUCLID6 picklist field - remarks information can be up to 2000 characters + + + + + + + + + + + The multilingual version of the picklist field including remarks information up to 2000 characters + + + + + + + + + + + Specifies the multiplicity and attribute of a repeatable block + + + + + + + + Attribute used to hold unique identifier information + + + + + + + An empty complex type that is extended by the picklist fields which are defined inline in the auto-generated document xsds. +

+The picklist fields contain the following elements: +
    +
  • value
  • +
  • other
  • +
  • remarks
  • +
+

+The inline definition of the fields take place in order to: +
    +
  • restrict the eligible phrase codes per picklist field
  • +
  • conditionally define or omit the "other" element based on the configured phrasegroup (open, close)
  • +
  • based on the picklist definition, properly define the multilingual behavior of the textual elements "other" and "remarks" elements
  • +
  • based on the picklist definition, properly define the length restriction of the "remarks" elements
  • +
+
+ +
+ + + + An empty complex type that is extended by the physical quantity fields which are defined inline in the auto-generated document xsds. +

+The physical quantity fields contain the following elements: +
    +
  • unitCode
  • +
  • unitOther
  • +
  • value
  • +
+

+The inline definition of the fields take place in order to: +
    +
  • restrict the eligible phrase codes for the "unitCode" element
  • +
  • conditionally define or omit the "unitOther" element based on the configured phrasegroup (open, close)
  • +
  • based on the field definition, properly define the multilingual behavior of the textual "unitOther" element
  • +
+
+ +
+ + + + An empty complex type that is extended by the physical quantity range fields which are defined inline in the auto-generated document xsds. +

+The physical quantity range fields contain the following elements: +
    +
  • unitCode
  • +
  • unitOther
  • +
  • lowerQualifier
  • +
  • upperQualifier
  • +
  • lowerValue
  • +
  • upperValue
  • +
  • qualifier: in case of half-bounded
  • +
  • value: in case of half-bounded
  • +
+

+The inline definition of the fields take place in order to: +
    +
  • restrict the eligible phrase codes for the "unitCode" element
  • +
  • conditionally define or omit the "unitOther" element based on the configured phrasegroup (open, close)
  • +
  • based on the field definition, properly define the multilingual behavior of the textual "unitOther" element
  • +
  • based on the field definition, dynamically setup the bounded- or half-boudnded-related elements
  • +
+
+ +
+ + + + An empty complex type that is extended by the data protection fields which are defined inline in the auto-generated document xsds. +

+The data protection fields contain the following elements: +
    +
  • confidentiality
  • +
  • justification
  • +
  • legislation
  • +
      +
    • value
    • +
    • other
    • +
    +
+

+The inline definition of the fields take place in order to: +
    +
  • restrict the eligible phrase codes for the "confidentiality" and "value" element
  • +
  • based on the field definition, properly define the multilingual behavior of the textual "justification" and "other" elements
  • +
+
+ +
+ +
diff --git a/epiuclid/schemas/v10/platform-metadata.xsd b/epiuclid/schemas/v10/platform-metadata.xsd new file mode 100644 index 00000000..9844ba16 --- /dev/null +++ b/epiuclid/schemas/v10/platform-metadata.xsd @@ -0,0 +1,138 @@ + + + XML Schema Definition of the "PlatformMetadata" section + + + + The current iuclid version used for exporting the .i6z archive + + + + + The unique identifier of the document + + + + + The type of the document. Eligible values are: +
    +
  • ANNOTATION
  • +
  • ARTICLE
  • +
  • CATEGORY
  • +
  • DOSSIER
  • +
  • FIXED_RECORD
  • +
  • FLEXIBLE_RECORD
  • +
  • ENDPOINT_STUDY_RECORD
  • +
  • FLEXIBLE_SUMMARY
  • +
  • ENDPOINT_SUMMARY
  • +
  • ASSESSMENT_ENTITY
  • +
  • LEGAL_ENTITY
  • +
  • MIXTURE
  • +
  • REFERENCE_SUBSTANCE
  • +
  • SITE
  • +
  • CONTACT
  • +
  • LITERATURE
  • +
  • SUBSTANCE
  • +
  • TEMPLATE
  • +
  • TEST_MATERIAL_INFORMATION
  • +
  • INVENTORY
  • +
  • CUSTOM_ENTITY
  • +
  • CUSTOM_SECTION
  • +
+
+
+ + + The definition version of the exported document. This value is used: +
    +
  • indicates that the content section follows the document format of the specified version
  • +
  • during import operation, this value drives the resolution of the proper document's .xsd to run the validation with
  • +
+
+
+ + + The date that the document was created + + + + + The last modification date of the document + + + + + It is the name of the document as specified by the user. + + + + + The subtype in case of section document. This information is not applicable to entity documents. "type"."subtype" uniquely identify the section document type and represent the document definition identifier + + + + + In case this document is a section document, this element keeps the unique identifier of its parent document + + + + + In case this is a section document, the order of the document with the specific definition identifier (type, subtype) under the provided parent entity + + + + + + + + + + + + + + + + + Applicable only to dossier archives. Indicates the submission type used during dossier generation. The value is specified in case the XML concerns: +
    +
  • the dossier document
  • +
  • the composite documents (SUBSTANCE/MIXTURE) under the dossier with a submission type different than the one of the dossier document
  • +
+
+
+ + + The version of the submission type used to generate the dossier for + + + + + The legal entity document identifier that originated toe dossier creation + + + + + In case this is the dossier document, it contains the document key (unique identifier) + of the dossier subject document (SUBSTANCE, MIXTURE, CATEGORY, ARTICLE) which is the document the dossier was created from + + + + + Flag indicating whether this document originated from a IUCLID5 instance and migrated to the current IUCLID6 format or not + + + + + Element that specifies the application this document was first created with. Default value "IUC6" should be provided for IUCLID6-documents + + + + + In case of dossier archive, element that specifies the application this dossier was created from. Upon dossier creation this is filled in with "IUC6" + + +
diff --git a/epiuclid/schemas/v10/platform-modification-history.xsd b/epiuclid/schemas/v10/platform-modification-history.xsd new file mode 100644 index 00000000..26df896f --- /dev/null +++ b/epiuclid/schemas/v10/platform-modification-history.xsd @@ -0,0 +1,39 @@ + + + + XML Schema Definition of the "ModificationHistory" section + This section lists the entries of the document's modification history. Every entry is a single operation that took place on the specific document and specifies the date of the action, the user that run the action, the submitting legal entity of the user and the modification remarks if any + + + + Holds the information concerning the document's modification. Every entry is a single operation that took place on the specific document and specifies the date of the action, the user that run the action, the submitting legal entity of the user and the modification remarks if any + + + + + + The date the action was performed on the document + + + + + The userName of the user that performed the modification + + + + + The description of the submitting legal entity of the user. This information contains the concatenated value of the LE name, city and localized country information + + + + + The modification comment + + + + + + diff --git a/epiuclid/schemas/v10/xlink.xsd b/epiuclid/schemas/v10/xlink.xsd new file mode 100644 index 00000000..1756a76a --- /dev/null +++ b/epiuclid/schemas/v10/xlink.xsd @@ -0,0 +1,231 @@ + + + + This schema document provides attribute declarations and attribute + group, complex type and simple type definitions which can be used in + the construction of user schemas to define the structure of + particular linking constructs, e.g. + + + + + + + ... + + ... + + + ... + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Intended for use as the type of user-declared elements to make them simple + links. + + + + + + + + + + + + + + + + + + + + + + Intended for use as the type of user-declared elements to make them extended + links. Note that the elements referenced in the content model are + all abstract. The intention is that by simply declaring elements + with these as their substitutionGroup, all the right things will + happen. + + + + + + + + + + + + xml:lang is not required, but provides much of the motivation for title + elements in addition to attributes, and so is provided here for + convenience. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + label is not required, but locators have no particular XLink function if + they are not labeled. + + + + + + + + + + + + + + + + + + + + + + + + + from and to have default behavior when values are missing + + + + + + + + + + + + + + diff --git a/epiuclid/schemas/v10/xml.xsd b/epiuclid/schemas/v10/xml.xsd new file mode 100644 index 00000000..0f3e6a53 --- /dev/null +++ b/epiuclid/schemas/v10/xml.xsd @@ -0,0 +1,145 @@ + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + id (as an attribute name): denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang, xml:space or xml:id + attributes on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2007/08/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself, or with the XML namespace itself. In other words, if the XML + Schema or XML namespaces change, the version of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2007/08/xml.xsd will not change. + + + + + + Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. See + RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry + at http://www.iana.org/assignments/lang-tag-apps.htm for + further information. + + The union allows for the 'un-declaration' of xml:lang with + the empty string. + + + + + + + + + + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + See http://www.w3.org/TR/xml-id/ for + information about this attribute. + + + + + + + + + + + \ No newline at end of file diff --git a/epiuclid/serializers/__init__.py b/epiuclid/serializers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/epiuclid/serializers/i6z.py b/epiuclid/serializers/i6z.py new file mode 100644 index 00000000..2b571c80 --- /dev/null +++ b/epiuclid/serializers/i6z.py @@ -0,0 +1,118 @@ +import io +import xml.etree.ElementTree as ET +import zipfile + +from epiuclid.builders.base import NS_PLATFORM_CONTAINER, document_key +from epiuclid.builders.endpoint_study import EndpointStudyRecordBuilder +from epiuclid.builders.reference_substance import ReferenceSubstanceBuilder +from epiuclid.builders.substance import SubstanceBuilder +from epiuclid.serializers.manifest import ManifestBuilder +from epiuclid.serializers.pathway_mapper import IUCLIDDocumentBundle +from epiuclid.schemas.loader import get_content_schema + + +def _i6d_filename(uuid) -> str: + return f"{uuid}_0.i6d" + + +class I6ZSerializer: + """Serialize a IUCLIDDocumentBundle to a ZIP file containing the manifest.xml and the i6d files in memory.""" + + def serialize(self, bundle: IUCLIDDocumentBundle, *, validate: bool = False) -> bytes: + return self._assemble(bundle, validate=validate) + + def _assemble(self, bundle: IUCLIDDocumentBundle, *, validate: bool = False) -> bytes: + sub_builder = SubstanceBuilder() + ref_builder = ReferenceSubstanceBuilder() + esr_builder = EndpointStudyRecordBuilder() + + # (filename, xml_string, doc_type, uuid, subtype) + files: list[tuple[str, str, str, str, str | None]] = [] + + for sub in bundle.substances: + fname = _i6d_filename(sub.uuid) + xml = sub_builder.build(sub) + files.append((fname, xml, "SUBSTANCE", str(sub.uuid), None)) + + for ref in bundle.reference_substances: + fname = _i6d_filename(ref.uuid) + xml = ref_builder.build(ref) + files.append((fname, xml, "REFERENCE_SUBSTANCE", str(ref.uuid), None)) + + for esr in bundle.endpoint_study_records: + fname = _i6d_filename(esr.uuid) + xml = esr_builder.build(esr) + files.append( + (fname, xml, "ENDPOINT_STUDY_RECORD", str(esr.uuid), "BiodegradationInSoil") + ) + + if validate: + self._validate_documents(files) + + # Build document relationship links for manifest + links = self._build_links(bundle) + + # Build manifest + manifest_docs = [(f[0], f[2], f[3], f[4]) for f in files] + base_uuid = str(bundle.substances[0].uuid) if bundle.substances else "" + manifest_xml = ManifestBuilder().build(manifest_docs, base_uuid, links=links) + + # Assemble ZIP + buf = io.BytesIO() + with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf: + zf.writestr("manifest.xml", manifest_xml) + for fname, xml, _, _, _ in files: + zf.writestr(fname, xml) + return buf.getvalue() + + @staticmethod + def _validate_documents( + files: list[tuple[str, str, str, str, str | None]], + ) -> None: + """Validate each i6d document against its XSD schema. + + Raises ``xmlschema.XMLSchemaValidationError`` on the first failure. + """ + + for fname, xml, doc_type, _uuid, subtype in files: + root = ET.fromstring(xml) + content = root.find(f"{{{NS_PLATFORM_CONTAINER}}}Content") + if content is None or len(content) == 0: + continue + content_el = list(content)[0] + schema = get_content_schema(doc_type, subtype) + schema.validate(content_el) + + @staticmethod + def _build_links(bundle: IUCLIDDocumentBundle) -> dict[str, list[tuple[str, str]]]: + """Build manifest link relationships between documents. + + Returns a dict mapping document UUID (str) to list of (target_doc_key, ref_type). + """ + links: dict[str, list[tuple[str, str]]] = {} + + def _add(uuid_str: str, target_key: str, ref_type: str) -> None: + doc_links = links.setdefault(uuid_str, []) + link = (target_key, ref_type) + if link not in doc_links: + doc_links.append(link) + + # Substance -> REFERENCE link to its reference substance + for sub in bundle.substances: + if sub.reference_substance_uuid: + ref_key = document_key(sub.reference_substance_uuid) + _add(str(sub.uuid), ref_key, "REFERENCE") + + # ESR -> PARENT link to its substance; substance -> CHILD link to ESR + for esr in bundle.endpoint_study_records: + sub_key = document_key(esr.substance_uuid) + esr_key = document_key(esr.uuid) + _add(str(esr.uuid), sub_key, "PARENT") + _add(str(esr.substance_uuid), esr_key, "CHILD") + + for tp in esr.transformation_products: + _add(str(esr.uuid), document_key(tp.product_reference_uuid), "REFERENCE") + for parent_ref_uuid in tp.parent_reference_uuids: + _add(str(esr.uuid), document_key(parent_ref_uuid), "REFERENCE") + + return links diff --git a/epiuclid/serializers/manifest.py b/epiuclid/serializers/manifest.py new file mode 100644 index 00000000..b221ec40 --- /dev/null +++ b/epiuclid/serializers/manifest.py @@ -0,0 +1,120 @@ +import xml.etree.ElementTree as ET +from datetime import datetime, timezone + +from epiuclid.builders.base import document_key + +NS_MANIFEST = "http://iuclid6.echa.europa.eu/namespaces/manifest/v1" +NS_XLINK = "http://www.w3.org/1999/xlink" + +ET.register_namespace("", NS_MANIFEST) +ET.register_namespace("xlink", NS_XLINK) + + +def _i6d_filename(uuid) -> str: + """Convert UUID to i6d filename (uuid_0.i6d for raw data).""" + return f"{uuid}_0.i6d" + + +def _tag(local: str) -> str: + return f"{{{NS_MANIFEST}}}{local}" + + +def _add_link(links_elem: ET.Element, ref_uuid: str, ref_type: str) -> None: + """Add a element with ref-uuid and ref-type.""" + link = ET.SubElement(links_elem, _tag("link")) + ref_uuid_elem = ET.SubElement(link, _tag("ref-uuid")) + ref_uuid_elem.text = ref_uuid + ref_type_elem = ET.SubElement(link, _tag("ref-type")) + ref_type_elem.text = ref_type + + +class ManifestBuilder: + def build( + self, + documents: list[tuple[str, str, str, str | None]], + base_document_uuid: str, + links: dict[str, list[tuple[str, str]]] | None = None, + ) -> str: + """Build manifest.xml. + + Args: + documents: List of (filename, doc_type, uuid, subtype) tuples. + base_document_uuid: UUID of the base document (the substance export started from). + links: Optional dict mapping document UUID to list of (target_doc_key, ref_type) tuples. + ref_type is one of: PARENT, CHILD, REFERENCE. + """ + if links is None: + links = {} + + root = ET.Element(_tag("manifest")) + + # general-information + gi = ET.SubElement(root, _tag("general-information")) + title = ET.SubElement(gi, _tag("title")) + title.text = "IUCLID 6 container manifest file" + + created = ET.SubElement(gi, _tag("created")) + created.text = datetime.now(timezone.utc).strftime("%a %b %d %H:%M:%S %Z %Y") + + author = ET.SubElement(gi, _tag("author")) + author.text = "enviPath" + + application = ET.SubElement(gi, _tag("application")) + application.text = "enviPath IUCLID Export" + + submission_type = ET.SubElement(gi, _tag("submission-type")) + submission_type.text = "R_INT_ONSITE" + + archive_type = ET.SubElement(gi, _tag("archive-type")) + archive_type.text = "RAW_DATA" + + legislations = ET.SubElement(gi, _tag("legislations-info")) + leg = ET.SubElement(legislations, _tag("legislation")) + leg_id = ET.SubElement(leg, _tag("id")) + leg_id.text = "core" + leg_ver = ET.SubElement(leg, _tag("version")) + leg_ver.text = "10.0" + + # base-document-uuid + base_doc = ET.SubElement(root, _tag("base-document-uuid")) + base_doc.text = document_key(base_document_uuid) + + # contained-documents + contained = ET.SubElement(root, _tag("contained-documents")) + + now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + + for filename, doc_type, uuid, subtype in documents: + doc_key = document_key(uuid) + doc_elem = ET.SubElement(contained, _tag("document")) + doc_elem.set("id", doc_key) + + type_elem = ET.SubElement(doc_elem, _tag("type")) + type_elem.text = doc_type + + if subtype: + subtype_elem = ET.SubElement(doc_elem, _tag("subtype")) + subtype_elem.text = subtype + + name_elem = ET.SubElement(doc_elem, _tag("name")) + name_elem.set(f"{{{NS_XLINK}}}type", "simple") + name_elem.set(f"{{{NS_XLINK}}}href", filename) + name_elem.text = filename + + first_mod = ET.SubElement(doc_elem, _tag("first-modification-date")) + first_mod.text = now + + last_mod = ET.SubElement(doc_elem, _tag("last-modification-date")) + last_mod.text = now + + uuid_elem = ET.SubElement(doc_elem, _tag("uuid")) + uuid_elem.text = doc_key + + # Add links for this document if any + doc_links = links.get(uuid, []) + if doc_links: + links_elem = ET.SubElement(doc_elem, _tag("links")) + for target_key, ref_type in doc_links: + _add_link(links_elem, target_key, ref_type) + + return ET.tostring(root, encoding="unicode", xml_declaration=True) diff --git a/epiuclid/serializers/pathway_mapper.py b/epiuclid/serializers/pathway_mapper.py new file mode 100644 index 00000000..d50ce1ad --- /dev/null +++ b/epiuclid/serializers/pathway_mapper.py @@ -0,0 +1,493 @@ +from __future__ import annotations + +import logging +from dataclasses import dataclass, field +from uuid import UUID, uuid4 + +from epapi.v1.interfaces.iuclid.dto import PathwayExportDTO +from utilities.chem import FormatConverter + +logger = logging.getLogger(__name__) + + +@dataclass +class IUCLIDReferenceSubstanceData: + uuid: UUID + name: str + smiles: str | None = None + cas_number: str | None = None + ec_number: str | None = None + iupac_name: str | None = None + molecular_formula: str | None = None + molecular_weight: float | None = None + inchi: str | None = None + inchi_key: str | None = None + + +@dataclass +class IUCLIDSubstanceData: + uuid: UUID + name: str + reference_substance_uuid: UUID | None = None + + +@dataclass +class SoilPropertiesData: + soil_no_code: str | None = None + soil_type: str | None = None + sand: float | None = None + silt: float | None = None + clay: float | None = None + org_carbon: float | None = None + ph_lower: float | None = None + ph_upper: float | None = None + ph_method: str | None = None + cec: float | None = None + moisture_content: float | None = None + soil_classification: str | None = None + + +@dataclass +class IUCLIDEndpointStudyRecordData: + uuid: UUID + substance_uuid: UUID + name: str + half_lives: list[HalfLifeEntry] = field(default_factory=list) + temperature: tuple[float, float] | None = None + transformation_products: list[IUCLIDTransformationProductEntry] = field(default_factory=list) + model_name_and_version: list[str] = field(default_factory=list) + software_name_and_version: list[str] = field(default_factory=list) + model_remarks: list[str] = field(default_factory=list) + soil_properties: SoilPropertiesData | None = None + soil_properties_entries: list[SoilPropertiesData] = field(default_factory=list) + + +@dataclass +class HalfLifeEntry: + model: str + dt50_start: float + dt50_end: float + unit: str + source: str + soil_no_code: str | None = None + temperature: tuple[float, float] | None = None + + +@dataclass +class IUCLIDTransformationProductEntry: + uuid: UUID + product_reference_uuid: UUID + parent_reference_uuids: list[UUID] = field(default_factory=list) + kinetic_formation_fraction: float | None = None + source_edge_uuid: UUID | None = None + + +@dataclass +class IUCLIDDocumentBundle: + substances: list[IUCLIDSubstanceData] = field(default_factory=list) + reference_substances: list[IUCLIDReferenceSubstanceData] = field(default_factory=list) + endpoint_study_records: list[IUCLIDEndpointStudyRecordData] = field(default_factory=list) + + +class PathwayMapper: + def map(self, export: PathwayExportDTO) -> IUCLIDDocumentBundle: + bundle = IUCLIDDocumentBundle() + + seen_compounds: dict[ + int, tuple[UUID, UUID] + ] = {} # compound PK -> (substance UUID, ref UUID) + compound_names: dict[int, str] = {} + + for compound in export.compounds: + if compound.pk in seen_compounds: + continue + + derived = self._compute_derived_properties(compound.smiles) + ref_sub_uuid = uuid4() + sub_uuid = uuid4() + seen_compounds[compound.pk] = (sub_uuid, ref_sub_uuid) + compound_names[compound.pk] = compound.name + + ref_sub = IUCLIDReferenceSubstanceData( + uuid=ref_sub_uuid, + name=compound.name, + smiles=compound.smiles, + cas_number=compound.cas_number, + molecular_formula=derived["molecular_formula"], + molecular_weight=derived["molecular_weight"], + inchi=derived["inchi"], + inchi_key=derived["inchi_key"], + ) + bundle.reference_substances.append(ref_sub) + + sub = IUCLIDSubstanceData( + uuid=sub_uuid, + name=compound.name, + reference_substance_uuid=ref_sub_uuid, + ) + bundle.substances.append(sub) + + if not export.compounds: + return bundle + + root_compound_pks: list[int] = [] + seen_root_pks: set[int] = set() + for root_pk in export.root_compound_pks: + if root_pk in seen_compounds and root_pk not in seen_root_pks: + root_compound_pks.append(root_pk) + seen_root_pks.add(root_pk) + + if not root_compound_pks: + fallback_root_pk = export.compounds[0].pk + if fallback_root_pk in seen_compounds: + root_compound_pks = [fallback_root_pk] + + if not root_compound_pks: + return bundle + + edge_templates: list[tuple[UUID, frozenset[int], tuple[int, ...], tuple[UUID, ...]]] = [] + for edge in sorted(export.edges, key=lambda item: str(item.edge_uuid)): + parent_compound_pks = sorted( + {pk for pk in edge.start_compound_pks if pk in seen_compounds} + ) + product_compound_pks = sorted( + {pk for pk in edge.end_compound_pks if pk in seen_compounds} + ) + + if not parent_compound_pks or not product_compound_pks: + continue + + parent_ref_uuids = tuple( + sorted({seen_compounds[pk][1] for pk in parent_compound_pks}, key=str) + ) + edge_templates.append( + ( + edge.edge_uuid, + frozenset(parent_compound_pks), + tuple(product_compound_pks), + parent_ref_uuids, + ) + ) + + model_names: list[str] = [] + software_names: list[str] = [] + model_remarks: list[str] = [] + if export.model_info: + if export.model_info.model_name: + model_names.append(export.model_info.model_name) + if export.model_info.model_uuid: + model_remarks.append(f"Model UUID: {export.model_info.model_uuid}") + if export.model_info.software_name: + if export.model_info.software_version: + software_names.append( + f"{export.model_info.software_name} {export.model_info.software_version}" + ) + else: + software_names.append(export.model_info.software_name) + + # Aggregate scenario-aware AI from all root nodes for each root compound. + # Each entry is (scenario_uuid, scenario_name, effective_ai_list). + root_node_ai_by_scenario: dict[int, dict[str, tuple[UUID | None, str | None, list]]] = {} + for node in export.nodes: + if node.depth == 0 and node.compound_pk in seen_root_pks: + scenario_bucket = root_node_ai_by_scenario.setdefault(node.compound_pk, {}) + if node.scenarios: + for scenario in node.scenarios: + scenario_key = str(scenario.scenario_uuid) + existing = scenario_bucket.get(scenario_key) + if existing is None: + scenario_bucket[scenario_key] = ( + scenario.scenario_uuid, + scenario.name, + list(scenario.additional_info), + ) + else: + existing[2].extend(scenario.additional_info) + else: + # Backward compatibility path for callers that only provide node.additional_info. + fallback_key = f"fallback:{node.node_uuid}" + scenario_bucket[fallback_key] = (None, None, list(node.additional_info)) + + has_multiple_roots = len(root_compound_pks) > 1 + for root_pk in root_compound_pks: + substance_uuid, _ = seen_compounds[root_pk] + esr_name = f"Biodegradation in soil - {export.pathway_name}" + if has_multiple_roots: + root_name = compound_names.get(root_pk) + if root_name: + esr_name = f"{esr_name} ({root_name})" + + transformation_entries: list[IUCLIDTransformationProductEntry] = [] + reachable_compound_pks = self._reachable_compounds_from_root(root_pk, edge_templates) + seen_transformations: set[tuple[UUID, tuple[UUID, ...]]] = set() + for ( + edge_uuid, + parent_compound_pks, + product_compound_pks, + parent_reference_uuids, + ) in edge_templates: + if not parent_compound_pks.issubset(reachable_compound_pks): + continue + + for product_compound_pk in product_compound_pks: + if product_compound_pk not in reachable_compound_pks: + continue + + product_ref_uuid = seen_compounds[product_compound_pk][1] + dedupe_key = (product_ref_uuid, parent_reference_uuids) + if dedupe_key in seen_transformations: + continue + + seen_transformations.add(dedupe_key) + transformation_entries.append( + IUCLIDTransformationProductEntry( + uuid=uuid4(), + product_reference_uuid=product_ref_uuid, + parent_reference_uuids=list(parent_reference_uuids), + source_edge_uuid=edge_uuid, + ) + ) + + scenarios_for_root = list(root_node_ai_by_scenario.get(root_pk, {}).values()) + if not scenarios_for_root: + scenarios_for_root = [(None, None, [])] + + soil_entries: list[SoilPropertiesData] = [] + soil_no_by_signature: dict[tuple, str] = {} + half_lives: list[HalfLifeEntry] = [] + merged_ai_for_root: list = [] + + for _, _, ai_for_scenario in scenarios_for_root: + merged_ai_for_root.extend(ai_for_scenario) + + soil = self._extract_soil_properties(ai_for_scenario) + temperature = self._extract_temperature(ai_for_scenario) + + soil_no_code: str | None = None + if soil is not None: + soil_signature = self._soil_signature(soil) + soil_no_code = soil_no_by_signature.get(soil_signature) + if soil_no_code is None: + soil_no_code = self._soil_no_code_for_index(len(soil_entries)) + if soil_no_code is not None: + soil.soil_no_code = soil_no_code + soil_entries.append(soil) + soil_no_by_signature[soil_signature] = soil_no_code + + for hl in self._extract_half_lives(ai_for_scenario): + hl.soil_no_code = soil_no_code + hl.temperature = temperature + half_lives.append(hl) + + esr = IUCLIDEndpointStudyRecordData( + uuid=uuid4(), + substance_uuid=substance_uuid, + name=esr_name, + half_lives=half_lives, + temperature=self._extract_temperature(merged_ai_for_root), + transformation_products=transformation_entries, + model_name_and_version=model_names, + software_name_and_version=software_names, + model_remarks=model_remarks, + soil_properties=soil_entries[0] if soil_entries else None, + soil_properties_entries=soil_entries, + ) + bundle.endpoint_study_records.append(esr) + + return bundle + + @staticmethod + def _extract_half_lives(ai_list: list) -> list[HalfLifeEntry]: + from envipy_additional_information.information import HalfLife + + entries = [] + for ai in ai_list: + if not isinstance(ai, HalfLife): + continue + start = ai.dt50.start + end = ai.dt50.end + if start is None or end is None: + continue + entries.append( + HalfLifeEntry( + model=ai.model, + dt50_start=start, + dt50_end=end, + unit="d", + source=ai.source, + ) + ) + return entries + + @staticmethod + def _extract_temperature(ai_list: list) -> tuple[float, float] | None: + from envipy_additional_information.information import Temperature + + for ai in ai_list: + if not isinstance(ai, Temperature): + continue + lower = ai.interval.start + upper = ai.interval.end + if lower is None or upper is None: + continue + return (lower, upper) + return None + + @staticmethod + def _extract_soil_properties(ai_list: list) -> SoilPropertiesData | None: + from envipy_additional_information.information import ( + Acidity, + BulkDensity, + CEC, + Humidity, + OMContent, + SoilClassification, + SoilTexture1, + SoilTexture2, + ) + + props = SoilPropertiesData() + + for ai in ai_list: + if isinstance(ai, SoilTexture1) and props.soil_type is None: + props.soil_type = ai.type.value + elif isinstance(ai, SoilTexture2): + if props.sand is None: + props.sand = ai.sand + if props.silt is None: + props.silt = ai.silt + if props.clay is None: + props.clay = ai.clay + elif isinstance(ai, OMContent) and props.org_carbon is None: + props.org_carbon = ai.in_oc + elif isinstance(ai, Acidity) and props.ph_lower is None: + props.ph_lower = ai.interval.start + props.ph_upper = ai.interval.end + if isinstance(ai.method, str): + props.ph_method = ai.method.strip() or None + else: + props.ph_method = ai.method + elif isinstance(ai, CEC) and props.cec is None: + props.cec = ai.capacity + elif isinstance(ai, Humidity) and props.moisture_content is None: + props.moisture_content = ai.humiditiy + elif isinstance(ai, SoilClassification) and props.soil_classification is None: + props.soil_classification = ai.system.value + elif isinstance(ai, BulkDensity): + pass # BulkDensity.data is a free-text string; not mapped to SoilPropertiesData + + all_none = all( + v is None + for v in ( + props.soil_type, + props.sand, + props.silt, + props.clay, + props.org_carbon, + props.ph_lower, + props.ph_upper, + props.ph_method, + props.cec, + props.moisture_content, + props.soil_classification, + ) + ) + return None if all_none else props + + @staticmethod + def _reachable_compounds_from_root( + root_compound_pk: int, + edge_templates: list[tuple[UUID, frozenset[int], tuple[int, ...], tuple[UUID, ...]]], + ) -> set[int]: + reachable: set[int] = {root_compound_pk} + changed = True + + while changed: + changed = False + for _, parent_compound_pks, product_compound_pks, _ in edge_templates: + if not parent_compound_pks.issubset(reachable): + continue + + for product_compound_pk in product_compound_pks: + if product_compound_pk in reachable: + continue + reachable.add(product_compound_pk) + changed = True + + return reachable + + @staticmethod + def _soil_signature(props: SoilPropertiesData) -> tuple: + return ( + props.soil_type, + props.sand, + props.silt, + props.clay, + props.org_carbon, + props.ph_lower, + props.ph_upper, + props.ph_method, + props.cec, + props.moisture_content, + props.soil_classification, + ) + + @staticmethod + def _soil_no_code_for_index(index: int) -> str | None: + f137_codes = [ + "2", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "3", + "4070", + "4071", + "4072", + "4073", + "4074", + "4075", + "4076", + "4077", + "4078", + "4079", + ] + if 0 <= index < len(f137_codes): + return f137_codes[index] + return None + + @staticmethod + def _compute_derived_properties(smiles: str | None) -> dict: + molecular_formula = None + molecular_weight = None + inchi = None + inchi_key = None + + if smiles: + try: + molecular_formula = FormatConverter.formula(smiles) + except Exception: + logger.debug("Could not compute formula for %s", smiles) + try: + molecular_weight = FormatConverter.mass(smiles) + except Exception: + logger.debug("Could not compute mass for %s", smiles) + try: + inchi = FormatConverter.InChI(smiles) + except Exception: + logger.debug("Could not compute InChI for %s", smiles) + try: + inchi_key = FormatConverter.InChIKey(smiles) + except Exception: + logger.debug("Could not compute InChIKey for %s", smiles) + + return { + "molecular_formula": molecular_formula, + "molecular_weight": molecular_weight, + "inchi": inchi, + "inchi_key": inchi_key, + } diff --git a/epiuclid/tests/__init__.py b/epiuclid/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/epiuclid/tests/factories.py b/epiuclid/tests/factories.py new file mode 100644 index 00000000..97084f57 --- /dev/null +++ b/epiuclid/tests/factories.py @@ -0,0 +1,102 @@ +from __future__ import annotations + +from uuid import uuid4 + +from epiuclid.serializers.pathway_mapper import ( + HalfLifeEntry, + IUCLIDEndpointStudyRecordData, + IUCLIDReferenceSubstanceData, + IUCLIDSubstanceData, + IUCLIDTransformationProductEntry, + SoilPropertiesData, +) + + +def make_substance_data(**overrides) -> IUCLIDSubstanceData: + payload = { + "uuid": uuid4(), + "name": "Atrazine", + "reference_substance_uuid": uuid4(), + } + payload.update(overrides) + return IUCLIDSubstanceData(**payload) + + +def make_reference_substance_data(**overrides) -> IUCLIDReferenceSubstanceData: + payload = { + "uuid": uuid4(), + "name": "Atrazine", + "smiles": "CCNc1nc(Cl)nc(NC(C)C)n1", + "cas_number": "1912-24-9", + "ec_number": "217-617-8", + "iupac_name": "6-chloro-N2-ethyl-N4-isopropyl-1,3,5-triazine-2,4-diamine", + "molecular_formula": "C8H14ClN5", + "molecular_weight": 215.68, + "inchi": ( + "InChI=1S/C8H14ClN5/c1-4-10-7-12-6(9)11-8(13-7)" + "14-5(2)3/h5H,4H2,1-3H3,(H2,10,11,12,13,14)" + ), + "inchi_key": "MXWJVTOOROXGIU-UHFFFAOYSA-N", + } + payload.update(overrides) + return IUCLIDReferenceSubstanceData(**payload) + + +def make_half_life_entry(**overrides) -> HalfLifeEntry: + payload = { + "model": "SFO", + "dt50_start": 12.5, + "dt50_end": 15.0, + "unit": "d", + "source": "Model prediction", + "soil_no_code": None, + "temperature": None, + } + payload.update(overrides) + return HalfLifeEntry(**payload) + + +def make_transformation_entry(**overrides) -> IUCLIDTransformationProductEntry: + payload = { + "uuid": uuid4(), + "product_reference_uuid": uuid4(), + "parent_reference_uuids": [uuid4()], + "kinetic_formation_fraction": 0.42, + } + payload.update(overrides) + return IUCLIDTransformationProductEntry(**payload) + + +def make_soil_properties_data(**overrides) -> SoilPropertiesData: + payload = { + "soil_no_code": None, + "clay": 20.0, + "silt": 30.0, + "sand": 50.0, + "org_carbon": 1.5, + "ph_lower": 6.0, + "ph_upper": 7.0, + "ph_method": "CaCl2", + "cec": 12.0, + "moisture_content": 40.0, + "soil_type": "LOAM", + "soil_classification": "USDA", + } + payload.update(overrides) + return SoilPropertiesData(**payload) + + +def make_endpoint_study_record_data(**overrides) -> IUCLIDEndpointStudyRecordData: + payload = { + "uuid": uuid4(), + "substance_uuid": uuid4(), + "name": "Biodegradation study", + "half_lives": [], + "temperature": None, + "transformation_products": [], + "model_name_and_version": [], + "software_name_and_version": [], + "model_remarks": [], + } + payload.update(overrides) + return IUCLIDEndpointStudyRecordData(**payload) diff --git a/epiuclid/tests/test_api.py b/epiuclid/tests/test_api.py new file mode 100644 index 00000000..84abdc25 --- /dev/null +++ b/epiuclid/tests/test_api.py @@ -0,0 +1,92 @@ +"""Integration tests for IUCLID export API endpoint.""" + +import io +import zipfile +from uuid import uuid4 + +from django.test import TestCase, tag + +from epdb.logic import PackageManager, UserManager +from epdb.models import Node, Pathway + + +@tag("iuclid") +class IUCLIDExportAPITest(TestCase): + @classmethod + def setUpTestData(cls): + cls.user = UserManager.create_user( + "iuclid-api-user", + "iuclid-api@test.com", + "TestPass123", + set_setting=False, + add_to_group=False, + is_active=True, + ) + default_pkg = cls.user.default_package + cls.user.default_package = None + cls.user.save() + default_pkg.delete() + + cls.package = PackageManager.create_package(cls.user, "IUCLID API Test Package") + + cls.pathway = Pathway.create( + cls.package, + "c1ccccc1", + name="Export Test Pathway", + ) + Node.create(cls.pathway, "c1ccc(O)cc1", depth=1, name="Phenol") + + # Unauthorized user + cls.other_user = UserManager.create_user( + "iuclid-other-user", + "other@test.com", + "TestPass123", + set_setting=False, + add_to_group=False, + is_active=True, + ) + other_pkg = cls.other_user.default_package + cls.other_user.default_package = None + cls.other_user.save() + other_pkg.delete() + + def test_export_returns_zip(self): + self.client.force_login(self.user) + url = f"/api/v1/pathway/{self.pathway.uuid}/export/iuclid" + response = self.client.get(url) + + self.assertEqual(response.status_code, 200) + self.assertEqual(response["Content-Type"], "application/zip") + self.assertIn(".i6z", response["Content-Disposition"]) + + self.assertTrue(zipfile.is_zipfile(io.BytesIO(response.content))) + + def test_export_contains_expected_files(self): + self.client.force_login(self.user) + url = f"/api/v1/pathway/{self.pathway.uuid}/export/iuclid" + response = self.client.get(url) + + with zipfile.ZipFile(io.BytesIO(response.content)) as zf: + names = zf.namelist() + self.assertIn("manifest.xml", names) + i6d_files = [n for n in names if n.endswith(".i6d")] + # 2 substances + 2 ref substances + 1 ESR = 5 i6d files + self.assertEqual(len(i6d_files), 5) + + def test_anonymous_returns_401(self): + self.client.logout() + url = f"/api/v1/pathway/{self.pathway.uuid}/export/iuclid" + response = self.client.get(url) + self.assertEqual(response.status_code, 401) + + def test_unauthorized_user_returns_403(self): + self.client.force_login(self.other_user) + url = f"/api/v1/pathway/{self.pathway.uuid}/export/iuclid" + response = self.client.get(url) + self.assertEqual(response.status_code, 403) + + def test_nonexistent_pathway_returns_404(self): + self.client.force_login(self.user) + url = f"/api/v1/pathway/{uuid4()}/export/iuclid" + response = self.client.get(url) + self.assertEqual(response.status_code, 404) diff --git a/epiuclid/tests/test_builders.py b/epiuclid/tests/test_builders.py new file mode 100644 index 00000000..5cc54f1e --- /dev/null +++ b/epiuclid/tests/test_builders.py @@ -0,0 +1,521 @@ +"""Contract tests for IUCLID XML builders - no DB required.""" + +import xml.etree.ElementTree as ET +from uuid import uuid4 + +from django.test import SimpleTestCase, tag + +from epiuclid.builders.base import ( + NS_PLATFORM_CONTAINER, + NS_PLATFORM_FIELDS, + NS_PLATFORM_METADATA, + document_key, +) +from epiuclid.builders.endpoint_study import DOC_SUBTYPE, EndpointStudyRecordBuilder, NS_ESR_BIODEG +from epiuclid.builders.reference_substance import NS_REFERENCE_SUBSTANCE, ReferenceSubstanceBuilder +from epiuclid.builders.substance import NS_SUBSTANCE, SubstanceBuilder + +from .factories import ( + make_endpoint_study_record_data, + make_half_life_entry, + make_reference_substance_data, + make_soil_properties_data, + make_substance_data, + make_transformation_entry, +) +from .xml_assertions import assert_xpath_absent, assert_xpath_text + + +@tag("iuclid") +class SubstanceBuilderContractTest(SimpleTestCase): + def test_maps_name_and_reference_key(self): + reference_uuid = uuid4() + data = make_substance_data(name="Atrazine", reference_substance_uuid=reference_uuid) + + root = ET.fromstring(SubstanceBuilder().build(data)) + + assert_xpath_text(self, root, f".//{{{NS_SUBSTANCE}}}ChemicalName", "Atrazine") + assert_xpath_text( + self, + root, + f".//{{{NS_SUBSTANCE}}}ReferenceSubstance/{{{NS_SUBSTANCE}}}ReferenceSubstance", + document_key(reference_uuid), + ) + + def test_omits_reference_substance_when_missing(self): + data = make_substance_data(reference_substance_uuid=None) + + root = ET.fromstring(SubstanceBuilder().build(data)) + + assert_xpath_absent(self, root, f".//{{{NS_SUBSTANCE}}}ReferenceSubstance") + + def test_sets_substance_document_type(self): + data = make_substance_data() + + root = ET.fromstring(SubstanceBuilder().build(data)) + + assert_xpath_text( + self, + root, + f"{{{NS_PLATFORM_CONTAINER}}}PlatformMetadata/{{{NS_PLATFORM_METADATA}}}documentType", + "SUBSTANCE", + ) + + +@tag("iuclid") +class ReferenceSubstanceBuilderContractTest(SimpleTestCase): + def test_maps_structural_identifiers_and_mass_precision(self): + data = make_reference_substance_data(molecular_weight=215.6) + + root = ET.fromstring(ReferenceSubstanceBuilder().build(data)) + + assert_xpath_text( + self, + root, + f".//{{{NS_REFERENCE_SUBSTANCE}}}Inventory/{{{NS_REFERENCE_SUBSTANCE}}}CASNumber", + "1912-24-9", + ) + assert_xpath_text( + self, + root, + f".//{{{NS_REFERENCE_SUBSTANCE}}}MolecularStructuralInfo/{{{NS_REFERENCE_SUBSTANCE}}}InChl", + ( + "InChI=1S/C8H14ClN5/c1-4-10-7-12-6(9)11-8(13-7)" + "14-5(2)3/h5H,4H2,1-3H3,(H2,10,11,12,13,14)" + ), + ) + assert_xpath_text( + self, + root, + f".//{{{NS_REFERENCE_SUBSTANCE}}}MolecularStructuralInfo/{{{NS_REFERENCE_SUBSTANCE}}}InChIKey", + "MXWJVTOOROXGIU-UHFFFAOYSA-N", + ) + assert_xpath_text( + self, + root, + f".//{{{NS_REFERENCE_SUBSTANCE}}}MolecularStructuralInfo" + f"/{{{NS_REFERENCE_SUBSTANCE}}}MolecularWeightRange" + f"/{{{NS_REFERENCE_SUBSTANCE}}}lowerValue", + "215.60", + ) + + def test_omits_inventory_and_weight_for_minimal_payload(self): + data = make_reference_substance_data( + cas_number=None, + molecular_formula=None, + molecular_weight=None, + inchi=None, + inchi_key=None, + smiles="CC", + ) + + root = ET.fromstring(ReferenceSubstanceBuilder().build(data)) + + assert_xpath_absent(self, root, f".//{{{NS_REFERENCE_SUBSTANCE}}}Inventory") + assert_xpath_absent( + self, + root, + f".//{{{NS_REFERENCE_SUBSTANCE}}}MolecularWeightRange", + ) + assert_xpath_text( + self, + root, + f".//{{{NS_REFERENCE_SUBSTANCE}}}MolecularStructuralInfo/{{{NS_REFERENCE_SUBSTANCE}}}SmilesNotation", + "CC", + ) + + +@tag("iuclid") +class EndpointStudyRecordBuilderContractTest(SimpleTestCase): + def test_sets_document_metadata_and_parent_link(self): + substance_uuid = uuid4() + data = make_endpoint_study_record_data(substance_uuid=substance_uuid) + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + metadata_root = f"{{{NS_PLATFORM_CONTAINER}}}PlatformMetadata" + assert_xpath_text( + self, + root, + f"{metadata_root}/{{{NS_PLATFORM_METADATA}}}documentType", + "ENDPOINT_STUDY_RECORD", + ) + assert_xpath_text( + self, + root, + f"{metadata_root}/{{{NS_PLATFORM_METADATA}}}documentSubType", + DOC_SUBTYPE, + ) + assert_xpath_text( + self, + root, + f"{metadata_root}/{{{NS_PLATFORM_METADATA}}}parentDocumentKey", + document_key(substance_uuid), + ) + assert_xpath_text( + self, + root, + f"{metadata_root}/{{{NS_PLATFORM_METADATA}}}orderInSectionNo", + "1", + ) + + def test_esr_metadata_order_uses_stax_safe_layout(self): + data = make_endpoint_study_record_data() + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + metadata = root.find(f"{{{NS_PLATFORM_CONTAINER}}}PlatformMetadata") + + self.assertIsNotNone(metadata) + assert metadata is not None + child_tags = [el.tag.split("}", 1)[1] for el in list(metadata)] + self.assertEqual( + child_tags, + [ + "iuclidVersion", + "documentKey", + "documentType", + "definitionVersion", + "creationDate", + "lastModificationDate", + "name", + "documentSubType", + "parentDocumentKey", + "orderInSectionNo", + "i5Origin", + "creationTool", + ], + ) + + def test_omits_results_for_skeleton_payload(self): + data = make_endpoint_study_record_data() + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + assert_xpath_absent(self, root, f".//{{{NS_ESR_BIODEG}}}ResultsAndDiscussion") + + def test_maps_half_life_and_temperature_ranges(self): + data = make_endpoint_study_record_data( + half_lives=[make_half_life_entry(model="SFO", dt50_start=12.5, dt50_end=15.0)], + temperature=(20.0, 20.0), + ) + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + base = ( + f".//{{{NS_ESR_BIODEG}}}ResultsAndDiscussion" + f"/{{{NS_ESR_BIODEG}}}DTParentCompound" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text(self, root, f"{base}/{{{NS_ESR_BIODEG}}}KineticParameters", "SFO") + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Value/{{{NS_ESR_BIODEG}}}lowerValue", "12.5" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Value/{{{NS_ESR_BIODEG}}}upperValue", "15.0" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}lowerValue", "20.0" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}upperValue", "20.0" + ) + + def test_maps_soil_no_on_dt_entries(self): + data = make_endpoint_study_record_data( + half_lives=[ + make_half_life_entry( + model="SFO", + dt50_start=12.5, + dt50_end=15.0, + soil_no_code="2", + temperature=(22.0, 22.0), + ) + ], + temperature=None, + ) + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + base = ( + f".//{{{NS_ESR_BIODEG}}}ResultsAndDiscussion" + f"/{{{NS_ESR_BIODEG}}}DTParentCompound" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}SoilNo/{{{NS_ESR_BIODEG}}}value", "2" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}lowerValue", "22.0" + ) + + def test_maps_transformation_entries_and_model_context(self): + parent_ref_uuid = uuid4() + product_ref_uuid = uuid4() + data = make_endpoint_study_record_data( + transformation_products=[ + make_transformation_entry( + parent_reference_uuids=[parent_ref_uuid], + product_reference_uuid=product_ref_uuid, + kinetic_formation_fraction=0.42, + ) + ], + model_name_and_version=["Test model 1.0"], + software_name_and_version=["enviPath"], + model_remarks=["Model UUID: 00000000-0000-0000-0000-000000000000"], + ) + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + assert_xpath_text( + self, + root, + f".//{{{NS_ESR_BIODEG}}}MaterialsAndMethods" + f"/{{{NS_ESR_BIODEG}}}ModelAndSoftware" + f"/{{{NS_ESR_BIODEG}}}ModelNameAndVersion", + "Test model 1.0", + ) + entry_base = ( + f".//{{{NS_ESR_BIODEG}}}ResultsAndDiscussion" + f"/{{{NS_ESR_BIODEG}}}TransformationProductsDetails" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, + root, + f"{entry_base}/{{{NS_ESR_BIODEG}}}IdentityOfCompound", + document_key(product_ref_uuid), + ) + assert_xpath_text( + self, + root, + f"{entry_base}/{{{NS_ESR_BIODEG}}}ParentCompoundS/{{{NS_PLATFORM_FIELDS}}}key", + document_key(parent_ref_uuid), + ) + assert_xpath_text( + self, + root, + f"{entry_base}/{{{NS_ESR_BIODEG}}}KineticFormationFraction", + "0.42", + ) + + def test_temperature_without_half_lives_in_xml(self): + """Temperature with no half-lives still renders a DTParentCompound entry.""" + data = make_endpoint_study_record_data(temperature=(21.0, 21.0)) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + base = ( + f".//{{{NS_ESR_BIODEG}}}ResultsAndDiscussion" + f"/{{{NS_ESR_BIODEG}}}DTParentCompound" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}lowerValue", "21.0" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}upperValue", "21.0" + ) + + def test_temperature_interval_in_xml(self): + """Temperature tuple renders as lowerValue/upperValue in Temp element.""" + hl = make_half_life_entry() + data = make_endpoint_study_record_data(half_lives=[hl], temperature=(20.0, 25.0)) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + base = ( + f".//{{{NS_ESR_BIODEG}}}ResultsAndDiscussion" + f"/{{{NS_ESR_BIODEG}}}DTParentCompound" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}lowerValue", "20.0" + ) + assert_xpath_text( + self, root, f"{base}/{{{NS_ESR_BIODEG}}}Temp/{{{NS_ESR_BIODEG}}}upperValue", "25.0" + ) + + def test_esr_with_soil_properties_emits_structured_soil_by_default(self): + props = make_soil_properties_data(clay=15.0, silt=35.0, sand=50.0) + data = make_endpoint_study_record_data(soil_properties=props) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + entry_path = ( + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilProperties" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}Clay/{{{NS_ESR_BIODEG}}}lowerValue", + "15.0", + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}Silt/{{{NS_ESR_BIODEG}}}lowerValue", + "35.0", + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}Sand/{{{NS_ESR_BIODEG}}}lowerValue", + "50.0", + ) + assert_xpath_text( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}value", + "1649", + ) + assert_xpath_absent( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}other", + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}SoilType/{{{NS_ESR_BIODEG}}}value", + "1026", + ) + assert_xpath_absent( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}SoilType/{{{NS_ESR_BIODEG}}}other", + ) + assert_xpath_absent( + self, + root, + f".//{{{NS_ESR_BIODEG}}}AnyOtherInformationOnMaterialsAndMethodsInclTables", + ) + assert_xpath_absent(self, root, f".//{{{NS_ESR_BIODEG}}}DetailsOnSoilCharacteristics") + + def test_maps_multiple_soil_entries_with_soil_no(self): + data = make_endpoint_study_record_data( + soil_properties_entries=[ + make_soil_properties_data(soil_no_code="2", soil_type="LOAMY_SAND", sand=83.1), + make_soil_properties_data(soil_no_code="4", soil_type="CLAY_LOAM", sand=23.7), + ] + ) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + entries = root.findall( + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilProperties" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + self.assertEqual(len(entries), 2) + + soil_no_values = [ + entry.findtext(f"{{{NS_ESR_BIODEG}}}SoilNo/{{{NS_ESR_BIODEG}}}value") + for entry in entries + ] + self.assertEqual(soil_no_values, ["2", "4"]) + + def test_maps_soil_type_and_soil_classification_to_structured_fields(self): + props = make_soil_properties_data(soil_type="LOAMY_SAND", soil_classification="USDA") + data = make_endpoint_study_record_data(soil_properties=props) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + entry_path = ( + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilProperties" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}SoilType/{{{NS_ESR_BIODEG}}}value", + "1027", + ) + assert_xpath_absent( + self, root, f"{entry_path}/{{{NS_ESR_BIODEG}}}SoilType/{{{NS_ESR_BIODEG}}}other" + ) + assert_xpath_text( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}value", + "1649", + ) + assert_xpath_absent( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}other", + ) + + def test_unknown_soil_type_and_classification_use_open_picklist(self): + props = make_soil_properties_data(soil_type="SILTY_SAND", soil_classification="UK_ADAS") + data = make_endpoint_study_record_data(soil_properties=props) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + entry_path = ( + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilProperties" + f"/{{{NS_ESR_BIODEG}}}entry" + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}SoilType/{{{NS_ESR_BIODEG}}}value", + "1342", + ) + assert_xpath_text( + self, + root, + f"{entry_path}/{{{NS_ESR_BIODEG}}}SoilType/{{{NS_ESR_BIODEG}}}other", + "SILTY SAND", + ) + assert_xpath_text( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}value", + "1342", + ) + assert_xpath_text( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}other", + "UK ADAS", + ) + + def test_infers_usda_soil_classification_from_soil_type(self): + props = make_soil_properties_data(soil_type="LOAMY_SAND", soil_classification=None) + data = make_endpoint_study_record_data(soil_properties=props) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + assert_xpath_text( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign" + f"/{{{NS_ESR_BIODEG}}}SoilClassification" + f"/{{{NS_ESR_BIODEG}}}value", + "1649", + ) + assert_xpath_absent( + self, + root, + f".//{{{NS_ESR_BIODEG}}}StudyDesign/{{{NS_ESR_BIODEG}}}SoilClassification/{{{NS_ESR_BIODEG}}}other", + ) + + def test_esr_without_soil_properties_omits_study_design(self): + """ESR with soil_properties=None → no in XML.""" + data = make_endpoint_study_record_data(soil_properties=None) + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + assert_xpath_absent(self, root, f".//{{{NS_ESR_BIODEG}}}StudyDesign") + + def test_omits_empty_ph_measured_in(self): + props = make_soil_properties_data(ph_method="") + data = make_endpoint_study_record_data(soil_properties=props) + + root = ET.fromstring(EndpointStudyRecordBuilder().build(data)) + + self.assertNotIn("PHMeasuredIn", ET.tostring(root, encoding="unicode")) diff --git a/epiuclid/tests/test_i6z.py b/epiuclid/tests/test_i6z.py new file mode 100644 index 00000000..f1fa5234 --- /dev/null +++ b/epiuclid/tests/test_i6z.py @@ -0,0 +1,199 @@ +"""Tests for i6z archive assembly.""" + +import io +import xml.etree.ElementTree as ET +import zipfile +from uuid import uuid4 + +from django.test import SimpleTestCase, tag + +from epiuclid.serializers.i6z import I6ZSerializer +from epiuclid.serializers.pathway_mapper import ( + IUCLIDDocumentBundle, + IUCLIDEndpointStudyRecordData, + IUCLIDReferenceSubstanceData, + IUCLIDSubstanceData, + IUCLIDTransformationProductEntry, +) + + +def _make_bundle() -> IUCLIDDocumentBundle: + ref_uuid = uuid4() + sub_uuid = uuid4() + return IUCLIDDocumentBundle( + substances=[ + IUCLIDSubstanceData( + uuid=sub_uuid, + name="Benzene", + reference_substance_uuid=ref_uuid, + ), + ], + reference_substances=[ + IUCLIDReferenceSubstanceData( + uuid=ref_uuid, + name="Benzene", + smiles="c1ccccc1", + cas_number="71-43-2", + molecular_formula="C6H6", + molecular_weight=78.11, + ), + ], + endpoint_study_records=[ + IUCLIDEndpointStudyRecordData( + uuid=uuid4(), + substance_uuid=sub_uuid, + name="Endpoint study - Benzene", + ), + ], + ) + + +def _make_bundle_with_transformation_links() -> tuple[IUCLIDDocumentBundle, str, str]: + parent_ref_uuid = uuid4() + product_ref_uuid = uuid4() + sub_uuid = uuid4() + + bundle = IUCLIDDocumentBundle( + substances=[ + IUCLIDSubstanceData( + uuid=sub_uuid, + name="Benzene", + reference_substance_uuid=parent_ref_uuid, + ), + ], + reference_substances=[ + IUCLIDReferenceSubstanceData(uuid=parent_ref_uuid, name="Benzene", smiles="c1ccccc1"), + IUCLIDReferenceSubstanceData( + uuid=product_ref_uuid, name="Phenol", smiles="c1ccc(O)cc1" + ), + ], + endpoint_study_records=[ + IUCLIDEndpointStudyRecordData( + uuid=uuid4(), + substance_uuid=sub_uuid, + name="Endpoint study - Benzene", + transformation_products=[ + IUCLIDTransformationProductEntry( + uuid=uuid4(), + product_reference_uuid=product_ref_uuid, + parent_reference_uuids=[parent_ref_uuid], + ) + ], + ), + ], + ) + return bundle, f"{parent_ref_uuid}/0", f"{product_ref_uuid}/0" + + +@tag("iuclid") +class I6ZSerializerTest(SimpleTestCase): + def test_output_is_valid_zip(self): + bundle = _make_bundle() + data = I6ZSerializer().serialize(bundle) + self.assertTrue(zipfile.is_zipfile(io.BytesIO(data))) + + def test_contains_manifest(self): + bundle = _make_bundle() + data = I6ZSerializer().serialize(bundle) + + with zipfile.ZipFile(io.BytesIO(data)) as zf: + self.assertIn("manifest.xml", zf.namelist()) + + def test_contains_i6d_files(self): + bundle = _make_bundle() + data = I6ZSerializer().serialize(bundle) + + with zipfile.ZipFile(io.BytesIO(data)) as zf: + names = zf.namelist() + # manifest + 1 substance + 1 ref substance + 1 ESR = 4 files + self.assertEqual(len(names), 4) + i6d_files = [n for n in names if n.endswith(".i6d")] + self.assertEqual(len(i6d_files), 3) + + def test_manifest_references_all_documents(self): + bundle = _make_bundle() + data = I6ZSerializer().serialize(bundle) + + with zipfile.ZipFile(io.BytesIO(data)) as zf: + manifest_xml = zf.read("manifest.xml").decode("utf-8") + root = ET.fromstring(manifest_xml) + + ns = "http://iuclid6.echa.europa.eu/namespaces/manifest/v1" + docs = root.findall(f".//{{{ns}}}document") + self.assertEqual(len(docs), 3) + + types = set() + for doc in docs: + type_elem = doc.find(f"{{{ns}}}type") + self.assertIsNotNone(type_elem) + assert type_elem is not None + types.add(type_elem.text) + self.assertEqual(types, {"SUBSTANCE", "REFERENCE_SUBSTANCE", "ENDPOINT_STUDY_RECORD"}) + + def test_manifest_contains_expected_document_links(self): + bundle = _make_bundle() + data = I6ZSerializer().serialize(bundle) + + with zipfile.ZipFile(io.BytesIO(data)) as zf: + manifest_xml = zf.read("manifest.xml").decode("utf-8") + root = ET.fromstring(manifest_xml) + + ns = "http://iuclid6.echa.europa.eu/namespaces/manifest/v1" + docs = root.findall(f".//{{{ns}}}document") + + links_by_type: dict[str, set[tuple[str | None, str | None]]] = {} + for doc in docs: + doc_type = doc.findtext(f"{{{ns}}}type") + links = set() + for link in doc.findall(f"{{{ns}}}links/{{{ns}}}link"): + links.add( + ( + link.findtext(f"{{{ns}}}ref-type"), + link.findtext(f"{{{ns}}}ref-uuid"), + ) + ) + if doc_type: + links_by_type[doc_type] = links + + self.assertIn("REFERENCE", {ref_type for ref_type, _ in links_by_type["SUBSTANCE"]}) + self.assertIn("CHILD", {ref_type for ref_type, _ in links_by_type["SUBSTANCE"]}) + self.assertIn( + "PARENT", {ref_type for ref_type, _ in links_by_type["ENDPOINT_STUDY_RECORD"]} + ) + + def test_i6d_files_are_valid_xml(self): + bundle = _make_bundle() + data = I6ZSerializer().serialize(bundle) + + with zipfile.ZipFile(io.BytesIO(data)) as zf: + for name in zf.namelist(): + if name.endswith(".i6d"): + content = zf.read(name).decode("utf-8") + # Should not raise + ET.fromstring(content) + + def test_manifest_links_esr_to_transformation_reference_substances(self): + bundle, parent_ref_key, product_ref_key = _make_bundle_with_transformation_links() + data = I6ZSerializer().serialize(bundle) + + with zipfile.ZipFile(io.BytesIO(data)) as zf: + manifest_xml = zf.read("manifest.xml").decode("utf-8") + root = ET.fromstring(manifest_xml) + + ns = "http://iuclid6.echa.europa.eu/namespaces/manifest/v1" + esr_doc = None + for doc in root.findall(f".//{{{ns}}}document"): + if doc.findtext(f"{{{ns}}}type") == "ENDPOINT_STUDY_RECORD": + esr_doc = doc + break + + self.assertIsNotNone(esr_doc) + assert esr_doc is not None + + reference_links = { + link.findtext(f"{{{ns}}}ref-uuid") + for link in esr_doc.findall(f"{{{ns}}}links/{{{ns}}}link") + if link.findtext(f"{{{ns}}}ref-type") == "REFERENCE" + } + self.assertIn(parent_ref_key, reference_links) + self.assertIn(product_ref_key, reference_links) diff --git a/epiuclid/tests/test_iuclid_export.py b/epiuclid/tests/test_iuclid_export.py new file mode 100644 index 00000000..9edab631 --- /dev/null +++ b/epiuclid/tests/test_iuclid_export.py @@ -0,0 +1,86 @@ +""" +Tests for the IUCLID projection layer. +""" + +from django.test import TestCase, tag + +from envipy_additional_information.information import Temperature + +from epdb.logic import PackageManager, UserManager +from epdb.models import AdditionalInformation, Pathway, Scenario +from epapi.v1.interfaces.iuclid.projections import get_pathway_for_iuclid_export + + +@tag("api", "iuclid") +class IUCLIDExportScenarioAITests(TestCase): + """Test that scenario additional information is correctly reflected in the IUCLID export.""" + + @classmethod + def setUpTestData(cls): + cls.user = UserManager.create_user( + "iuclid-test-user", + "iuclid-test@envipath.com", + "SuperSafe", + set_setting=False, + add_to_group=False, + is_active=True, + ) + cls.package = PackageManager.create_package( + cls.user, "IUCLID Test Package", "Package for IUCLID export tests" + ) + cls.pathway = Pathway.create(cls.package, "CCO", name="Test Pathway") + cls.root_node = cls.pathway.node_set.get(depth=0) + cls.compound = cls.root_node.default_node_label.compound + cls.scenario = Scenario.objects.create( + package=cls.package, + name="Test Scenario", + scenario_type="biodegradation", + scenario_date="2024-01-01", + ) + cls.root_node.scenarios.add(cls.scenario) + + def test_scenario_with_no_ai_exports_without_error(self): + """Scenario attached to a node but with no AI must export cleanly with empty lists. + + Regression: previously scenario.parent was accessed here, causing AttributeError. + """ + result = get_pathway_for_iuclid_export(self.user, self.pathway.uuid) + + self.assertEqual(len(result.nodes), 1) + node = result.nodes[0] + self.assertEqual(len(node.scenarios), 1) + self.assertEqual(node.scenarios[0].scenario_uuid, self.scenario.uuid) + self.assertEqual(node.scenarios[0].additional_info, []) + self.assertEqual(node.additional_info, []) + + def test_direct_scenario_ai_appears_in_export(self): + """AI added directly to a scenario (no object binding) must appear in the export DTO.""" + ai = Temperature(interval={"start": 20, "end": 25}) + AdditionalInformation.create(self.package, ai, scenario=self.scenario) + + result = get_pathway_for_iuclid_export(self.user, self.pathway.uuid) + + node = result.nodes[0] + self.assertEqual(len(node.scenarios), 1) + scenario_dto = node.scenarios[0] + self.assertEqual(len(scenario_dto.additional_info), 1) + # The same AI must roll up to the node level + self.assertEqual(len(node.additional_info), 1) + self.assertEqual(node.additional_info[0], scenario_dto.additional_info[0]) + + def test_object_bound_ai_excluded_from_scenario_direct_info(self): + """AI bound to a specific object (object_id set) must not appear in direct scenario info. + + get_additional_information(direct_only=True) filters object_id__isnull=False. + """ + ai = Temperature(interval={"start": 10, "end": 15}) + AdditionalInformation.create( + self.package, ai, scenario=self.scenario, content_object=self.compound + ) + + result = get_pathway_for_iuclid_export(self.user, self.pathway.uuid) + + node = result.nodes[0] + scenario_dto = node.scenarios[0] + self.assertEqual(scenario_dto.additional_info, []) + self.assertEqual(node.additional_info, []) diff --git a/epiuclid/tests/test_pathway_mapper.py b/epiuclid/tests/test_pathway_mapper.py new file mode 100644 index 00000000..5c41c500 --- /dev/null +++ b/epiuclid/tests/test_pathway_mapper.py @@ -0,0 +1,512 @@ +"""Tests for PathwayMapper - no DB needed, uses DTO fixtures.""" + +from django.test import SimpleTestCase, tag + +from uuid import uuid4 + +from epapi.v1.interfaces.iuclid.dto import ( + PathwayCompoundDTO, + PathwayEdgeDTO, + PathwayExportDTO, + PathwayNodeDTO, + PathwayScenarioDTO, +) +from epiuclid.serializers.pathway_mapper import PathwayMapper + + +@tag("iuclid") +class PathwayMapperTest(SimpleTestCase): + def setUp(self): + self.compounds = [ + PathwayCompoundDTO(pk=1, name="Benzene", smiles="c1ccccc1"), + PathwayCompoundDTO(pk=2, name="Phenol", smiles="c1ccc(O)cc1"), + ] + + def test_mapper_produces_bundle(self): + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=self.compounds, + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + + self.assertEqual(len(bundle.substances), 2) + self.assertEqual(len(bundle.reference_substances), 2) + self.assertEqual(len(bundle.endpoint_study_records), 1) + + def test_mapper_deduplicates_compounds(self): + compounds_with_dup = [ + PathwayCompoundDTO(pk=1, name="Benzene", smiles="c1ccccc1"), + PathwayCompoundDTO(pk=2, name="Phenol", smiles="c1ccc(O)cc1"), + PathwayCompoundDTO(pk=1, name="Benzene", smiles="c1ccccc1"), + ] + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=compounds_with_dup, + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + + # 2 unique compounds -> 2 substances, 2 ref substances + self.assertEqual(len(bundle.substances), 2) + self.assertEqual(len(bundle.reference_substances), 2) + # One endpoint study record per pathway + self.assertEqual(len(bundle.endpoint_study_records), 1) + + def test_mapper_extracts_smiles(self): + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=self.compounds, + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + + smiles_values = [s.smiles for s in bundle.reference_substances] + self.assertTrue(all(s is not None for s in smiles_values)) + + def test_mapper_extracts_cas_when_present(self): + compounds = [ + PathwayCompoundDTO(pk=1, name="Benzene", smiles="c1ccccc1", cas_number="71-43-2"), + PathwayCompoundDTO(pk=2, name="Phenol", smiles="c1ccc(O)cc1"), + ] + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=compounds, + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + + cas_values = [r.cas_number for r in bundle.reference_substances] + self.assertIn("71-43-2", cas_values) + + def test_mapper_builds_transformation_entries(self): + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=self.compounds, + edges=[ + PathwayEdgeDTO( + edge_uuid=uuid4(), + start_compound_pks=[1], + end_compound_pks=[2], + probability=0.73, + ) + ], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + + self.assertEqual(len(bundle.endpoint_study_records), 1) + esr = bundle.endpoint_study_records[0] + self.assertEqual(len(esr.transformation_products), 1) + self.assertIsNone(esr.transformation_products[0].kinetic_formation_fraction) + + def test_mapper_deduplicates_transformation_entries(self): + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=self.compounds, + edges=[ + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[1], end_compound_pks=[2]), + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[1], end_compound_pks=[2]), + ], + root_compound_pks=[1], + ) + + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + + self.assertEqual(len(esr.transformation_products), 1) + + def test_mapper_creates_endpoint_record_for_each_root_compound(self): + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Test Pathway", + compounds=self.compounds, + root_compound_pks=[1, 2], + ) + + bundle = PathwayMapper().map(export) + + self.assertEqual(len(bundle.endpoint_study_records), 2) + esr_names = {record.name for record in bundle.endpoint_study_records} + self.assertIn("Biodegradation in soil - Test Pathway (Benzene)", esr_names) + self.assertIn("Biodegradation in soil - Test Pathway (Phenol)", esr_names) + + def test_mapper_builds_root_specific_transformations_for_disjoint_subgraphs(self): + compounds = [ + PathwayCompoundDTO(pk=1, name="Root A", smiles="CC"), + PathwayCompoundDTO(pk=2, name="Root B", smiles="CCC"), + PathwayCompoundDTO(pk=3, name="A Child", smiles="CCCC"), + PathwayCompoundDTO(pk=4, name="B Child", smiles="CCCCC"), + ] + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Disjoint Pathway", + compounds=compounds, + edges=[ + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[1], end_compound_pks=[3]), + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[2], end_compound_pks=[4]), + ], + root_compound_pks=[1, 2], + ) + + bundle = PathwayMapper().map(export) + + substance_name_by_uuid = {sub.uuid: sub.name for sub in bundle.substances} + reference_name_by_uuid = {ref.uuid: ref.name for ref in bundle.reference_substances} + + products_by_root: dict[str, set[str]] = {} + for esr in bundle.endpoint_study_records: + root_name = substance_name_by_uuid[esr.substance_uuid] + products_by_root[root_name] = { + reference_name_by_uuid[tp.product_reference_uuid] + for tp in esr.transformation_products + } + + self.assertEqual(products_by_root["Root A"], {"A Child"}) + self.assertEqual(products_by_root["Root B"], {"B Child"}) + + def test_mapper_requires_all_edge_parents_to_be_reachable(self): + compounds = [ + PathwayCompoundDTO(pk=1, name="Root", smiles="CC"), + PathwayCompoundDTO(pk=2, name="Co-reactant", smiles="CCC"), + PathwayCompoundDTO(pk=3, name="Product", smiles="CCCC"), + ] + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Multi Parent Pathway", + compounds=compounds, + edges=[ + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[1, 2], end_compound_pks=[3]), + ], + root_compound_pks=[1], + ) + + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + + self.assertEqual(len(esr.transformation_products), 0) + + def test_mapper_resolves_multi_parent_transformations_after_intermediate_is_reachable(self): + compounds = [ + PathwayCompoundDTO(pk=1, name="Root", smiles="CC"), + PathwayCompoundDTO(pk=2, name="Intermediate", smiles="CCC"), + PathwayCompoundDTO(pk=3, name="Product", smiles="CCCC"), + ] + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="Closure Pathway", + compounds=compounds, + edges=[ + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[1], end_compound_pks=[2]), + PathwayEdgeDTO(edge_uuid=uuid4(), start_compound_pks=[1, 2], end_compound_pks=[3]), + ], + root_compound_pks=[1], + ) + + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + reference_name_by_uuid = {ref.uuid: ref.name for ref in bundle.reference_substances} + product_names = { + reference_name_by_uuid[tp.product_reference_uuid] for tp in esr.transformation_products + } + + self.assertEqual(product_names, {"Intermediate", "Product"}) + + def test_mapper_populates_half_lives_from_root_node_ai(self): + """HalfLife AI on root node → ESR.half_lives.""" + from envipy_additional_information.information import HalfLife, Interval + + hl = HalfLife( + model="SFO", fit="ok", comment="", dt50=Interval(start=5.0, end=10.0), source="test" + ) + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + additional_info=[hl], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertEqual(len(esr.half_lives), 1) + self.assertEqual(esr.half_lives[0].dt50_start, 5.0) + self.assertEqual(esr.half_lives[0].dt50_end, 10.0) + + def test_mapper_populates_temperature_from_root_node_ai(self): + """Temperature AI on root node → ESR.temperature as tuple.""" + from envipy_additional_information.information import Temperature, Interval + + temp = Temperature(interval=Interval(start=20.0, end=25.0)) + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + additional_info=[temp], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertEqual(esr.temperature, (20.0, 25.0)) + + def test_mapper_ignores_ai_on_non_root_nodes(self): + """AI from non-root nodes (depth > 0) should not appear in ESR.""" + from envipy_additional_information.information import HalfLife, Interval + + hl = HalfLife( + model="SFO", fit="ok", comment="", dt50=Interval(start=5.0, end=10.0), source="test" + ) + non_root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=2, + name="Product", + depth=1, + smiles="CCC", + additional_info=[hl], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[ + PathwayCompoundDTO(pk=1, name="Root", smiles="CC"), + PathwayCompoundDTO(pk=2, name="Product", smiles="CCC"), + ], + nodes=[non_root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertEqual(len(esr.half_lives), 0) + + def test_extracts_soil_texture2_from_root_node_ai(self): + """SoilTexture2 AI on root node → ESR.soil_properties.sand/silt/clay.""" + from envipy_additional_information.information import SoilTexture2 + + texture = SoilTexture2(sand=65.0, silt=25.0, clay=10.0) + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + additional_info=[texture], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertIsNotNone(esr.soil_properties) + self.assertEqual(esr.soil_properties.sand, 65.0) + self.assertEqual(esr.soil_properties.silt, 25.0) + self.assertEqual(esr.soil_properties.clay, 10.0) + + def test_extracts_ph_from_root_node_ai(self): + """Acidity AI on root node → ESR.soil_properties.ph_lower/ph_upper/ph_method.""" + from envipy_additional_information.information import Acidity, Interval + + acidity = Acidity(interval=Interval(start=6.5, end=7.2), method="CaCl2") + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + additional_info=[acidity], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertIsNotNone(esr.soil_properties) + self.assertEqual(esr.soil_properties.ph_lower, 6.5) + self.assertEqual(esr.soil_properties.ph_upper, 7.2) + self.assertEqual(esr.soil_properties.ph_method, "CaCl2") + + def test_normalizes_blank_ph_method_to_none(self): + """Blank Acidity method should not produce an empty PHMeasuredIn XML node.""" + from envipy_additional_information.information import Acidity, Interval + + acidity = Acidity(interval=Interval(start=6.5, end=7.2), method=" ") + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + additional_info=[acidity], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + + self.assertIsNotNone(esr.soil_properties) + self.assertIsNone(esr.soil_properties.ph_method) + + def test_extracts_cec_and_org_carbon(self): + """CEC and OMContent AI on root node → ESR.soil_properties.cec/org_carbon.""" + from envipy_additional_information.information import CEC, OMContent + + cec = CEC(capacity=15.3) + om = OMContent(in_oc=2.1) + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + additional_info=[cec, om], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertIsNotNone(esr.soil_properties) + self.assertEqual(esr.soil_properties.cec, 15.3) + self.assertEqual(esr.soil_properties.org_carbon, 2.1) + + def test_soil_properties_none_when_no_soil_ai(self): + """No soil AI → soil_properties is None.""" + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertIsNone(esr.soil_properties) + + def test_ignores_soil_ai_on_non_root_nodes(self): + """Soil AI on non-root nodes (depth > 0) is not extracted.""" + from envipy_additional_information.information import SoilTexture2 + + texture = SoilTexture2(sand=60.0, silt=30.0, clay=10.0) + non_root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=2, + name="Product", + depth=1, + smiles="CCC", + additional_info=[texture], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[ + PathwayCompoundDTO(pk=1, name="Root", smiles="CC"), + PathwayCompoundDTO(pk=2, name="Product", smiles="CCC"), + ], + nodes=[non_root_node], + root_compound_pks=[1], + ) + bundle = PathwayMapper().map(export) + esr = bundle.endpoint_study_records[0] + self.assertIsNone(esr.soil_properties) + + def test_mapper_merges_root_scenarios_into_single_esr_with_soil_numbers(self): + """Scenario-aware root export should merge scenarios into one ESR linked by SoilNo.""" + from envipy_additional_information.information import HalfLife, Interval, SoilTexture2 + + scenario_a = PathwayScenarioDTO( + scenario_uuid=uuid4(), + name="Scenario A", + additional_info=[ + HalfLife( + model="SFO", + fit="ok", + comment="", + dt50=Interval(start=2.0, end=2.0), + source="A", + ), + SoilTexture2(sand=70.0, silt=20.0, clay=10.0), + ], + ) + scenario_b = PathwayScenarioDTO( + scenario_uuid=uuid4(), + name="Scenario B", + additional_info=[ + HalfLife( + model="SFO", + fit="ok", + comment="", + dt50=Interval(start=5.0, end=5.0), + source="B", + ), + SoilTexture2(sand=40.0, silt=40.0, clay=20.0), + ], + ) + root_node = PathwayNodeDTO( + node_uuid=uuid4(), + compound_pk=1, + name="Root", + depth=0, + smiles="CC", + scenarios=[scenario_a, scenario_b], + ) + export = PathwayExportDTO( + pathway_uuid=uuid4(), + pathway_name="P", + compounds=[PathwayCompoundDTO(pk=1, name="Root", smiles="CC")], + nodes=[root_node], + root_compound_pks=[1], + ) + + bundle = PathwayMapper().map(export) + + self.assertEqual(len(bundle.endpoint_study_records), 1) + esr = bundle.endpoint_study_records[0] + + self.assertEqual(esr.name, "Biodegradation in soil - P") + self.assertEqual(len(esr.half_lives), 2) + self.assertEqual(len(esr.soil_properties_entries), 2) + + by_dt50 = {hl.dt50_start: hl for hl in esr.half_lives} + self.assertEqual(by_dt50[2.0].soil_no_code, "2") + self.assertEqual(by_dt50[5.0].soil_no_code, "4") + self.assertEqual(by_dt50[2.0].temperature, None) + + by_soil_no = {soil.soil_no_code: soil for soil in esr.soil_properties_entries} + self.assertEqual(by_soil_no["2"].sand, 70.0) + self.assertEqual(by_soil_no["4"].sand, 40.0) diff --git a/epiuclid/tests/test_xsd_validation.py b/epiuclid/tests/test_xsd_validation.py new file mode 100644 index 00000000..4c6aff48 --- /dev/null +++ b/epiuclid/tests/test_xsd_validation.py @@ -0,0 +1,148 @@ +"""XSD validation tests for IUCLID XML builders — no DB required.""" + +import xml.etree.ElementTree as ET + +from django.test import SimpleTestCase, tag + +from epiuclid.builders.base import NS_PLATFORM_CONTAINER +from epiuclid.builders.endpoint_study import EndpointStudyRecordBuilder +from epiuclid.builders.reference_substance import ReferenceSubstanceBuilder +from epiuclid.builders.substance import SubstanceBuilder +from epiuclid.schemas.loader import get_content_schema, get_document_schema + +from .factories import ( + make_endpoint_study_record_data, + make_half_life_entry, + make_reference_substance_data, + make_soil_properties_data, + make_substance_data, + make_transformation_entry, +) + + +def _content_element(xml_str: str) -> ET.Element: + """Extract the first child of from a full i6d XML string.""" + root = ET.fromstring(xml_str) + content = root.find(f"{{{NS_PLATFORM_CONTAINER}}}Content") + assert content is not None and len(content) > 0 + return list(content)[0] + + +def _assert_content_valid(xml_str: str, doc_type: str, subtype: str | None = None) -> None: + schema = get_content_schema(doc_type, subtype) + schema.validate(_content_element(xml_str)) + + +@tag("iuclid") +class SubstanceXSDValidationTest(SimpleTestCase): + def test_substance_validates_against_xsd(self): + data = make_substance_data() + xml_str = SubstanceBuilder().build(data) + _assert_content_valid(xml_str, "SUBSTANCE") + + def test_minimal_substance_validates_against_xsd(self): + data = make_substance_data(name="Unknown compound", reference_substance_uuid=None) + xml_str = SubstanceBuilder().build(data) + _assert_content_valid(xml_str, "SUBSTANCE") + + +@tag("iuclid") +class ReferenceSubstanceXSDValidationTest(SimpleTestCase): + def test_reference_substance_validates_against_xsd(self): + data = make_reference_substance_data() + xml_str = ReferenceSubstanceBuilder().build(data) + _assert_content_valid(xml_str, "REFERENCE_SUBSTANCE") + + def test_reference_substance_minimal_validates_against_xsd(self): + data = make_reference_substance_data( + name="Minimal compound", + smiles="CC", + cas_number=None, + molecular_formula=None, + molecular_weight=None, + inchi=None, + inchi_key=None, + ) + xml_str = ReferenceSubstanceBuilder().build(data) + _assert_content_valid(xml_str, "REFERENCE_SUBSTANCE") + + +@tag("iuclid") +class EndpointStudyRecordXSDValidationTest(SimpleTestCase): + def test_endpoint_study_record_validates_against_xsd(self): + data = make_endpoint_study_record_data( + name="Biodegradation study with data", + half_lives=[ + make_half_life_entry(), + ], + temperature=(20.0, 20.0), + transformation_products=[ + make_transformation_entry(), + ], + model_name_and_version=["Test model 1.0"], + software_name_and_version=["enviPath"], + model_remarks=["Model UUID: 00000000-0000-0000-0000-000000000000"], + ) + xml_str = EndpointStudyRecordBuilder().build(data) + _assert_content_valid(xml_str, "ENDPOINT_STUDY_RECORD", "BiodegradationInSoil") + + def test_temperature_only_esr_validates_against_xsd(self): + data = make_endpoint_study_record_data( + name="Biodegradation study with temperature only", temperature=(21.0, 21.0) + ) + xml_str = EndpointStudyRecordBuilder().build(data) + _assert_content_valid(xml_str, "ENDPOINT_STUDY_RECORD", "BiodegradationInSoil") + + def test_skeleton_esr_validates_against_xsd(self): + data = make_endpoint_study_record_data(name="Biodegradation study") + xml_str = EndpointStudyRecordBuilder().build(data) + _assert_content_valid(xml_str, "ENDPOINT_STUDY_RECORD", "BiodegradationInSoil") + + def test_esr_with_soil_properties_validates_against_xsd(self): + """ESR with full soil properties validates against BiodegradationInSoil XSD.""" + data = make_endpoint_study_record_data( + name="Biodegradation study with soil properties", + soil_properties=make_soil_properties_data(), + ) + xml_str = EndpointStudyRecordBuilder().build(data) + _assert_content_valid(xml_str, "ENDPOINT_STUDY_RECORD", "BiodegradationInSoil") + + def test_esr_with_multiple_soils_and_linked_dt_validates_against_xsd(self): + data = make_endpoint_study_record_data( + name="Biodegradation study with multiple soils", + soil_properties_entries=[ + make_soil_properties_data(soil_no_code="2", soil_type="LOAMY_SAND"), + make_soil_properties_data(soil_no_code="4", soil_type="CLAY_LOAM"), + ], + half_lives=[ + make_half_life_entry(dt50_start=1.0, dt50_end=1.0, soil_no_code="2"), + make_half_life_entry(dt50_start=2.0, dt50_end=2.0, soil_no_code="4"), + ], + ) + xml_str = EndpointStudyRecordBuilder().build(data) + _assert_content_valid(xml_str, "ENDPOINT_STUDY_RECORD", "BiodegradationInSoil") + + +@tag("iuclid") +class DocumentWrapperXSDValidationTest(SimpleTestCase): + def test_full_i6d_document_validates_against_container_xsd(self): + """Validate the Document wrapper (PlatformMetadata + Content + Attachments + ModificationHistory). + + The container schema uses processContents="strict" for xs:any in Content, + so we need the content schema loaded into the validator too. + """ + data = make_substance_data() + xml_str = SubstanceBuilder().build(data) + root = ET.fromstring(xml_str) + + doc_schema = get_document_schema() + content_schema = get_content_schema("SUBSTANCE") + + # This is a xmlschema quirk and happens because there are children of the Content element not defined in the Content schema. + errors = [ + e for e in doc_schema.iter_errors(root) if "unavailable namespace" not in str(e.reason) + ] + self.assertEqual(errors, [], msg=f"Document wrapper errors: {errors}") + + content_el = _content_element(xml_str) + content_schema.validate(content_el) diff --git a/epiuclid/tests/xml_assertions.py b/epiuclid/tests/xml_assertions.py new file mode 100644 index 00000000..3c668c85 --- /dev/null +++ b/epiuclid/tests/xml_assertions.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +import xml.etree.ElementTree as ET + +from django.test import SimpleTestCase + + +def assert_xpath_text( + case: SimpleTestCase, + root: ET.Element, + path: str, + expected: str, +) -> ET.Element: + element = root.find(path) + case.assertIsNotNone(element, msg=f"Missing element at xpath: {path}") + assert element is not None + case.assertEqual(element.text, expected) + return element + + +def assert_xpath_absent(case: SimpleTestCase, root: ET.Element, path: str) -> None: + case.assertIsNone(root.find(path), msg=f"Element should be absent at xpath: {path}") diff --git a/pyproject.toml b/pyproject.toml index 12f0d2b7..e0cb325f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,8 @@ dependencies = [ "setuptools>=80.8.0", "nh3==0.3.2", "polars==1.35.1", + "xmlschema>=3.0.0", + ] [tool.uv.sources] @@ -139,6 +141,7 @@ collectstatic = { cmd = "uv run python manage.py collectstatic --noinput", help frontend-test-setup = { cmd = "playwright install", help = "Install the browsers required for frontend testing" } [tool.pytest.ini_options] +DJANGO_SETTINGS_MODULE = "envipath.settings" addopts = "--verbose --capture=no --durations=10" testpaths = ["tests", "*/tests"] pythonpath = ["."] @@ -155,4 +158,5 @@ markers = [ "frontend: Frontend tests", "end2end: End-to-end tests", "slow: Slow tests", + "iuclid: IUCLID i6z export tests", ] diff --git a/templates/actions/objects/pathway.html b/templates/actions/objects/pathway.html index be8c2486..3aaaa248 100644 --- a/templates/actions/objects/pathway.html +++ b/templates/actions/objects/pathway.html @@ -41,6 +41,14 @@ Download Pathway as Image +{% if meta.enabled_features.IUCLID_EXPORT and meta.user.username != 'anonymous' %} +
  • + + Download Pathway as IUCLID + (.i6z) +
  • +{% endif %}