Skip to content

Commit

Permalink
Add variants related models
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorjerse committed Jun 27, 2024
1 parent 8ef7428 commit bb36f80
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Changed
Added
-----
- Add ``restart`` method to the ``Data`` resource
- Add variants related models

Fixed
-----
Expand Down
6 changes: 6 additions & 0 deletions src/resdk/resolwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
Relation,
Sample,
User,
Variant,
VariantCall,
VariantExperiment,
)
from .resources.base import BaseResource
from .resources.kb import Feature, Mapping
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/resdk/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
:members:
:inherited-members:
.. autoclass:: resdk.resources.Variants
:members:
:inherited-members:
.. autoclass:: resdk.resources.User
:members:
:inherited-members:
Expand Down Expand Up @@ -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",
Expand All @@ -117,4 +122,7 @@
"Process",
"Relation",
"User",
"Variant",
"VariantCall",
"VariantExperiment",
)
101 changes: 101 additions & 0 deletions src/resdk/resources/variants.py
Original file line number Diff line number Diff line change
@@ -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 <chr: {self.chromosome}, pos: {self.position}, "
f"ref: {self.reference}, alt: {self.alternative}>"
)


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 <variant: {self.variant}>"


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 <variant annotation: {self.variant_annotation}>"


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 <pk: {self.id}>"

0 comments on commit bb36f80

Please sign in to comment.