0068_auto_20210310_1052.py 1.93 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Generated by Django 2.2.1 on 2021-03-10 10:52

from django.db import migrations, models


def init_isolevel(apps, schema_editor):
    Chain = apps.get_model("ippidb", "Chain")
    InteractFile = apps.get_model("ippidb", "InteractFile")
    Chains = Chain.objects.all()
    if Chains:
        for Chain in Chains:
            Chain.default_isolevel = 0.5
            Chain.save()
    InteractFiles = InteractFile.objects.all()
    if InteractFiles:
        for InteractFile in InteractFiles:
            if InteractFile.label == "all":
                InteractFile.default_isolevel = 0.7
                InteractFile.save()
            if InteractFile.label == "hydrophobic":
                InteractFile.default_isolevel = 0.3
                InteractFile.save()
            if InteractFile.label == "hbond donor-acceptor":
                InteractFile.default_isolevel = 0.3
                InteractFile.save()
            if InteractFile.label == "negative":
                InteractFile.default_isolevel = 0.08
                InteractFile.save()
            if InteractFile.label == "positive":
                InteractFile.default_isolevel = 0.05
                InteractFile.save()
            if InteractFile.label == "backbone":
                InteractFile.default_isolevel = 0.18
                InteractFile.save()


class Migration(migrations.Migration):

    dependencies = [
        ("ippidb", "0067_metainformation_normalize_factor"),
    ]

    operations = [
        migrations.AddField(
            model_name="chain",
            name="default_isolevel",
            field=models.FloatField(default=0.7, verbose_name="Default isolevel value"),
        ),
        migrations.AddField(
            model_name="interactfile",
            name="default_isolevel",
            field=models.FloatField(default=0.7, verbose_name="Default isolevel value"),
        ),
        migrations.RunPython(init_isolevel, reverse_code=migrations.RunPython.noop),
    ]