diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index 6f042554d89f9d57434a1d5e7379d5d76b361990..f5e944e3ace8399c7e9fc038e9c80810fdc3c3aa 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -894,7 +894,7 @@ class CompoundCytotoxicityResultBaseInlineNestedFormSet(BaseInlineNestedFormSet) continue # if the form is empty - if not (form.has_changed() or 'compound_name' in form.cleaned_data): + if not (form.has_changed() and 'compound_name' in form.cleaned_data): continue compound_name = form.cleaned_data['compound_name'] @@ -1095,7 +1095,7 @@ class CompoundPKResultBaseInlineNestedFormSet(BaseInlineNestedFormSet): continue # if the form is empty - if not (form.has_changed() or 'compound_name' in form.cleaned_data): + if not (form.has_changed() and 'compound_name' in form.cleaned_data): continue compound_name = form.cleaned_data['compound_name'] diff --git a/ippisite/ippidb/tests_contribute.py b/ippisite/ippidb/tests_contribute.py index fe2e8c8ce21f3e8a09600b99d83e798e5dad771c..c83e03f07076b7e7d49508b98993168db44514e8 100644 --- a/ippisite/ippidb/tests_contribute.py +++ b/ippisite/ippidb/tests_contribute.py @@ -58,6 +58,16 @@ class ContributionViewsTestCase(TestCase): models.TestActivityDescription.objects.count() + len(entry_data.get("activity_tests", [])), "Activity tests count", ), + ( + models.TestCytotoxDescription.objects.count, + models.TestCytotoxDescription.objects.count() + len(entry_data.get("cytotox_tests", [])), + "Cytotox tests count", + ), + ( + models.TestPKDescription.objects.count, + models.TestPKDescription.objects.count() + len(entry_data.get("pharmacokinetic_tests", [])), + "Pharmacokinetic tests count", + ), ] self._process_contribution_wizard_without_sanity_check(entry_data) for fcn, results, msg in future_expected_equals: @@ -255,6 +265,18 @@ class ContributionViewsTestCase(TestCase): "MIN_NUM_FORMS": 1, "MAX_NUM_FORMS": 1000, } + for idx, cytotox_test in enumerate(entry_data.get("cytotox_tests", [])): + data[f"{idx}-test_name"] = cytotox_test["test_name"] + data[f"{idx}-compound_concentration"] = cytotox_test["compound_concentration"] + data[f"{idx}-cell_line_name"] = cytotox_test["cell_line_name"] + + data[f"{idx}-compoundcytotoxicityresult_set-cytotox-results-TOTAL_FORMS"] = len(cytotox_test.get("compound_cytotox_results",[])) + data[f"{idx}-compoundcytotoxicityresult_set-cytotox-results-INITIAL_FORMS"] = 0 + data[f"{idx}-compoundcytotoxicityresult_set-cytotox-results-MIN_NUM_FORMS"] = 0 + data[f"{idx}-compoundcytotoxicityresult_set-cytotox-results-MAX_NUM_FORMS"] = 1000 + for nidx, result in enumerate(cytotox_test["compound_cytotox_results"]): + data[f"{idx}-compoundcytotoxicityresult_set-cytotox-results-{nidx}-compound_name"] = result["compound_name"] + data[f"{idx}-compoundcytotoxicityresult_set-cytotox-results-{nidx}-toxicity"] = result["toxicity"] return data def get_pk_description_form(): @@ -379,6 +401,108 @@ class ContributionViewsTestCase(TestCase): } self._process_contribution_wizard(entry_data) + def test_with_all_tests(self): + """ + Basic entry test + """ + entry_data = { + "source": "PM", + "id_source": "15072770", + "in_silico": True, + "pharmacokinetic": True, + "cytotox": True, + "pdb_id": "3u85", + "complexChoice": "inhibited", + "complexType": "Hetero2MerAB", + "complex": [ + { + "uniprot_id": "O00255", + "complex_type": "Partner", + "domain_pfam_acc": "PF05053", + "ppc_copy_nb": 1, + "cc_nb": 1, + "ppp_copy_nb_per_p": "", + }, + { + "uniprot_id": "Q03164", + "complex_type": "Bound", + "domain_pfam_acc": "PF05965", + "ppc_copy_nb": 1, + "cc_nb": 1, + "ppp_copy_nb_per_p": 1, + }, + ], + "family_name": "BCL2-Like+/+BAX", + "compounds": [ + { + "molecule_smiles": "CCC", + "compound_name": "toto", + "common_name": "super", + } + ], + "activity_tests": [ + { + "test_name": "test", + "is_primary": True, + "protein_bound_construct": "F", + "test_type": "BIOCH", + "test_modulation_type": "I", + "nb_active_compounds": 2, + "cell_line_name": "", + # means first in the list above + "protein_complex": "2", + "compound_activity_results": [ + { + "compound_name": "toto", + "activity_type": "pIC50", + "activity": 6.85, + "inhibition_percentage": "", + "modulation_type": "I", + } + ], + } + ], + "pharmacokinetic_tests": [ + { + "test_name": "test", + "organism": 1, + "administration_mode": "IV", + "concentration": "1.2", + "dose": "3.5", + "dose_interval": "2", + "cell_line_name": "1043SK ", + # means position in the list above + "compound_pk_results": [ + { + "tolerated": "True", + "auc": "1", + "clearance": "1.2", + "c_max": "5.2", + "oral_bioavailability": "22", + "t_demi": "5", + "t_max": "5", + "voldistribution": "5.5", + "compound_name": "toto", + } + ], + } + ], + "cytotox_tests": [ + { + "test_name": "test", + "compound_concentration": "2", + "cell_line_name": "1043SK ", + "compound_cytotox_results": [ + { + "compound_name": "toto", + "toxicity": "True", + }, + ], + } + ], + } + self._process_contribution_wizard(entry_data) + def test_complex_no_pfam(self): """ Test that it is possible to not select any domain @@ -452,7 +576,6 @@ class ContributionViewsTestCase(TestCase): "id_source": "26958703", "in_silico": True, "in_vitro": True, - "pharmacokinetic": True, "xray": True, "pdb_id": "3emh", "complexChoice": "inhibited", @@ -520,31 +643,6 @@ class ContributionViewsTestCase(TestCase): ], } ], - "pharmacokinetic_tests": [ - { - "test_name": "test", - "organism": 1, - "administration_mode": "IV", - "concentration": "1.2", - "dose": "3.5", - "dose_interval": "2", - "cell_line_name": "1043SK ", - # means position in the list above - "compound_pk_results": [ - { - "tolerated": "True", - "auc": "1", - "clearance": "1.2", - "c_max": "5.2", - "oral_bioavailability": "22", - "t_demi": "5", - "t_max": "5", - "voldistribution": "5.5", - "compound_name": "16d", - } - ], - } - ], } self._process_contribution_wizard(entry_data)