From 2f149a3fe0680f0a37bf9118f5856eac38962c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Jer=C5=A1e?= Date: Mon, 25 Mar 2024 11:08:13 +0100 Subject: [PATCH] Add variations models --- resolwe_bio/variants/apps.py | 14 +- .../variants/migrations/0001_initial.py | 192 ++++++++++++++++++ resolwe_bio/variants/migrations/__init__.py | 0 3 files changed, 199 insertions(+), 7 deletions(-) create mode 100644 resolwe_bio/variants/migrations/0001_initial.py create mode 100644 resolwe_bio/variants/migrations/__init__.py diff --git a/resolwe_bio/variants/apps.py b/resolwe_bio/variants/apps.py index 05e7e65ae..c4b967fec 100644 --- a/resolwe_bio/variants/apps.py +++ b/resolwe_bio/variants/apps.py @@ -1,16 +1,16 @@ """.. Ignore pydocstyle D400. -================================ -Mutations Base App Configuration -================================ +=============================== +Variants Base App Configuration +=============================== """ from django.apps import AppConfig -class MutationsConfig(AppConfig): +class VariantsConfig(AppConfig): """App configuration.""" - name = "resolwe_bio.mutations" - label = "resolwe_bio_mutations" - verbose_name = "Resolwe Bioinformatics Mutations Base" + name = "resolwe_bio.variants" + label = "resolwe_bio_variants" + verbose_name = "Resolwe Bioinformatics Variants Base" diff --git a/resolwe_bio/variants/migrations/0001_initial.py b/resolwe_bio/variants/migrations/0001_initial.py new file mode 100644 index 000000000..8463987fd --- /dev/null +++ b/resolwe_bio/variants/migrations/0001_initial.py @@ -0,0 +1,192 @@ +# Generated by Django 4.2.11 on 2024-03-25 10:07 + +from django.conf import settings +import django.contrib.postgres.fields +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("flow", "0021_annotationvalue_modified"), + ] + + operations = [ + migrations.CreateModel( + name="Variant", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("species", models.CharField(max_length=50)), + ("genome_assembly", models.CharField(max_length=20)), + ("chromosome", models.CharField(max_length=20)), + ("position", models.PositiveBigIntegerField()), + ("reference", models.CharField(max_length=100)), + ("alternative", models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name="VariantExperiment", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("variant_data_source", models.CharField(max_length=100)), + ("date", models.DateTimeField(auto_now_add=True, db_index=True)), + ( + "contributor", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, + to=settings.AUTH_USER_MODEL, + ), + ), + ], + ), + migrations.CreateModel( + name="VariantCall", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("quality", models.FloatField()), + ("depth", models.PositiveIntegerField()), + ("filter", models.CharField(max_length=20)), + ("genotype", models.CharField(blank=True, max_length=100, null=True)), + ( + "data", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="variant_calls", + to="flow.data", + ), + ), + ( + "experiment", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="variant_calls", + to="resolwe_bio_variants.variantexperiment", + ), + ), + ( + "sample", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="variant_calls", + to="flow.entity", + ), + ), + ( + "variant", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="variant_calls", + to="resolwe_bio_variants.variant", + ), + ), + ], + ), + migrations.CreateModel( + name="VariantAnnotation", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("type", models.CharField(blank=True, max_length=100, null=True)), + ("annotation", models.CharField(max_length=200)), + ("annotation_impact", models.CharField(max_length=20)), + ("gene", models.CharField(max_length=100)), + ("protein_impact", models.CharField(max_length=100)), + ( + "feature_id", + django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(max_length=200), + default=list, + size=None, + ), + ), + ( + "clinical_diagnosis", + models.CharField(blank=True, max_length=200, null=True), + ), + ( + "clinical_significance", + models.CharField(blank=True, max_length=100, null=True), + ), + ("dbsnp_id", models.CharField(blank=True, max_length=20, null=True)), + ( + "clinical_var_id", + models.CharField(blank=True, max_length=20, null=True), + ), + ( + "data", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="variant_annotations", + to="flow.data", + ), + ), + ( + "variant", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + related_name="annotation", + to="resolwe_bio_variants.variant", + ), + ), + ], + ), + migrations.AddConstraint( + model_name="variant", + constraint=models.UniqueConstraint( + fields=( + "species", + "genome_assembly", + "chromosome", + "position", + "reference", + "alternative", + ), + name="uniq_composite_key_variants", + ), + ), + ] diff --git a/resolwe_bio/variants/migrations/__init__.py b/resolwe_bio/variants/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb