class Person(YAMLRoot):
    """
    A person, living or dead
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = FOAF.Person
    class_class_curie: ClassVar[str] = "foaf:Person"
    class_name: ClassVar[str] = "person"
    class_model_uri: ClassVar[URIRef] = PERS.Person

    id: Union[str, PersonId] = None
    last_name: str = None
    first_name: Optional[Union[str, List[str]]] = empty_list()
    living: Optional[Bool] = None
    age: Optional[int] = None
    knows: Optional[Union[Union[str, PersonId],
                          List[Union[str, PersonId]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, PersonId):
            self.id = PersonId(self.id)

        if self.last_name is None:
            raise ValueError("last_name must be supplied")
        if not isinstance(self.last_name, str):
            self.last_name = str(self.last_name)

        if self.first_name is None:
            self.first_name = []
        if not isinstance(self.first_name, list):
            self.first_name = [self.first_name]
        self.first_name = [
            v if isinstance(v, str) else str(v) for v in self.first_name
        ]

        if self.living is not None and not isinstance(self.living, Bool):
            self.living = Bool(self.living)

        if self.age is not None and not isinstance(self.age, int):
            self.age = int(self.age)

        if self.knows is None:
            self.knows = []
        if not isinstance(self.knows, list):
            self.knows = [self.knows]
        self.knows = [
            v if isinstance(v, PersonId) else PersonId(v) for v in self.knows
        ]

        super().__post_init__(**kwargs)
Beispiel #2
0
class Patient(Entity):
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = CCDH.Patient
    class_class_curie: ClassVar[str] = "ccdh:Patient"
    class_name: ClassVar[str] = "Patient"
    class_model_uri: ClassVar[URIRef] = CCDH.Patient

    id: Union[str, PatientId] = None
    identifier: Optional[Union[Union[dict, "Identifier"],
                               List[Union[dict,
                                          "Identifier"]]]] = empty_list()
    taxon: Optional[Union[dict, "CodeableConcept"]] = None

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, PatientId):
            self.id = PatientId(self.id)

        if self.identifier is None:
            self.identifier = []
        if not isinstance(self.identifier, list):
            self.identifier = [self.identifier]
        self.identifier = [
            v if isinstance(v, Identifier) else Identifier(**v)
            for v in self.identifier
        ]

        if self.taxon is not None and not isinstance(self.taxon,
                                                     CodeableConcept):
            self.taxon = CodeableConcept(**self.taxon)

        super().__post_init__(**kwargs)
Beispiel #3
0
class Annotation(Extension):
    """
    a tag/value pair with the semantics of OWL Annotation
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = LINKML.Annotation
    class_class_curie: ClassVar[str] = "linkml:Annotation"
    class_name: ClassVar[str] = "annotation"
    class_model_uri: ClassVar[URIRef] = LINKML.Annotation

    tag: Union[str, URIorCURIE] = None
    value: str = None
    annotations: Optional[Union[Union[dict, "Annotation"],
                                List[Union[dict,
                                           "Annotation"]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.annotations is None:
            self.annotations = []
        if not isinstance(self.annotations, list):
            self.annotations = [self.annotations]
        self._normalize_inlined_slot(slot_name="annotations",
                                     slot_type=Annotation,
                                     key_name="tag",
                                     inlined_as_list=True,
                                     keyed=False)

        super().__post_init__(**kwargs)
Beispiel #4
0
class Extensible(YAMLRoot):
    """
    mixin for classes that support extension
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = LINKML.Extensible
    class_class_curie: ClassVar[str] = "linkml:Extensible"
    class_name: ClassVar[str] = "extensible"
    class_model_uri: ClassVar[URIRef] = LINKML.Extensible

    extensions: Optional[Union[Union[dict, Extension],
                               List[Union[dict, Extension]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.extensions is None:
            self.extensions = []
        if not isinstance(self.extensions, list):
            self.extensions = [self.extensions]
        self._normalize_inlined_slot(slot_name="extensions",
                                     slot_type=Extension,
                                     key_name="tag",
                                     inlined_as_list=True,
                                     keyed=False)

        super().__post_init__(**kwargs)
Beispiel #5
0
class Employee(YAMLRoot):
    """
    A person
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = URIRef(
        "http://example.org/sample/organization/Employee")
    class_class_curie: ClassVar[str] = None
    class_name: ClassVar[str] = "employee"
    class_model_uri: ClassVar[URIRef] = URIRef(
        "http://example.org/sample/organization/Employee")

    id: Union[str, EmployeeId]
    last_name: str
    first_name: Optional[str] = None
    aliases: List[str] = empty_list()
    age_in_years: Optional[int] = None

    def __post_init__(self, **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError(f"id must be supplied")
        if not isinstance(self.id, EmployeeId):
            self.id = EmployeeId(self.id)
        if self.last_name is None:
            raise ValueError(f"last_name must be supplied")
        super().__post_init__(**kwargs)
Beispiel #6
0
class CodeableConcept(YAMLRoot):
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = TYPES.CodeableConcept
    class_class_curie: ClassVar[str] = "types:CodeableConcept"
    class_name: ClassVar[str] = "CodeableConcept"
    class_model_uri: ClassVar[URIRef] = TYPES.CodeableConcept

    coding: Optional[Union[Union[dict, Coding],
                           List[Union[dict, Coding]]]] = empty_list()
    text: Optional[str] = None

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.coding is None:
            self.coding = []
        if not isinstance(self.coding, list):
            self.coding = [self.coding]
        self.coding = [
            v if isinstance(v, Coding) else Coding(**v) for v in self.coding
        ]

        if self.text is not None and not isinstance(self.text, str):
            self.text = str(self.text)

        super().__post_init__(**kwargs)
Beispiel #7
0
class GOLRClass(YAMLRoot):
    id: str
    schema_generating: bool
    description: str
    display_name: str
    document_category: str
    weight: int
    fields: List[GOLRField] = empty_list()
Beispiel #8
0
class Person(YAMLRoot):
    """
    Minimal information about a person
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = SDO.Person
    class_class_curie: ClassVar[str] = "sdo:Person"
    class_name: ClassVar[str] = "Person"
    class_model_uri: ClassVar[URIRef] = EX.Person

    id: Union[str, PersonId] = None
    first_name: Union[str, List[str]] = None
    last_name: str = None
    knows: Optional[Union[Union[str, PersonId],
                          List[Union[str, PersonId]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, PersonId):
            self.id = PersonId(self.id)

        if self.first_name is None:
            raise ValueError("first_name must be supplied")
        elif not isinstance(self.first_name, list):
            self.first_name = [self.first_name]
        elif len(self.first_name) == 0:
            raise ValueError(f"first_name must be a non-empty list")
        self.first_name = [
            v if isinstance(v, str) else str(v) for v in self.first_name
        ]

        if self.last_name is None:
            raise ValueError("last_name must be supplied")
        if not isinstance(self.last_name, str):
            self.last_name = str(self.last_name)

        if self.knows is None:
            self.knows = []
        if not isinstance(self.knows, list):
            self.knows = [self.knows]
        self.knows = [
            v if isinstance(v, PersonId) else PersonId(v) for v in self.knows
        ]

        super().__post_init__(**kwargs)
Beispiel #9
0
class EntityReference(YAMLRoot):
    """
    The URI, namespace/name (if known) and a list of code systems that make assertions about the entity.
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = TCCM.EntityReference
    class_class_curie: ClassVar[str] = "tccm:EntityReference"
    class_name: ClassVar[str] = "EntityReference"
    class_model_uri: ClassVar[URIRef] = TCCM.EntityReference

    code: Union[str, EntityReferenceCode]
    about: Optional[URIorCURIE] = None
    designation: Optional[str] = None
    description: Optional[str] = None
    href: Optional[Union[URIorCURIE, RenderingURI]] = None
    see_also: List[Union[URIorCURIE, RenderingURI]] = empty_list()
Beispiel #10
0
class Extension(YAMLRoot):
    """
    a tag/value pair used to add non-model information to an entry
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = LINKML.Extension
    class_class_curie: ClassVar[str] = "linkml:Extension"
    class_name: ClassVar[str] = "extension"
    class_model_uri: ClassVar[URIRef] = LINKML.Extension

    tag: Union[str, URIorCURIE] = None
    value: str = None
    extensions: Optional[Union[Union[dict, "Extension"],
                               List[Union[dict, "Extension"]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.tag is None:
            raise ValueError("tag must be supplied")
        if not isinstance(self.tag, URIorCURIE):
            self.tag = URIorCURIE(self.tag)

        if self.value is None:
            raise ValueError("value must be supplied")
        if not isinstance(self.value, str):
            self.value = str(self.value)

        if self.extensions is None:
            self.extensions = []
        if not isinstance(self.extensions, list):
            self.extensions = [self.extensions]
        self._normalize_inlined_slot(slot_name="extensions",
                                     slot_type=Extension,
                                     key_name="tag",
                                     inlined_as_list=True,
                                     keyed=False)

        super().__post_init__(**kwargs)
Beispiel #11
0
class Specimen(Entity):
    """
    Any material taken as a sample from a biological entity (living or dead), or from a physical object or the
    environment. Specimens are usually collected as an example of their kind, often for use in some investigation.
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = CCDH.Specimen
    class_class_curie: ClassVar[str] = "ccdh:Specimen"
    class_name: ClassVar[str] = "Specimen"
    class_model_uri: ClassVar[URIRef] = CCDH.Specimen

    id: Union[str, SpecimenId] = None
    identifier: Optional[Union[Union[dict, "Identifier"],
                               List[Union[dict,
                                          "Identifier"]]]] = empty_list()
    associated_project: Optional[Union[str, ProjectId]] = None
    specimen_type: Optional[Union[dict, "CodeableConcept"]] = None
    analyte_type: Optional[Union[dict, "CodeableConcept"]] = None
    derived_from_specimen: Optional[Union[Union[str, SpecimenId], List[Union[
        str, SpecimenId]]]] = empty_list()
    derived_from_subject: Optional[Union[str, PatientId]] = None
    source_material_type: Optional[Union[dict, "CodeableConcept"]] = None
    cellular_composition: Optional[Union[dict, "CodeableConcept"]] = None
    general_tissue_morphology: Optional[Union[dict, "CodeableConcept"]] = None
    specific_tissue_morphology: Optional[Union[dict, "CodeableConcept"]] = None
    current_weight: Optional[Union[Union[dict, "Quantity"],
                                   List[Union[dict,
                                              "Quantity"]]]] = empty_list()
    current_volume: Optional[Union[Union[dict, "Quantity"],
                                   List[Union[dict,
                                              "Quantity"]]]] = empty_list()
    analyte_concentration: Optional[Union[dict, "Quantity"]] = None
    analyte_concentration_method: Optional[Union[dict,
                                                 "CodeableConcept"]] = None
    matched_normal_flag: Optional[
        Union[Union[dict, "CodeableConcept"],
              List[Union[dict, "CodeableConcept"]]]] = empty_list()
    qualification_status_flag: Optional[Union[dict, "CodeableConcept"]] = None

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, SpecimenId):
            self.id = SpecimenId(self.id)

        if self.identifier is None:
            self.identifier = []
        if not isinstance(self.identifier, list):
            self.identifier = [self.identifier]
        self.identifier = [
            v if isinstance(v, Identifier) else Identifier(**v)
            for v in self.identifier
        ]

        if self.associated_project is not None and not isinstance(
                self.associated_project, ProjectId):
            self.associated_project = ProjectId(self.associated_project)

        if self.specimen_type is not None and not isinstance(
                self.specimen_type, CodeableConcept):
            self.specimen_type = CodeableConcept(**self.specimen_type)

        if self.analyte_type is not None and not isinstance(
                self.analyte_type, CodeableConcept):
            self.analyte_type = CodeableConcept(**self.analyte_type)

        if self.derived_from_specimen is None:
            self.derived_from_specimen = []
        if not isinstance(self.derived_from_specimen, list):
            self.derived_from_specimen = [self.derived_from_specimen]
        self.derived_from_specimen = [
            v if isinstance(v, SpecimenId) else SpecimenId(v)
            for v in self.derived_from_specimen
        ]

        if self.derived_from_subject is not None and not isinstance(
                self.derived_from_subject, PatientId):
            self.derived_from_subject = PatientId(self.derived_from_subject)

        if self.source_material_type is not None and not isinstance(
                self.source_material_type, CodeableConcept):
            self.source_material_type = CodeableConcept(
                **self.source_material_type)

        if self.cellular_composition is not None and not isinstance(
                self.cellular_composition, CodeableConcept):
            self.cellular_composition = CodeableConcept(
                **self.cellular_composition)

        if self.general_tissue_morphology is not None and not isinstance(
                self.general_tissue_morphology, CodeableConcept):
            self.general_tissue_morphology = CodeableConcept(
                **self.general_tissue_morphology)

        if self.specific_tissue_morphology is not None and not isinstance(
                self.specific_tissue_morphology, CodeableConcept):
            self.specific_tissue_morphology = CodeableConcept(
                **self.specific_tissue_morphology)

        if self.current_weight is None:
            self.current_weight = []
        if not isinstance(self.current_weight, list):
            self.current_weight = [self.current_weight]
        self.current_weight = [
            v if isinstance(v, Quantity) else Quantity(**v)
            for v in self.current_weight
        ]

        if self.current_volume is None:
            self.current_volume = []
        if not isinstance(self.current_volume, list):
            self.current_volume = [self.current_volume]
        self.current_volume = [
            v if isinstance(v, Quantity) else Quantity(**v)
            for v in self.current_volume
        ]

        if self.analyte_concentration is not None and not isinstance(
                self.analyte_concentration, Quantity):
            self.analyte_concentration = Quantity(**self.analyte_concentration)

        if self.analyte_concentration_method is not None and not isinstance(
                self.analyte_concentration_method, CodeableConcept):
            self.analyte_concentration_method = CodeableConcept(
                **self.analyte_concentration_method)

        if self.matched_normal_flag is None:
            self.matched_normal_flag = []
        if not isinstance(self.matched_normal_flag, list):
            self.matched_normal_flag = [self.matched_normal_flag]
        self.matched_normal_flag = [
            v if isinstance(v, CodeableConcept) else CodeableConcept(**v)
            for v in self.matched_normal_flag
        ]

        if self.qualification_status_flag is not None and not isinstance(
                self.qualification_status_flag, CodeableConcept):
            self.qualification_status_flag = CodeableConcept(
                **self.qualification_status_flag)

        super().__post_init__(**kwargs)
Beispiel #12
0
class ResearchSubject(Entity):
    """
    A research subject is the entity of interest in a research study, typically a human being or an animal, but can
    also be a device, group of humans or animals, or a tissue sample. Human research subjects are usually not
    traceable to a particular person to protect the subject’s privacy.
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = CCDH.ResearchSubject
    class_class_curie: ClassVar[str] = "ccdh:ResearchSubject"
    class_name: ClassVar[str] = "ResearchSubject"
    class_model_uri: ClassVar[URIRef] = CCDH.ResearchSubject

    id: Union[str, ResearchSubjectId] = None
    identifier: Optional[Union[Union[dict, "Identifier"],
                               List[Union[dict,
                                          "Identifier"]]]] = empty_list()
    associated_project: Optional[Union[Union[str, ProjectId],
                                       List[Union[str,
                                                  ProjectId]]]] = empty_list()
    primary_disease_type: Optional[Union[dict, "CodeableConcept"]] = None
    primary_disease_site: Optional[Union[dict, "CodeableConcept"]] = None
    associated_patient: Optional[Union[str, PatientId]] = None

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, ResearchSubjectId):
            self.id = ResearchSubjectId(self.id)

        if self.identifier is None:
            self.identifier = []
        if not isinstance(self.identifier, list):
            self.identifier = [self.identifier]
        self.identifier = [
            v if isinstance(v, Identifier) else Identifier(**v)
            for v in self.identifier
        ]

        if self.associated_project is None:
            self.associated_project = []
        if not isinstance(self.associated_project, list):
            self.associated_project = [self.associated_project]
        self.associated_project = [
            v if isinstance(v, ProjectId) else ProjectId(v)
            for v in self.associated_project
        ]

        if self.primary_disease_type is not None and not isinstance(
                self.primary_disease_type, CodeableConcept):
            self.primary_disease_type = CodeableConcept(
                **self.primary_disease_type)

        if self.primary_disease_site is not None and not isinstance(
                self.primary_disease_site, CodeableConcept):
            self.primary_disease_site = CodeableConcept(
                **self.primary_disease_site)

        if self.associated_patient is not None and not isinstance(
                self.associated_patient, PatientId):
            self.associated_patient = PatientId(self.associated_patient)

        super().__post_init__(**kwargs)
Beispiel #13
0
class ConceptSystem(YAMLRoot):
    """
    A terminological resource (ontology, classification scheme, concept system, etc.)
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = SKOS.ConceptScheme
    class_class_curie: ClassVar[str] = "skos:ConceptScheme"
    class_name: ClassVar[str] = "ConceptSystem"
    class_model_uri: ClassVar[URIRef] = TERMCI.ConceptSystem

    namespace: Union[str, ConceptSystemNamespace] = None
    prefix: str = None
    description: Optional[str] = None
    reference: Optional[Union[Union[str, URI],
                              List[Union[str, URI]]]] = empty_list()
    root_concept: Optional[Union[Union[str, ConceptReferenceUri], List[Union[
        str, ConceptReferenceUri]]]] = empty_list()
    contents: Optional[Union[Dict[Union[str, ConceptReferenceUri],
                                  Union[dict, ConceptReference]],
                             List[Union[dict,
                                        ConceptReference]]]] = empty_dict()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.namespace is None:
            raise ValueError("namespace must be supplied")
        if not isinstance(self.namespace, ConceptSystemNamespace):
            self.namespace = ConceptSystemNamespace(self.namespace)

        if self.prefix is None:
            raise ValueError("prefix must be supplied")
        if not isinstance(self.prefix, str):
            self.prefix = str(self.prefix)

        if self.description is not None and not isinstance(
                self.description, str):
            self.description = str(self.description)

        if self.reference is None:
            self.reference = []
        if not isinstance(self.reference, list):
            self.reference = [self.reference]
        self.reference = [
            v if isinstance(v, URI) else URI(v) for v in self.reference
        ]

        if self.root_concept is None:
            self.root_concept = []
        if not isinstance(self.root_concept, list):
            self.root_concept = [self.root_concept]
        self.root_concept = [
            v if isinstance(v, ConceptReferenceUri) else ConceptReferenceUri(v)
            for v in self.root_concept
        ]

        if self.contents is None:
            self.contents = []
        if not isinstance(self.contents, (list)):
            self.contents = [self.contents]
        self._normalize_inlined_slot(slot_name="contents",
                                     slot_type=ConceptReference,
                                     key_name="uri",
                                     inlined_as_list=True,
                                     keyed=True)

        super().__post_init__(**kwargs)
Beispiel #14
0
class ConceptReference(YAMLRoot):
    """
    A minimal description of a class, individual, term or similar construct
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = SKOS.Concept
    class_class_curie: ClassVar[str] = "skos:Concept"
    class_name: ClassVar[str] = "ConceptReference"
    class_model_uri: ClassVar[URIRef] = TERMCI.ConceptReference

    uri: Union[str, ConceptReferenceUri] = None
    code: str = None
    defined_in: Union[str, ConceptSystemNamespace] = None
    designation: Optional[str] = None
    definition: Optional[str] = None
    reference: Optional[Union[Union[str, URI],
                              List[Union[str, URI]]]] = empty_list()
    narrower_than: Optional[Union[Union[str, ConceptReferenceUri], List[Union[
        str, ConceptReferenceUri]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.uri is None:
            raise ValueError("uri must be supplied")
        if not isinstance(self.uri, ConceptReferenceUri):
            self.uri = ConceptReferenceUri(self.uri)

        if self.code is None:
            raise ValueError("code must be supplied")
        if not isinstance(self.code, str):
            self.code = str(self.code)

        if self.defined_in is None:
            raise ValueError("defined_in must be supplied")
        if not isinstance(self.defined_in, ConceptSystemNamespace):
            self.defined_in = ConceptSystemNamespace(self.defined_in)

        if self.designation is not None and not isinstance(
                self.designation, str):
            self.designation = str(self.designation)

        if self.definition is not None and not isinstance(
                self.definition, str):
            self.definition = str(self.definition)

        if self.reference is None:
            self.reference = []
        if not isinstance(self.reference, list):
            self.reference = [self.reference]
        self.reference = [
            v if isinstance(v, URI) else URI(v) for v in self.reference
        ]

        if self.narrower_than is None:
            self.narrower_than = []
        if not isinstance(self.narrower_than, list):
            self.narrower_than = [self.narrower_than]
        self.narrower_than = [
            v if isinstance(v, ConceptReferenceUri) else ConceptReferenceUri(v)
            for v in self.narrower_than
        ]

        super().__post_init__(**kwargs)
Beispiel #15
0
class BiosampleProcessing(YAMLRoot):
    """
    A process that takes one or more biosamples as inputs and generates one or more as output
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = NMDC.BiosampleProcessing
    class_class_curie: ClassVar[str] = "nmdc:BiosampleProcessing"
    class_name: ClassVar[str] = "biosample processing"
    class_model_uri: ClassVar[URIRef] = NMDC.BiosampleProcessing

    input: Optional[Union[Union[ElementIdentifier, BiosampleId], List[Union[ElementIdentifier, BiosampleId]]]] = empty_list()
    output: Optional[Union[Union[ElementIdentifier, BiosampleId], List[Union[ElementIdentifier, BiosampleId]]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.input is None:
            self.input = []
        if not isinstance(self.input, list):
            self.input = [self.input]
        self.input = [v if isinstance(v, BiosampleId) else BiosampleId(v) for v in self.input]

        if self.output is None:
            self.output = []
        if not isinstance(self.output, list):
            self.output = [self.output]
        self.output = [v if isinstance(v, BiosampleId) else BiosampleId(v) for v in self.output]

        super().__post_init__(**kwargs)
Beispiel #16
0
class GOLRField(YAMLRoot):
    id: str
    description: str
    display_name: str
    property: List = empty_list()
    cardinality: Optional[str] = None
Beispiel #17
0
class Characteristic(YAMLRoot):
    """
    A characteristic of a biosample. Examples: depth, habitat, material, ... For NMDC, characteristics SHOULD be
    mapped to fields within a MIxS template
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = NMDC.Characteristic
    class_class_curie: ClassVar[str] = "nmdc:Characteristic"
    class_name: ClassVar[str] = "characteristic"
    class_model_uri: ClassVar[URIRef] = NMDC.Characteristic

    id: Union[ElementIdentifier, CharacteristicId] = None
    name: Optional[str] = None
    description: Optional[str] = None
    alternate_identifiers: Optional[Union[ElementIdentifier, List[ElementIdentifier]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, CharacteristicId):
            self.id = CharacteristicId(self.id)

        if self.name is not None and not isinstance(self.name, str):
            self.name = str(self.name)

        if self.description is not None and not isinstance(self.description, str):
            self.description = str(self.description)

        if self.alternate_identifiers is None:
            self.alternate_identifiers = []
        if not isinstance(self.alternate_identifiers, list):
            self.alternate_identifiers = [self.alternate_identifiers]
        self.alternate_identifiers = [v if isinstance(v, ElementIdentifier) else ElementIdentifier(v) for v in self.alternate_identifiers]

        super().__post_init__(**kwargs)
Beispiel #18
0
class Biosample(YAMLRoot):
    """
    A material sample. May be environmental (encompassing many organisms) or isolate or tissue
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = NMDC.Biosample
    class_class_curie: ClassVar[str] = "nmdc:Biosample"
    class_name: ClassVar[str] = "biosample"
    class_model_uri: ClassVar[URIRef] = NMDC.Biosample

    id: Union[ElementIdentifier, BiosampleId] = None
    name: Optional[str] = None
    annotations: Optional[Union[Union[dict, "Annotation"], List[Union[dict, "Annotation"]]]] = empty_list()
    alternate_identifiers: Optional[Union[ElementIdentifier, List[ElementIdentifier]]] = empty_list()

    def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
        if self.id is None:
            raise ValueError("id must be supplied")
        if not isinstance(self.id, BiosampleId):
            self.id = BiosampleId(self.id)

        if self.name is not None and not isinstance(self.name, str):
            self.name = str(self.name)

        if self.annotations is None:
            self.annotations = []
        if not isinstance(self.annotations, list):
            self.annotations = [self.annotations]
        self._normalize_inlined_slot(slot_name="annotations", slot_type=Annotation, key_name="has raw value", inlined_as_list=True, keyed=False)

        if self.alternate_identifiers is None:
            self.alternate_identifiers = []
        if not isinstance(self.alternate_identifiers, list):
            self.alternate_identifiers = [self.alternate_identifiers]
        self.alternate_identifiers = [v if isinstance(v, ElementIdentifier) else ElementIdentifier(v) for v in self.alternate_identifiers]

        super().__post_init__(**kwargs)