Commit 2af7683b authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

remove the need to specify "protein bound construct" in Test step

the value for the field is:
- automatically deducted if there is only one ProteinDomainBoundComplex
  in the PPI
- NULL otherwise

WIP on #204
parent 0e1b6ab0
Pipeline #28993 passed with stages
in 10 minutes and 56 seconds
......@@ -1053,13 +1053,6 @@ class TestActivityDescriptionForm(forms.ModelForm):
required=False,
)
protein_complex = forms.ModelChoiceField(
queryset=models.Protein.objects.none(),
label=_("protein_domain_bound_complex_label"),
help_text=_("protein_domain_bound_complex_help_text"),
required=True,
)
class Meta:
model = models.TestActivityDescription
fields = "__all__"
......@@ -1115,13 +1108,6 @@ class TestActivityDescriptionForm(forms.ModelForm):
name=self.cleaned_data["cell_line_name"]
)
self.instance.cell_line = cell_line
if "protein_complex" in self.cleaned_data:
try:
self.instance.protein_domain_bound_complex = self.complexes[
self.cleaned_data["protein_complex"].pk
]
except KeyError:
pass
return super().save(commit=commit)
......@@ -1148,13 +1134,6 @@ class TestActivityDescriptionBaseModelFormSet(BaseInlineNestedFormSet):
)
form.nested.set_compound_names(self.__compound_names)
form.nested.set_modulation_type(self.__modulation_type)
form.fields["protein_complex"].queryset = models.Protein.objects.filter(
id__in=self.__protein_subset_ids
)
if models.Protein.objects.filter(id__in=self.__protein_subset_ids).count() == 1:
form.fields["protein_complex"].initial = models.Protein.objects.filter(
id__in=self.__protein_subset_ids
).first()
def set_compound_names(self, compound_names):
"""
......@@ -1173,15 +1152,15 @@ class TestActivityDescriptionBaseModelFormSet(BaseInlineNestedFormSet):
"""
self.__protein_subset_ids = protein_subset_ids
def set_complexes(self, complexes):
def set_complex(self, protein_domain_bound_complex):
"""
Provided to the form the complexes dictionary received from the wizard
Set the protein domain bound complex for all the form instances in the formset
:param complexes:
:return:
"""
for form in self.forms:
form.complexes = complexes
form.instance.protein_domain_bound_complex = protein_domain_bound_complex
def set_compounds(self, compounds):
"""
......
# Generated by Django 2.2.1 on 2020-04-23 20:19
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('ippidb', '0051_remove_testactivitydescription_protein_bound_construct'),
]
operations = [
migrations.AlterField(
model_name='testactivitydescription',
name='protein_domain_bound_complex',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ippidb.ProteinDomainBoundComplex'),
),
]
......@@ -1014,7 +1014,7 @@ class TestActivityDescription(models.Model):
)
biblio = models.ForeignKey(Bibliography, on_delete=models.CASCADE)
protein_domain_bound_complex = models.ForeignKey(
ProteinDomainBoundComplex, on_delete=models.CASCADE
ProteinDomainBoundComplex, on_delete=models.CASCADE, null=True, blank=True
)
ppi = models.ForeignKey(Ppi, models.CASCADE, blank=True, null=True)
test_type = models.CharField(
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '2'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '2'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '2'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '2'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '2'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '1'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 1
protein_complex: '1'
test_modulation_type: B
test_name: biolayer interferometry assay
test_type: BIOCH
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '1'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -33,7 +33,6 @@ activity_tests:
test_modulation_type: I
nb_active_compounds: 1
cell_line_name: ''
protein_complex: '1'
compound_activity_results:
- activity_mol: 6
activity_type: pIC50
......@@ -46,7 +45,6 @@ activity_tests:
test_modulation_type: I
nb_active_compounds: 1
cell_line_name: 'Human small-cell lung cancer'
protein_complex: '1'
compound_activity_results:
- activity_mol: 20
activity_type: "KdRat"
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: S
is_primary: true
nb_active_compounds: 2
protein_complex: '1'
test_modulation_type: I
test_name: pull down
test_type: BIOCH
......
......@@ -30,7 +30,6 @@ activity_tests:
test_name: Fluorescence Polarization
test_modulation_type: B
nb_active_compounds: 1
protein_complex: '1'
compound_activity_results:
- activity_mol: 20
activity_type: pKd
......
......@@ -8,7 +8,6 @@ activity_tests:
modulation_type: I
is_primary: true
nb_active_compounds: 2
protein_complex: '2'
test_modulation_type: I
test_name: test
test_type: BIOCH
......
......@@ -369,7 +369,6 @@ class ContributionE2ETestCase(TestCase):
]
if "cell_line_name" in activity_test:
data[f"{idx}-cell_line_name"] = activity_test["cell_line_name"]
data[f"{idx}-protein_complex"] = activity_test["protein_complex"]
data[
f"{idx}-compoundactivityresult_set-activity-results-TOTAL_FORMS"
] = 1 # len(activity_test.get("compound_activity_results",[]))
......
......@@ -489,7 +489,13 @@ class IppiWizard(
# Step 8.1 Activity Tests
# We set the dicts to translates attributes into model
form_dict["ActivityDescriptionFormSet"].set_complexes(complexes)
bound_complexes = [
protein_domain_complex
for protein_domain_complex in complexes.values()
if isinstance(protein_domain_complex, models.ProteinDomainBoundComplex)
]
if len(bound_complexes) == 1:
form_dict["ActivityDescriptionFormSet"].set_complex(bound_complexes[0])
form_dict["ActivityDescriptionFormSet"].set_compounds(compounds)
# We set the constants attributes among the instances to be created by the modelformset
form_dict["ActivityDescriptionFormSet"].instance = dict(
......
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