Commit b03ff67d authored by Rachel TORCHET's avatar Rachel TORCHET
Browse files

Merge branch 'master' of gitlab.pasteur.fr:ippidb/ippidb-web

parents c38e1f80 97f9141b
Pipeline #28868 passed with stages
in 18 minutes and 31 seconds
......@@ -2,7 +2,7 @@ CELERYD_NODES="worker"
CELERY_BIN="/usr/local/bin/celery"
CELERY_APP="ippisite"
CELERYD_CHDIR="/home/ippidb/ippidb-web-{{ http_port }}/ippisite"
CELERYD_OPTS="--time-limit=3000 --concurrency=1 --max-tasks-per-child=1"
CELERYD_OPTS="--time-limit=172800 --concurrency=1 --max-tasks-per-child=1"
CELERYD_LOG_FILE="/var/ippidb-{{ http_port }}-celery/celery%n%I.log"
CELERYD_PID_FILE="/var/ippidb-{{ http_port }}-celery/celery%n.pid"
CELERYD_LOG_LEVEL="DEBUG"
......
......@@ -844,7 +844,7 @@ class CompoundActivityResultForm(ModelForm):
activity_unit = forms.CharField(
label="Activity unit",
max_length=5,
required=True,
required=False,
widget=widgets.Select(
choices=(
(None, "-----"),
......@@ -855,6 +855,7 @@ class CompoundActivityResultForm(ModelForm):
("1e-12", "pmol"),
),
),
help_text="Only required if 'activity type' is not Kd ratio.",
)
class Meta:
......@@ -896,20 +897,27 @@ class CompoundActivityResultForm(ModelForm):
return cleaned_data
if cleaned_data["activity_mol"] is None:
return cleaned_data
if cleaned_data["activity_unit"] in (None, ""):
self.add_error("activity_unit", "Unit must be provided")
if (
cleaned_data.get("activity_unit", "") == ""
and cleaned_data.get("activity_type", None) != "KdRat"
):
self.add_error("activity_unit", "Unit is required if type is not Kd ratio")
return cleaned_data
try:
d = Decimal(
-log10(
Decimal(self.cleaned_data["activity_mol"])
* Decimal(self.cleaned_data["activity_unit"])
if self.cleaned_data["activity_type"] != "KdRat":
d = Decimal(
-log10(
Decimal(self.cleaned_data["activity_mol"])
* Decimal(self.cleaned_data["activity_unit"])
)
)
)
d = d.quantize(
Decimal(10) ** -self.instance._meta.get_field("activity").decimal_places
)
self.cleaned_data["activity"] = d
d = d.quantize(
Decimal(10)
** -self.instance._meta.get_field("activity").decimal_places
)
self.cleaned_data["activity"] = d
else:
self.cleaned_data["activity"] = self.cleaned_data["activity_mol"]
except Exception as e:
self.add_error(
"activity_mol",
......@@ -945,6 +953,7 @@ class CompoundActivityResultBaseInlineNestedFormSet(BaseInlineNestedFormSet):
("pEC50", "EC50 (half maximal effective concentration)"),
("pKd", "Kd (dissociation constant)"),
("pKi", "Ki (inhibition constant)"),
("KdRat", "Kd ratio (Kd w/o ligand / Kd with ligand"),
]
def add_fields(self, form, index):
......
# Generated by Django 2.2.1 on 2020-04-20 20:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ippidb', '0049_auto_20200419_2005'),
]
operations = [
migrations.AlterField(
model_name='compoundactivityresult',
name='activity_type',
field=models.CharField(choices=[('pIC50', 'pIC50 (half maximal inhibitory concentration, -log10)'), ('pEC50', 'pEC50 (half maximal effective concentration, -log10)'), ('pKd', 'pKd (dissociation constant, -log10)'), ('pKi', 'pKi (inhibition constant, -log10)'), ('KdRat', 'Kd ratio (Kd without/with ligand')], max_length=5, verbose_name='Activity type'),
),
]
......@@ -1078,6 +1078,7 @@ class CompoundActivityResult(models.Model):
("pEC50", "pEC50 (half maximal effective concentration, -log10)"),
("pKd", "pKd (dissociation constant, -log10)"),
("pKi", "pKi (inhibition constant, -log10)"),
("KdRat", "Kd ratio (Kd without/with ligand"),
)
compound = models.ForeignKey(Compound, models.CASCADE)
test_activity_description = models.ForeignKey(
......
......@@ -41,7 +41,7 @@
{{form.common_name.label}}
</label>
</div>
{%if form.show_is_a_ligand != None %}
{%if form.ligand_id != None %}
<div class="input-inline">
<input type="text" name="{{form.ligand_id.html_name}}"
{%if form.ligand_id.value %}value="{{form.ligand_id.value}}" {%endif%}
......
......@@ -49,9 +49,8 @@ activity_tests:
cell_line_name: 'Human small-cell lung cancer'
protein_complex: '1'
compound_activity_results:
- activity_mol: 61
activity_type: pIC50
activity_unit: 1e-9
- activity_mol: 20
activity_type: "KdRat"
compound_name: 'compound 12'
modulation_type: I
\ No newline at end of file
......@@ -149,10 +149,15 @@ class ContributionE2ETestCase(TestCase):
"activity_mol" in compound_activity_results
and compound_activity_results["activity_mol"] != ""
):
compound_activity_results["activity"] = -math.log10(
Decimal(str(compound_activity_results["activity_mol"]))
* Decimal(str(compound_activity_results["activity_unit"]))
)
if compound_activity_results["activity_type"] != "KdRat":
compound_activity_results["activity"] = -math.log10(
Decimal(str(compound_activity_results["activity_mol"]))
* Decimal(str(compound_activity_results["activity_unit"]))
)
else:
compound_activity_results["activity"] = Decimal(
str(compound_activity_results["activity_mol"])
)
self._process_contribution_wizard_without_sanity_check(entry_data)
......@@ -574,15 +579,6 @@ class ContributionE2ETestCase(TestCase):
and activity_test["cell_line_name"] != ""
):
tad_filters["cell_line__name"] = activity_test["cell_line_name"]
for tad in models.TestActivityDescription.objects.all():
print(
tad.test_type,
tad.test_name,
tad.protein_bound_construct,
tad.test_modulation_type,
tad.nb_active_compounds,
tad.cell_line,
)
test_activity_description = models.TestActivityDescription.objects.get(
**tad_filters
)
......@@ -625,4 +621,5 @@ class ContributionE2ETestCase(TestCase):
"""
with NamedTemporaryFile(delete=False, suffix=".html") as f:
f.write(response.content)
print(response.content)
return f.name
......@@ -395,15 +395,7 @@ class IppiWizard(
bibliography.autofill()
return bibliography
if self.steps.current == "ProteinDomainComplexTypeForm":
print (
"blablabla",
self.storage.get_step_data("PDBForm").get("PDBForm-proteins"),
)
protein_ids = self.storage.get_step_data("PDBForm").get("PDBForm-proteins")
print (
"blablabla",
self.storage.get_step_data("PDBForm").get("PDBForm-proteins"),
)
return models.Protein.objects.filter(id__in=protein_ids)
def get_template_names(self):
......@@ -583,7 +575,7 @@ def admin_session_view(request, biblio_pk, ppi_pk, contribution_pk=None):
contribution = get_object_or_404(models.Contribution, pk=contribution_pk)
bibliography = contribution.bibliography
ppi = contribution.ppi
context["contribution"] = contribution
context["contribution"] = contribution
else:
bibliography = None
ppi = None
......
Supports Markdown
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