Commit 76e0db61 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

start annotation model

parent de1d5a5a
Pipeline #53204 failed with stages
in 3 minutes and 8 seconds
# Generated by Django 3.1.7 on 2021-04-08 15:05
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('catalog', '0028_index_source_and_functions'),
]
operations = [
migrations.CreateModel(
name='Annotation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=500)),
],
),
migrations.CreateModel(
name='GeneAnnotation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('annotation_category', models.CharField(choices=[('no-cat', 'No Category'), ('body-site', 'Body site')], default='no-cat', max_length=10)),
('annotation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='catalog.annotation')),
('gene', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='catalog.gene')),
],
options={
'unique_together': {('gene', 'annotation')},
},
),
]
from django.db import models
class Annotation(models.Model):
name = models.CharField(max_length=500, blank=True)
def __str__(self):
return self.name
......@@ -2,6 +2,7 @@ from itertools import repeat
from django.db import models
from .annotation import Annotation
from .function import Function
......@@ -95,3 +96,24 @@ class GeneFunction(models.Model):
unique_together = [
'gene', 'function'
]
class GeneAnnotation(models.Model):
NO_CAT = 'no-cat'
BODY_SITE = 'body-site'
ANNOTATION_CHOICES = [
(NO_CAT, 'No Category'),
(BODY_SITE, 'Body site'),
]
gene = models.ForeignKey(Gene, on_delete=models.CASCADE)
annotation = models.ForeignKey(Annotation, on_delete=models.CASCADE)
annotation_category = models.CharField(max_length=10, choices=ANNOTATION_CHOICES, default=NO_CAT)
def __str__(self):
return f"{self.gene.gene_id} <-> [{self.annotation_category}] {self.annotation.name}"
class Meta:
unique_together = [
'gene', 'annotation'
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment