Skip to content

Commit d377fc8

Browse files
author
rhliang
committed
WIP: some starting rumblings of a Django app to replace the current bblab tool.
1 parent f4ccc0b commit d377fc8

File tree

13 files changed

+248
-0
lines changed

13 files changed

+248
-0
lines changed

src/django_app/hla_typing/__init__.py

Whitespace-only changes.

src/django_app/hla_typing/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

src/django_app/hla_typing/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class HlaTypingConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'hla_typing'

src/django_app/hla_typing/migrations/__init__.py

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from django.contrib.auth.models import User
2+
from django.db import models
3+
4+
5+
class Run(models.Model):
6+
"""
7+
A discrete HLA interpretation run created by a user of the tool.
8+
9+
This can represent a single HLA interpretation on a single sequence,
10+
or a batch job.
11+
"""
12+
13+
user = models.ForeignKey(User, on_delete=models.CASCADE)
14+
15+
16+
class Interpretation(models.Model):
17+
RUNNING: str = "RUNNING"
18+
CANCELLED: str = "CANCELLED"
19+
PENDING: str = "PENDING"
20+
COMPLETE: str = "COMPLETE"
21+
FAILED: str = "FAILED"
22+
STATUSES: dict[str, str] = {
23+
RUNNING: "running",
24+
CANCELLED: "cancelled",
25+
PENDING: "pending",
26+
COMPLETE: "complete",
27+
FAILED: "failed",
28+
}
29+
30+
run = models.ForeignKey(Run, on_delete=models.CASCADE)
31+
status = models.CharField(choices=STATUSES, default=PENDING)
32+
33+
34+
class HLASequence(models.Model):
35+
interpretation = models.ForeignKey(Interpretation, on_delete=models.CASCADE)

src/django_app/hla_typing/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

src/django_app/hla_typing/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

src/django_app/hla_typing_site/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for hla_typing_site project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hla_typing_site.settings')
15+
16+
application = get_asgi_application()
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
"""
2+
Django settings for hla_typing_site project.
3+
4+
Generated by 'django-admin startproject' using Django 5.2.4.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.2/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/5.2/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'django-insecure-p6ipa)o5%o+^k(!js)38tv^=v=)===h($*k&^*4nkg6b4noosb'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
]
41+
42+
MIDDLEWARE = [
43+
'django.middleware.security.SecurityMiddleware',
44+
'django.contrib.sessions.middleware.SessionMiddleware',
45+
'django.middleware.common.CommonMiddleware',
46+
'django.middleware.csrf.CsrfViewMiddleware',
47+
'django.contrib.auth.middleware.AuthenticationMiddleware',
48+
'django.contrib.messages.middleware.MessageMiddleware',
49+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
50+
]
51+
52+
ROOT_URLCONF = 'hla_typing_site.urls'
53+
54+
TEMPLATES = [
55+
{
56+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
57+
'DIRS': [],
58+
'APP_DIRS': True,
59+
'OPTIONS': {
60+
'context_processors': [
61+
'django.template.context_processors.request',
62+
'django.contrib.auth.context_processors.auth',
63+
'django.contrib.messages.context_processors.messages',
64+
],
65+
},
66+
},
67+
]
68+
69+
WSGI_APPLICATION = 'hla_typing_site.wsgi.application'
70+
71+
72+
# Database
73+
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
74+
75+
DATABASES = {
76+
'default': {
77+
'ENGINE': 'django.db.backends.sqlite3',
78+
'NAME': BASE_DIR / 'db.sqlite3',
79+
}
80+
}
81+
82+
83+
# Password validation
84+
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
85+
86+
AUTH_PASSWORD_VALIDATORS = [
87+
{
88+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
89+
},
90+
{
91+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
92+
},
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
98+
},
99+
]
100+
101+
102+
# Internationalization
103+
# https://docs.djangoproject.com/en/5.2/topics/i18n/
104+
105+
LANGUAGE_CODE = 'en-us'
106+
107+
TIME_ZONE = 'UTC'
108+
109+
USE_I18N = True
110+
111+
USE_TZ = True
112+
113+
114+
# Static files (CSS, JavaScript, Images)
115+
# https://docs.djangoproject.com/en/5.2/howto/static-files/
116+
117+
STATIC_URL = 'static/'
118+
119+
# Default primary key field type
120+
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
121+
122+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

0 commit comments

Comments
 (0)