From f28d180360ebc6ca5a645177e1dcd20335fa445b Mon Sep 17 00:00:00 2001 From: oyurekten <103259724+oyurekten@users.noreply.github.com> Date: Sat, 14 Sep 2024 10:30:25 +0100 Subject: [PATCH] All objects have comments field inherit from CommentedIsaBase. --- mars-cli/mars_lib/models/isa_json.py | 56 +++++++++++----------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/mars-cli/mars_lib/models/isa_json.py b/mars-cli/mars_lib/models/isa_json.py index ead6b34..e8856ce 100644 --- a/mars-cli/mars_lib/models/isa_json.py +++ b/mars-cli/mars_lib/models/isa_json.py @@ -18,8 +18,11 @@ class Comment(IsaBase): value: Optional[str] = None -class OntologySourceReference(IsaBase): +class CommentedIsaBase(IsaBase): comments: List[Comment] = [] + + +class OntologySourceReference(CommentedIsaBase): description: Optional[str] = None file: Optional[str] = None name: Optional[str] = None @@ -35,9 +38,8 @@ class DataTypeEnum(str, Enum): FREE_INDUCTION_DECAY_FILE = "Free Induction Decay File" # TODO: QUESTION: This is not mentioned in the specs (https://isa-specs.readthedocs.io/) -class Data(IsaBase): +class Data(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) - comments: List[Comment] = [] name: Optional[str] = None type: Optional[DataTypeEnum] = None @@ -48,12 +50,11 @@ def apply_enum(cls, v: str) -> str: return v -class OntologyAnnotation(IsaBase): +class OntologyAnnotation(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) annotationValue: Union[Optional[str], Optional[float], Optional[int]] = Field( default=None ) - comments: List[Comment] = [] termAccession: Optional[str] = None termSource: Optional[str] = Field( description="The abbreviated ontology name. It should correspond to one of the sources as specified in the ontologySourceReference section of the Investigation.", @@ -61,19 +62,16 @@ class OntologyAnnotation(IsaBase): ) -class MaterialAttributeValue(IsaBase): +# TODO: QUESTION: comments field is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#material-attribute-value-schema-json) +class MaterialAttributeValue(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) category: Optional[MaterialAttribute] = None value: Union[str, float, int, OntologyAnnotation, None] = None unit: Optional[OntologyAnnotation] = None - comments: List[Comment] = Field( - default=[] - ) # TODO: QUESTION: This is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#material-attribute-value-schema-json) -class Factor(IsaBase): +class Factor(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) - comments: List[Comment] = [] factorName: Optional[str] = None factorType: Optional[OntologyAnnotation] = None @@ -85,24 +83,20 @@ class FactorValue(IsaBase): unit: Optional[OntologyAnnotation] = None -class Source(IsaBase): +# TODO: QUESTION: comments field is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#material-attribute-value-schema-json) +class Source(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) characteristics: List[MaterialAttributeValue] = [] name: Optional[str] = None - comments: List[Comment] = Field( - default=[] - ) # TODO: QUESTION: This is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#source-schema-json) -class Sample(IsaBase): +# TODO: QUESTION: comments field is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#material-attribute-value-schema-json) +class Sample(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) name: Optional[str] = None characteristics: List[MaterialAttributeValue] = [] factorValues: List[FactorValue] = [] derivesFrom: List[Source] = [] - comments: List[Comment] = Field( - default=[] - ) # TODO: QUESTION: This is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#sample-schema-json) class ProtocolParameter(IsaBase): @@ -122,9 +116,8 @@ class Component(IsaBase): componentType: Optional[OntologyAnnotation] = None -class Protocol(IsaBase): +class Protocol(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) - comments: List[Comment] = [] components: List[Component] = [] description: Optional[str] = None name: Optional[str] = None @@ -142,10 +135,9 @@ class MaterialTypeEnum(str, Enum): LIBRARY_NAME = "library name" # TODO: QUESTION: This is not mentioned in the specs (https://isa-specs.readthedocs.io/en/latest/isajson.html#material-schema-json) but was found in DataHub ISA-JSON and ARC ISA-JSON. -class Material(IsaBase): +class Material(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) characteristics: List[MaterialAttributeValue] = [] - comments: List[Comment] = [] name: Optional[str] = None type: Optional[str] = None derivesFrom: List[Material] = [] @@ -157,9 +149,8 @@ def apply_enum(cls, v: str) -> str: return v -class Process(IsaBase): +class Process(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) - comments: List[Comment] = [] date: Optional[str] = None executesProtocol: Optional[Protocol] = None inputs: Optional[Union[List[Source], List[Sample], List[Material], list[Data]]] = [] @@ -179,10 +170,9 @@ class AssayMaterialType(IsaBase): otherMaterials: List[Material] = [] -class Assay(IsaBase): +class Assay(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) characteristicCategories: List[MaterialAttribute] = [] - comments: List[Comment] = [] dataFiles: List[Data] = [] filename: Optional[str] = None materials: Optional[AssayMaterialType] = None @@ -212,11 +202,10 @@ def detect_target_repo_comments(cls, v: List[Comment]) -> Optional[List[Comment] ) -class Person(IsaBase): +class Person(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) address: Optional[str] = None affiliation: Optional[str] = None - comments: List[Comment] = [] email: Optional[str] = None fax: Optional[str] = None firstName: Optional[str] = None @@ -226,9 +215,8 @@ class Person(IsaBase): roles: List[OntologyAnnotation] = [] -class Publication(IsaBase): +class Publication(CommentedIsaBase): authorList: Optional[str] = None - comments: List[Comment] = [] doi: Optional[str] = None pubMedID: Optional[str] = None status: Optional[OntologyAnnotation] = None @@ -246,11 +234,10 @@ class MaterialAttribute(IsaBase): characteristicType: Optional[OntologyAnnotation] = None -class Study(IsaBase): +class Study(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) assays: List[Assay] = [] characteristicCategories: List[MaterialAttribute] = [] - comments: List[Comment] = [] description: Optional[str] = None factors: List[Factor] = [] filename: Optional[str] = None @@ -267,9 +254,8 @@ class Study(IsaBase): unitCategories: List[OntologyAnnotation] = [] -class Investigation(IsaBase): +class Investigation(CommentedIsaBase): id: Optional[str] = Field(alias="@id", default=None) - comments: List[Comment] = [] description: Optional[str] = None filename: Optional[str] = None identifier: Optional[str] = None