Skip to content

Commit

Permalink
udpate
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Jul 17, 2024
1 parent d4934cf commit faedc8a
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 88 deletions.
2 changes: 1 addition & 1 deletion notebooks/getting_started/3_Basic_Models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
30 changes: 15 additions & 15 deletions notebooks/getting_started/5_Exploring_the_CnvTranslator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:CX.0M5VkV5v504_laQURFMEsqzZGcOF9YEw',\n",
" 'type': <VrsType.CN_CHANGE: 'CopyNumberChange'>,\n",
" 'type': 'CopyNumberChange',\n",
" 'digest': '0M5VkV5v504_laQURFMEsqzZGcOF9YEw',\n",
" 'location': {'id': 'ga4gh:SL.GSJAEJXFDz7Nq6VlJj5NTEku48MmteUU',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'GSJAEJXFDz7Nq6VlJj5NTEku48MmteUU',\n",
" 'sequenceReference': {'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'sequenceReference': {'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.eK4D2MosgK_ivBkgi6FVPg5UXs1bYESm'},\n",
" 'start': 45002866,\n",
" 'end': 45015056},\n",
" 'copyChange': <CopyChange.EFO_0030067: 'efo:0030067'>}"
" 'copyChange': 'efo:0030067'}"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -225,16 +225,16 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:CX.0BN4vrqPrLPAZYsQEAPnG4IS8AYeBGe1',\n",
" 'type': <VrsType.CN_CHANGE: 'CopyNumberChange'>,\n",
" 'type': 'CopyNumberChange',\n",
" 'digest': '0BN4vrqPrLPAZYsQEAPnG4IS8AYeBGe1',\n",
" 'location': {'id': 'ga4gh:SL.tydo6UFL8Y60L5Me3k8AJfljURO9vYn9',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'tydo6UFL8Y60L5Me3k8AJfljURO9vYn9',\n",
" 'sequenceReference': {'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'sequenceReference': {'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.KEO-4XBcm1cxeo_DIQ8_ofqGUkp4iZhI'},\n",
" 'start': 75502957,\n",
" 'end': 76045032},\n",
" 'copyChange': <CopyChange.EFO_0030070: 'efo:0030070'>}"
" 'copyChange': 'efo:0030070'}"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -292,12 +292,12 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:CN.O_QHImmfErh9jDFkJaypPPvUmnj7EM70',\n",
" 'type': <VrsType.CN_COUNT: 'CopyNumberCount'>,\n",
" 'type': 'CopyNumberCount',\n",
" 'digest': 'O_QHImmfErh9jDFkJaypPPvUmnj7EM70',\n",
" 'location': {'id': 'ga4gh:SL.hBVWalem_rNclxjmUuT9CHbEGCdlqW9L',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'hBVWalem_rNclxjmUuT9CHbEGCdlqW9L',\n",
" 'sequenceReference': {'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'sequenceReference': {'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.HxuclGHh0XCDuF8x6yQrpHUBL7ZntAHc'},\n",
" 'start': 85623,\n",
" 'end': 57073230},\n",
Expand Down Expand Up @@ -346,12 +346,12 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:CN.WDzlT9oUq4IcQrVRWGH0dZnARnFBotCS',\n",
" 'type': <VrsType.CN_COUNT: 'CopyNumberCount'>,\n",
" 'type': 'CopyNumberCount',\n",
" 'digest': 'WDzlT9oUq4IcQrVRWGH0dZnARnFBotCS',\n",
" 'location': {'id': 'ga4gh:SL.H1Zh5xdBqamBjwVE9orWdY_uBkpEMH1V',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'H1Zh5xdBqamBjwVE9orWdY_uBkpEMH1V',\n",
" 'sequenceReference': {'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'sequenceReference': {'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.5ZUqxCmDDgN4xTRbaSjN8LwgZironmB8'},\n",
" 'start': 46111352,\n",
" 'end': 46119948},\n",
Expand Down Expand Up @@ -385,7 +385,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
46 changes: 22 additions & 24 deletions notebooks/getting_started/6_Upcoming_features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,16 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:VA.LK_4rOVxyEwrEpaOVd-BDFV0ocbO5vgV',\n",
" 'type': <VrsType.ALLELE: 'Allele'>,\n",
" 'type': 'Allele',\n",
" 'digest': 'LK_4rOVxyEwrEpaOVd-BDFV0ocbO5vgV',\n",
" 'location': {'id': 'ga4gh:SL.nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'sequenceReference': {'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'sequenceReference': {'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.aUiQCzCPZ2d0csHbMSbh2NzInhonSXwI'},\n",
" 'start': 80656509,\n",
" 'end': 80656510},\n",
" 'state': {'type': <VrsType.LIT_SEQ_EXPR: 'LiteralSequenceExpression'>,\n",
" 'sequence': 'TT'}}"
" 'state': {'type': 'LiteralSequenceExpression', 'sequence': 'TT'}}"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -226,9 +225,9 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:SL.nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'sequenceReference': {'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'sequenceReference': {'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.aUiQCzCPZ2d0csHbMSbh2NzInhonSXwI'},\n",
" 'start': 80656509,\n",
" 'end': 80656510}"
Expand Down Expand Up @@ -261,7 +260,7 @@
{
"data": {
"text/plain": [
"{'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
"{'type': 'SequenceReference',\n",
" 'refgetAccession': 'SQ.aUiQCzCPZ2d0csHbMSbh2NzInhonSXwI'}"
]
},
Expand Down Expand Up @@ -293,7 +292,7 @@
"data": {
"text/plain": [
"{'id': None,\n",
" 'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'type': 'SequenceReference',\n",
" 'label': None,\n",
" 'description': None,\n",
" 'alternativeLabels': None,\n",
Expand Down Expand Up @@ -399,9 +398,9 @@
"data": {
"text/plain": [
"{'id': 'refseq:NC_000005.10',\n",
" 'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'label': 'GRCh38:chr5',\n",
" 'alternativeLabels': ['GRCh38:5'],\n",
" 'type': 'SequenceReference',\n",
" 'label': 'GRCh38:5',\n",
" 'alternativeLabels': ['GRCh38:chr5'],\n",
" 'refgetAccession': 'SQ.aUiQCzCPZ2d0csHbMSbh2NzInhonSXwI'}"
]
},
Expand Down Expand Up @@ -435,12 +434,12 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:SL.nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'sequenceReference': {'id': 'refseq:NC_000005.10',\n",
" 'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'label': 'GRCh38:chr5',\n",
" 'alternativeLabels': ['GRCh38:5'],\n",
" 'type': 'SequenceReference',\n",
" 'label': 'GRCh38:5',\n",
" 'alternativeLabels': ['GRCh38:chr5'],\n",
" 'refgetAccession': 'SQ.aUiQCzCPZ2d0csHbMSbh2NzInhonSXwI'},\n",
" 'start': 80656509,\n",
" 'end': 80656510}"
Expand All @@ -465,20 +464,19 @@
"data": {
"text/plain": [
"{'id': 'ga4gh:VA.LK_4rOVxyEwrEpaOVd-BDFV0ocbO5vgV',\n",
" 'type': <VrsType.ALLELE: 'Allele'>,\n",
" 'type': 'Allele',\n",
" 'digest': 'LK_4rOVxyEwrEpaOVd-BDFV0ocbO5vgV',\n",
" 'location': {'id': 'ga4gh:SL.nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'type': <VrsType.SEQ_LOC: 'SequenceLocation'>,\n",
" 'type': 'SequenceLocation',\n",
" 'digest': 'nA5-KovovkH-5p3LF1657nkkeWFwrInI',\n",
" 'sequenceReference': {'id': 'refseq:NC_000005.10',\n",
" 'type': <VrsType.SEQ_REF: 'SequenceReference'>,\n",
" 'label': 'GRCh38:chr5',\n",
" 'alternativeLabels': ['GRCh38:5'],\n",
" 'type': 'SequenceReference',\n",
" 'label': 'GRCh38:5',\n",
" 'alternativeLabels': ['GRCh38:chr5'],\n",
" 'refgetAccession': 'SQ.aUiQCzCPZ2d0csHbMSbh2NzInhonSXwI'},\n",
" 'start': 80656509,\n",
" 'end': 80656510},\n",
" 'state': {'type': <VrsType.LIT_SEQ_EXPR: 'LiteralSequenceExpression'>,\n",
" 'sequence': 'TT'}}"
" 'state': {'type': 'LiteralSequenceExpression', 'sequence': 'TT'}}"
]
},
"execution_count": 11,
Expand Down Expand Up @@ -507,7 +505,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
35 changes: 17 additions & 18 deletions src/ga4gh/core/domain_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
module name, e.g., `ga4gh.core.domain_models.Gene`
"""
from typing import Literal, Union, List
from enum import Enum

from pydantic import Field, RootModel

from ga4gh.core.entity_models import DomainEntity


class CommonDomainType(str, Enum):
class CommonDomainType:
"""Define GKS Common Domain Entity types"""

PHENOTYPE = "Phenotype"
Expand All @@ -33,9 +32,9 @@ class CommonDomainType(str, Enum):
class Phenotype(DomainEntity):
"""An observable characteristic or trait of an organism."""

type: Literal[CommonDomainType.PHENOTYPE] = Field(
type: Literal["Phenotype"] = Field(
CommonDomainType.PHENOTYPE,
description=f'MUST be "{CommonDomainType.PHENOTYPE.value}".'
description=f'MUST be "{CommonDomainType.PHENOTYPE}".'
)


Expand All @@ -44,18 +43,18 @@ class Disease(DomainEntity):
of all or part of an organism and is not immediately due to any external injury.
"""

type: Literal[CommonDomainType.DISEASE] = Field(
type: Literal["Disease"] = Field(
CommonDomainType.DISEASE,
description=f'MUST be "{CommonDomainType.DISEASE.value}".'
description=f'MUST be "{CommonDomainType.DISEASE}".'
)


class TraitSet(DomainEntity):
"""A set of phenotype and/or disease concepts that together constitute a condition."""

type: Literal[CommonDomainType.TRAIT_SET] = Field(
type: Literal["TraitSet"] = Field(
CommonDomainType.TRAIT_SET,
description=f'MUST be "{CommonDomainType.TRAIT_SET.value}".'
description=f'MUST be "{CommonDomainType.TRAIT_SET}".'
)
traits: List[Union[Disease, Phenotype]] = Field(
...,
Expand All @@ -76,27 +75,27 @@ class Condition(RootModel):
class TherapeuticAction(DomainEntity):
"""A therapeutic action taken that is intended to alter or stop a pathologic process."""

type: Literal[CommonDomainType.TR_ACTION] = Field(
type: Literal["TherapeuticAction"] = Field(
CommonDomainType.TR_ACTION,
description=f'MUST be "{CommonDomainType.TR_ACTION.value}".'
description=f'MUST be "{CommonDomainType.TR_ACTION}".'
)


class TherapeuticAgent(DomainEntity):
"""An administered therapeutic agent that is intended to alter or stop a pathologic process."""

type: Literal[CommonDomainType.TR_AGENT] = Field(
type: Literal["TherapeuticAgent"] = Field(
CommonDomainType.TR_AGENT,
description=f'MUST be "{CommonDomainType.TR_AGENT.value}".'
description=f'MUST be "{CommonDomainType.TR_AGENT}".'
)


class TherapeuticSubstituteGroup(DomainEntity):
"""A group of therapeutic procedures that may be treated as substitutes for one another."""

type: Literal[CommonDomainType.TR_SUB] = Field(
type: Literal["TherapeuticSubstituteGroup"] = Field(
CommonDomainType.TR_SUB,
description=f'MUST be "{CommonDomainType.TR_SUB.value}".'
description=f'MUST be "{CommonDomainType.TR_SUB}".'
)
substitutes: List[Union[TherapeuticAction, TherapeuticAgent]] = Field(
...,
Expand All @@ -110,9 +109,9 @@ class CombinationTherapy(DomainEntity):
performed in combination.
"""

type: Literal[CommonDomainType.TR_COMB] = Field(
type: Literal["CombinationTherapy"] = Field(
CommonDomainType.TR_COMB,
description=f'MUST be "{CommonDomainType.TR_COMB.value}".'
description=f'MUST be "{CommonDomainType.TR_COMB}".'
)
components: List[Union[TherapeuticSubstituteGroup, TherapeuticAction, TherapeuticAgent]] = Field(
...,
Expand All @@ -136,7 +135,7 @@ class TherapeuticProcedure(RootModel):
class Gene(DomainEntity):
"""A basic physical and functional unit of heredity."""

type: Literal[CommonDomainType.GENE] = Field(
type: Literal["Gene"] = Field(
CommonDomainType.GENE,
description=f'MUST be "{CommonDomainType.GENE.value}".'
description=f'MUST be "{CommonDomainType.GENE}".'
)
17 changes: 5 additions & 12 deletions src/ga4gh/core/entity_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Any, Dict, Annotated, Optional, Union, List
from enum import Enum

from pydantic import BaseModel, Field, RootModel, StringConstraints, model_serializer, field_validator
from pydantic import BaseModel, Field, RootModel, StringConstraints, model_serializer, ConfigDict

from ga4gh.core import GA4GH_IR_REGEXP

Expand Down Expand Up @@ -119,6 +119,8 @@ class Coding(BaseModel):
class ConceptMapping(BaseModel):
"""A mapping to a concept in a terminology or code system."""

model_config = ConfigDict(use_enum_values=True)

coding: Coding = Field(..., description="A structured representation of a code for a defined concept in a terminology or code system.")
relation: Relation = Field(..., description="A mapping relation between concepts as defined by the Simple Knowledge Organization System (SKOS).")

Expand All @@ -144,6 +146,8 @@ class Expression(BaseModel):
variation include the HGVS and ISCN nomenclatures.
"""

model_config = ConfigDict(use_enum_values=True)

syntax: Syntax = Field(..., description="The syntax used to describe the variation. The value should be one of the supported syntaxes.")
value: str = Field(..., description="The expression of the variation in the specified syntax. The value should be a valid expression in the specified syntax.")
syntax_version: Optional[str] = Field(None, description="The version of the syntax used to describe the variation. This is particularly important for HGVS expressions, as the syntax has evolved over time.")
Expand Down Expand Up @@ -176,17 +180,6 @@ class Entity(ABC, BaseModel):
alternativeLabels: Optional[List[str]] = Field(None, description="Alternative name(s) for the Entity.")
extensions: Optional[List[Extension]] = Field(None, description="A list of extensions to the entity. Extensions are not expected to be natively understood, but may be used for pre-negotiated exchange of message attributes between systems.")

@field_validator("type")
def validate_type(cls, v: str | Enum) -> str:
"""Ensure that ``type`` field is represented as a string
:param v: Input value
:return: String representation of ``type`` field
"""
if isinstance(v, Enum):
v = v.value
return v


class DomainEntity(Entity, ABC):
"""An Entity that is specific to a particular biomedical domain such as disease,
Expand Down
Loading

0 comments on commit faedc8a

Please sign in to comment.