diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index 29892e0bd5311ee7283a1326c87cdcc9e9df025a..8b8d64f5622ce12c4237a5c609721112ee6bb5be 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -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): """ diff --git a/ippisite/ippidb/migrations/0052_auto_20200423_2019.py b/ippisite/ippidb/migrations/0052_auto_20200423_2019.py new file mode 100644 index 0000000000000000000000000000000000000000..e25caeff611dac47a48882b0478e4f4f69e64e60 --- /dev/null +++ b/ippisite/ippidb/migrations/0052_auto_20200423_2019.py @@ -0,0 +1,19 @@ +# 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'), + ), + ] diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 93733c7bee2aef1490759ad34dfca2c0f94832df..43e189f83bc0f39027568587f791026c4052a70e 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -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( diff --git a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_2380_002_e-9.yaml b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_2380_002_e-9.yaml index 61828344ddefb8c47d163b42fa6620df8b15aa0a..d23e8c9a7d11e94ced63753499e8129ef5fbcad1 100644 --- a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_2380_002_e-9.yaml +++ b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_2380_002_e-9.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_4_9846073_e-6.yaml b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_4_9846073_e-6.yaml index 1206c5300107827a7bf7e42bb8b334f109bce52c..963453ff916c5671abe90aa1a69dc0f6e5c655ab 100644 --- a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_4_9846073_e-6.yaml +++ b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_4_9846073_e-6.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_639_39406_e-3.yaml b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_639_39406_e-3.yaml index 306f48ab4f4e5edd11f77ce10281979ac1a6bbcd..8dd666a74fe8f9106e69b46166e717156c4bca40 100644 --- a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_639_39406_e-3.yaml +++ b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_639_39406_e-3.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_6_85_e-0.yaml b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_6_85_e-0.yaml index eb93af6d979d60af273e12bf718ee02026fa7cbd..a11ee0b690e376ef4253a0d0571575582f3fed1f 100644 --- a/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_6_85_e-0.yaml +++ b/ippisite/ippidb/tests/test_activity_computation_and_storage_pIC50_6_85_e-0.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_basic_entry.yaml b/ippisite/ippidb/tests/test_basic_entry.yaml index 6f28b468b4f39c34c7678855243ecbef4f820d98..af3ac0d2a90e95ef8d83cf1c348a2d3f0946af0c 100644 --- a/ippisite/ippidb/tests/test_basic_entry.yaml +++ b/ippisite/ippidb/tests/test_basic_entry.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_complex_no_pfam.yaml b/ippisite/ippidb/tests/test_complex_no_pfam.yaml index cc7429b468a22b53b2a7843a7c7d61be3015a34b..9ff962bf4fae400a8dc91f2f37d0ddff0233227c 100644 --- a/ippisite/ippidb/tests/test_complex_no_pfam.yaml +++ b/ippisite/ippidb/tests/test_complex_no_pfam.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_entry_28.yaml b/ippisite/ippidb/tests/test_entry_28.yaml index 7fddcc4b3e6c9d4bc2d1028b0d197f6e3105407f..5923d9523d70ffdda832aea5ce80f94c55319a23 100644 --- a/ippisite/ippidb/tests/test_entry_28.yaml +++ b/ippisite/ippidb/tests/test_entry_28.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_simple_heterodimer.yaml b/ippisite/ippidb/tests/test_simple_heterodimer.yaml index 72cd7db1ececc61f71d004abaae8b4fcc9b317ff..31762772d1822d48aba3bb24f3cbd84864c7dd24 100644 --- a/ippisite/ippidb/tests/test_simple_heterodimer.yaml +++ b/ippisite/ippidb/tests/test_simple_heterodimer.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_simple_heterodimer_208.yaml b/ippisite/ippidb/tests/test_simple_heterodimer_208.yaml index a3c8e2a874054d4d8a55df6d5cb90fba49f61f77..84608560d331b79483534668f836e6005f4c987f 100644 --- a/ippisite/ippidb/tests/test_simple_heterodimer_208.yaml +++ b/ippisite/ippidb/tests/test_simple_heterodimer_208.yaml @@ -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" diff --git a/ippisite/ippidb/tests/test_simple_stabilized_heterodimer.yaml b/ippisite/ippidb/tests/test_simple_stabilized_heterodimer.yaml index 57c5b9236cb1275a6304ead85260cf8b4c609bbb..3dc5abcd9777d0071b571fc4513c95b311e41a4b 100644 --- a/ippisite/ippidb/tests/test_simple_stabilized_heterodimer.yaml +++ b/ippisite/ippidb/tests/test_simple_stabilized_heterodimer.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_stabilizer_204.yaml b/ippisite/ippidb/tests/test_stabilizer_204.yaml index e7d9d13a1638fe9d2a596d55c857f2a5d3e77d5e..32e3ded658e247ef496275ba8f0e5a63f38f1854 100644 --- a/ippisite/ippidb/tests/test_stabilizer_204.yaml +++ b/ippisite/ippidb/tests/test_stabilizer_204.yaml @@ -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 diff --git a/ippisite/ippidb/tests/test_with_all_tests.yaml b/ippisite/ippidb/tests/test_with_all_tests.yaml index 26fc81b4ca5037bec288f98b12aacb2ff5365d6c..154992d54674d638c69474d0d467e366f227c978 100644 --- a/ippisite/ippidb/tests/test_with_all_tests.yaml +++ b/ippisite/ippidb/tests/test_with_all_tests.yaml @@ -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 diff --git a/ippisite/ippidb/tests/tests_contribute_e2e.py b/ippisite/ippidb/tests/tests_contribute_e2e.py index ad6959b049e379b8b540ce11bd4b54ca1b608d9c..09c8983fde9efe969cf90595573934c561a39c49 100644 --- a/ippisite/ippidb/tests/tests_contribute_e2e.py +++ b/ippisite/ippidb/tests/tests_contribute_e2e.py @@ -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",[])) diff --git a/ippisite/ippidb/views/contribute.py b/ippisite/ippidb/views/contribute.py index 6e88540f4d696272fe124bbefcc764506641c174..31e28ae6f31968aa2e1eb219b5d1323dc75c10e9 100644 --- a/ippisite/ippidb/views/contribute.py +++ b/ippisite/ippidb/views/contribute.py @@ -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(