Skip to content

Commit

Permalink
Merge pull request #50 from oyurekten/commented-base-isa
Browse files Browse the repository at this point in the history
All objects that have comments field inherit from CommentedIsaBase.
  • Loading branch information
kdp-cloud authored Oct 8, 2024
2 parents 90dd5df + f28d180 commit 236eb67
Showing 1 changed file with 21 additions and 35 deletions.
56 changes: 21 additions & 35 deletions mars-cli/mars_lib/models/isa_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,9 +48,8 @@ class DataTypeEnum(str, Enum):
DATA_TYPE_VALUES = {item.value for item in DataTypeEnum}


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

Expand All @@ -58,32 +60,28 @@ 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.",
default=None,
)


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

Expand All @@ -95,24 +93,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):
Expand All @@ -132,9 +126,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
Expand All @@ -152,10 +145,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] = []
Expand All @@ -167,9 +159,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]]] = []
Expand All @@ -189,10 +180,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
Expand Down Expand Up @@ -222,11 +212,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
Expand All @@ -236,9 +225,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
Expand All @@ -256,11 +244,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
Expand All @@ -277,9 +264,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
Expand Down

0 comments on commit 236eb67

Please sign in to comment.