Skip to content

Commit eea16fa

Browse files
author
Richard Liang
committed
WIP: some fleshing out of the Django models.
1 parent b4f98c9 commit eea16fa

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/django_app/hla_typing/models.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
from django.contrib.auth.models import User
1+
from django.contrib.sessions.models import Session
2+
from django.core.validators import MinValueValidator
23
from django.db import models
34

5+
from easyhla.easyhla import HLAInterpretation
6+
47

58
class Run(models.Model):
69
"""
@@ -10,10 +13,11 @@ class Run(models.Model):
1013
or a batch job.
1114
"""
1215

13-
user = models.ForeignKey(User, on_delete=models.CASCADE)
16+
session = models.ForeignKey(Session, on_delete=models.CASCADE)
1417

1518

1619
class Interpretation(models.Model):
20+
# These are job statuses:
1721
RUNNING: str = "RUNNING"
1822
CANCELLED: str = "CANCELLED"
1923
PENDING: str = "PENDING"
@@ -27,9 +31,37 @@ class Interpretation(models.Model):
2731
FAILED: "failed",
2832
}
2933

34+
# Possible values for the locus of the sequence:
35+
A: str = "A"
36+
B: str = "B"
37+
C: str = "C"
38+
LOCI: dict[str, str] = {
39+
A: "A",
40+
B: "B",
41+
C: "C",
42+
}
43+
3044
run = models.ForeignKey(Run, on_delete=models.CASCADE)
31-
status = models.CharField(choices=STATUSES, default=PENDING)
45+
name = models.CharField(max_length=100)
46+
status = models.CharField(max_length=10, choices=STATUSES, default=PENDING)
3247

48+
exon2 = models.CharField(max_length=500)
49+
intron = models.CharField(max_length=1000)
50+
exon3 = models.CharField(max_length=500)
51+
locus = models.CharField(max_length=1, choices=LOCI)
3352

34-
class HLASequence(models.Model):
53+
54+
class MatchingCombinedStandard(BaseModel):
55+
name = models.CharField(max_length=100)
56+
mismatch_count = models.IntegerField(validators=[MinValueValidator(0)])
3557
interpretation = models.ForeignKey(Interpretation, on_delete=models.CASCADE)
58+
59+
60+
class Mismatch(BaseModel):
61+
matching_combined_standard = models.ForeignKey(
62+
MatchingCombinedStandard,
63+
on_delete=models.CASCADE,
64+
)
65+
index = models.IntegerField(validators=[MinValueValidator(1)])
66+
observed_base = models.CharField(max_length=1)
67+
expected_base = models.CharField(max_length=1)

0 commit comments

Comments
 (0)