From bb36f8068c714b5005450f16a229293fcdb0b30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Jer=C5=A1e?= Date: Mon, 18 Mar 2024 10:40:17 +0100 Subject: [PATCH] Add variants related models --- docs/CHANGELOG.rst | 1 + src/resdk/resolwe.py | 6 ++ src/resdk/resources/__init__.py | 8 +++ src/resdk/resources/variants.py | 101 ++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 src/resdk/resources/variants.py diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 199ae462..ccedcb7c 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -16,6 +16,7 @@ Changed Added ----- - Add ``restart`` method to the ``Data`` resource +- Add variants related models Fixed ----- diff --git a/src/resdk/resolwe.py b/src/resdk/resolwe.py index 63268dc1..02cbf016 100644 --- a/src/resdk/resolwe.py +++ b/src/resdk/resolwe.py @@ -47,6 +47,9 @@ Relation, Sample, User, + Variant, + VariantCall, + VariantExperiment, ) from .resources.base import BaseResource from .resources.kb import Feature, Mapping @@ -114,6 +117,9 @@ class Resolwe: resource_query_mapping = { AnnotationField: "annotation_field", AnnotationValue: "annotation_value", + Variant: "variant", + VariantExperiment: "variant_experiment", + VariantCall: "variant_calls", Data: "data", Collection: "collection", Sample: "sample", diff --git a/src/resdk/resources/__init__.py b/src/resdk/resources/__init__.py index 061a7964..4a2ecc72 100644 --- a/src/resdk/resources/__init__.py +++ b/src/resdk/resources/__init__.py @@ -54,6 +54,10 @@ :members: :inherited-members: +.. autoclass:: resdk.resources.Variants + :members: + :inherited-members: + .. autoclass:: resdk.resources.User :members: :inherited-members: @@ -102,6 +106,7 @@ from .relation import Relation from .sample import Sample from .user import Group, User +from .variants import Variant, VariantCall, VariantExperiment __all__ = ( "AnnotationField", @@ -117,4 +122,7 @@ "Process", "Relation", "User", + "Variant", + "VariantCall", + "VariantExperiment", ) diff --git a/src/resdk/resources/variants.py b/src/resdk/resources/variants.py new file mode 100644 index 00000000..a18c2edc --- /dev/null +++ b/src/resdk/resources/variants.py @@ -0,0 +1,101 @@ +"""Variant resources.""" + +from .base import BaseResource + + +class Variant(BaseResource): + """ResolweBio Variant resource.""" + + endpoint = "variant" + + READ_ONLY_FIELDS = BaseResource.READ_ONLY_FIELDS + ( + "species", + "genome_assembly", + "chromosome", + "position", + "reference", + "alternative", + ) + + def __repr__(self) -> str: + """Return string representation.""" + return ( + f"Variant " + ) + + +class VariantAnnotation(BaseResource): + """VariantAnnotation resource.""" + + endpoint = "variant_annotation" + + READ_ONLY_FIELDS = BaseResource.READ_ONLY_FIELDS + ( + "variant", + "type", + "clinical_diagnosis", + "clinical_significance", + "dbsnp_id", + "clinvar_id", + "data", + ) + + def __repr__(self) -> str: + """Return string representation.""" + return f"VariantAnnotation " + + +class VariantAnnotationTranscript(BaseResource): + """VariantAnnotationTranscript resource.""" + + endpoint = "variant_annotation_transcript" + + READ_ONLY_FIELDS = BaseResource.READ_ONLY_FIELDS + ( + "variant_annotation", + "annotation", + "annotation_impact", + "gene", + "protein_impact", + "transcript_ids", + "cananical", + ) + + def __repr__(self) -> str: + """Return string representation.""" + return f"VariantAnnotationTrascript " + + +class VariantExperiment(BaseResource): + """Variant experiment resource.""" + + endpoint = "variant_experiment" + + READ_ONLY_FIELDS = BaseResource.READ_ONLY_FIELDS + ( + "variant_data_source", + "timestamp", + "contributor", + ) + + +class VariantCall(BaseResource): + """VariantCall resource.""" + + endpoint = "variant_calls" + + READ_ONLY_FIELDS = BaseResource.READ_ONLY_FIELDS + ( + "sample", + "variant", + "experiment", + "quality", + "depth_norm_quality", + "unfiltered_allele_depth", + "depth", + "genotype", + "genotype_quality", + "filter", + "data", + ) + + def __repr__(self) -> str: + """Return string representation.""" + return f"VariantCall "