Skip to content
Snippets Groups Projects
Commit a670b417 authored by Rachel TORCHET's avatar Rachel TORCHET
Browse files

Update of CompoundForm ad ProteinDomainComplexForm

Former-commit-id: b5c77033eeee60f02d839d0f2b3c7f8227cf4078
parent e1c3aa10
No related branches found
No related tags found
No related merge requests found
...@@ -107,13 +107,18 @@ class ComplexCompositionForm(forms.Form): ...@@ -107,13 +107,18 @@ class ComplexCompositionForm(forms.Form):
complex_domain=forms.ModelChoiceField(queryset=Domain.objects.all(), required=True,widget=forms.Select(attrs={'class':'form-control'}),empty_label=None) complex_domain=forms.ModelChoiceField(queryset=Domain.objects.all(), required=True,widget=forms.Select(attrs={'class':'form-control'}),empty_label=None)
ppc_copy_nb=forms.IntegerField(initial=1,required=True,widget=forms.TextInput(attrs={'class':'form-control'})) ppc_copy_nb=forms.IntegerField(initial=1,required=True,widget=forms.TextInput(attrs={'class':'form-control'}))
def __init__(self,*args,**kwargs): def __init__(self,pks=None,*args,**kwargs):
super(ComplexCompositionForm, self).__init__(*args, **kwargs) super(ComplexCompositionForm, self).__init__(*args, **kwargs)
""" TODO : Filter based on submited PDBid""" """ TODO : Filter based on submited PDBid"""
#pks = kwargs.pop("prot")
print("<<<<<<<<<<")
print(args,kwargs)
print(">>>>>>>>>>")
self.fields['complex_protein'].queryset=Protein.objects.filter(pk__in=[569,570]) self.fields['complex_protein'].queryset=Protein.objects.filter(pk__in=[569,570])
self.fields['complex_domain'].queryset=Domain.objects.filter(pk__in=[73,73])
ComplexCompositionFormSet = formset_factory(ComplexCompositionForm, extra=2) ComplexCompositionFormSet = formset_factory(ComplexCompositionForm, extra=3)
formset= ComplexCompositionFormSet() formset= ComplexCompositionFormSet()
#print(formset.is_valid()) #print(formset.is_valid())
...@@ -164,7 +169,7 @@ class BaseCompoundFormSet(BaseFormSet): ...@@ -164,7 +169,7 @@ class BaseCompoundFormSet(BaseFormSet):
form.fields["molecule"] = forms.CharField(widget=forms.RadioSelect(choices=TYPE_MOLECULE, attrs={'class':'form-control'})) form.fields["molecule"] = forms.CharField(widget=forms.RadioSelect(choices=TYPE_MOLECULE, attrs={'class':'form-control'}))
form.fields["molecule_comp"] = forms.CharField(widget=forms.TextInput(attrs={'required':'required', 'class':'form-control'})) form.fields["molecule_comp"] = forms.CharField(widget=forms.TextInput(attrs={'required':'required', 'class':'form-control'}))
CompoundFormSet = formset_factory(CompoundForm, formset=BaseCompoundFormSet, max_num=500, can_delete=True) CompoundFormSet = formset_factory(CompoundForm, formset=BaseCompoundFormSet, extra=2, can_delete=True)
formset = CompoundFormSet() formset = CompoundFormSet()
""" Step 8 : TestsForm """ """ Step 8 : TestsForm """
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
{{ wizard.form.journal_name }} {{ wizard.form.journal_name }}
</div> </div>
<p> This publication contains :<br/></p> <p> This publication contains :<br/></p>
<div id="ck-button"> <div >
<label> <label>
<input type="checkbox"><span>{{ wizard.form.cytotox.label }}</span> <input type="checkbox"><span>{{ wizard.form.cytotox.label }}</span>
</label> </label>
......
...@@ -32,42 +32,7 @@ ...@@ -32,42 +32,7 @@
{{ wizard.form.management_form }} {{ wizard.form.management_form }}
<div class="compound"> <div class="compound">
{% for form in wizard.form.forms %} {% for form in wizard.form.forms %}
<div id="compound_{{ form.compound_name.id_for_label }}"> {{form}}
<div id="type_title">
<h1 id="Name_{{ form.compound_name.id_for_label }}">Compound</h1>
<h2>Name your compound</h2>
</div>
<div class="compound_input form-group">
{{ form.common_name }}
<label class="form-control-placeholder">Common name</label>
</div>
<div class="compound_input form-group">
{{ form.compound_name }}
<label class="form-control-placeholder">Name in biblio</label>
</div>
<div id="type_title">
<h2>Choose a format to import your molecule</h2>
</div>
<div id="compound_mol">
{% for radio in form.molecule %}
<div class="compound_radio_{{ radio.choice_label }}">
{{ radio.tag }}
<label for="{{ radio.id_for_label }}">
<span>{{ radio.choice_label }}</span>
</label>
</div>
{% endfor %}
</div>
<div class="compound_input form-group" id="molecule_comp_{{ form.molecule.id_for_label }}">
{{form.molecule_comp}}
<label class="form-control-placeholder">Molecule composition</label>
</div>
<div id="ck-button-long">
<label>{{ form.is_macrocycle}}<span>{{ form.is_macrocycle.label }}</span></label>
</div>
</div>
<input type="button" id="ck-button-long" class="add_button" onclick="addComp('{{ form.compound_name.id_for_label }}');" value="Add Compound">
</input>
{% endfor %} {% endfor %}
</div> </div>
......
...@@ -34,19 +34,19 @@ ...@@ -34,19 +34,19 @@
{{ wizard.form.management_form }} {{ wizard.form.management_form }}
{% for form in wizard.form.forms %} {% for form in wizard.form.forms %}
<div class="inline_box_complex_long"> <div class="inline_box_complex_long">
<div class="input_field form-group"> <div class="input_field form-group">
{{ form.complex_type }} {{ form.complex_type }}
<label class="form-control-placeholder">Complex type</label> <label class="form-control-placeholder">Complex type</label>
</div> </div>
<div class="input_field form-group"> <div class="input_field form-group">
{{ form.complex_protein }} {{ form.complex_protein }}
<label class="form-control-placeholder">Protein</label> <label class="form-control-placeholder">Protein</label>
</div> </div>
<div class="input_field form-group"> <div class="input_field form-group">
{{ form.complex_domain }} {{ form.complex_domain }}
<label class="form-control-placeholder">Domain</label> <label class="form-control-placeholder">Domain</label>
</div> </div>
<div class="input_field form-group"> <div class="input_field form-group">
{{ form.ppc_copy_nb }} {{ form.ppc_copy_nb }}
<label class="form-control-placeholder">Number of copies of the protein in the complex</label> <label class="form-control-placeholder">Number of copies of the protein in the complex</label>
</div> </div>
......
...@@ -73,14 +73,14 @@ TEMPLATES = {"IdForm": "IdForm.html", ...@@ -73,14 +73,14 @@ TEMPLATES = {"IdForm": "IdForm.html",
"PDBForm": "PDBForm.html", "PDBForm": "PDBForm.html",
"ProteinDomainComplexTypeForm": "ProteinDomainComplexTypeForm.html", "ProteinDomainComplexTypeForm": "ProteinDomainComplexTypeForm.html",
"ProteinDomainComplexForm": "ProteinDomainComplexForm.html", "ProteinDomainComplexForm": "ProteinDomainComplexForm.html",
"PpiForm": "PpiForm.html", "PpiForm": "PpiForm.html",
"CompoundForm":"CompoundForm.html", "CompoundForm":"CompoundForm.html",
"TestsForm":"TestsForm.html", "TestsForm":"TestsForm.html",
} }
class IppiWizard(NamedUrlSessionWizardView): class IppiWizard(NamedUrlSessionWizardView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context=super(IppiWizard, self).get_context_data(**kwargs) context=super(IppiWizard, self).get_context_data(**kwargs)
if self.steps.current == 'BibliographyForm': if self.steps.current == 'BibliographyForm':
...@@ -95,18 +95,22 @@ class IppiWizard(NamedUrlSessionWizardView): ...@@ -95,18 +95,22 @@ class IppiWizard(NamedUrlSessionWizardView):
context['complex_choice']=self.storage.get_step_data('ProteinDomainComplexTypeForm').get('ProteinDomainComplexTypeForm-complexChoice') context['complex_choice']=self.storage.get_step_data('ProteinDomainComplexTypeForm').get('ProteinDomainComplexTypeForm-complexChoice')
context['complex_type']=self.storage.get_step_data('ProteinDomainComplexTypeForm').get('ProteinDomainComplexTypeForm-complexType') context['complex_type']=self.storage.get_step_data('ProteinDomainComplexTypeForm').get('ProteinDomainComplexTypeForm-complexType')
context['pdb_id']=self.storage.get_step_data('PDBForm').get('PDBForm-pdb_id') context['pdb_id']=self.storage.get_step_data('PDBForm').get('PDBForm-pdb_id')
return context return context
def get_form_initial(self, step): def get_form_initial(self, step):
# Works for form.forms
initial = {} initial = {}
# Pre-fill fields with data from a previous form # Pre-fill fields with data from a previous form
if step == 'ProteinDomainComplexForm': if step == 'ProteinDomainComplexForm':
pks = self.storage.get_step_data('PDBForm').get('pks') pks = self.storage.get_step_data('PDBForm').get('pks')
print("Proteins",Protein.objects.filter(id__in=pks)) #initial['pks']=pks
#return {'pks':pks}
#form = ComplexCompositionForm(prot=pks)
if step == 'PpiForm': if step == 'PpiForm':
initial['pdb_id'] = self.storage.get_step_data('PDBForm').get('PDBForm-pdb_id') initial['pdb_id'] = self.storage.get_step_data('PDBForm').get('PDBForm-pdb_id')
print(self.initial_dict)
return self.initial_dict.get(step, initial) return self.initial_dict.get(step, initial)
def process_step(self, form): def process_step(self, form):
""" """
This method overrides the one used to postprocess the form data. This method overrides the one used to postprocess the form data.
...@@ -135,8 +139,9 @@ class IppiWizard(NamedUrlSessionWizardView): ...@@ -135,8 +139,9 @@ class IppiWizard(NamedUrlSessionWizardView):
protein_ids.append(p.id) protein_ids.append(p.id)
data['pks'] = protein_ids data['pks'] = protein_ids
return data return data
def get_form_instance(self, step): def get_form_instance(self, step):
# Works only for Modelform
if self.steps.current == 'BibliographyForm': if self.steps.current == 'BibliographyForm':
pk = self.storage.get_step_data('IdForm').get('pk') pk = self.storage.get_step_data('IdForm').get('pk')
return Bibliography.objects.get(pk=pk) return Bibliography.objects.get(pk=pk)
...@@ -162,7 +167,7 @@ class IppiWizard(NamedUrlSessionWizardView): ...@@ -162,7 +167,7 @@ class IppiWizard(NamedUrlSessionWizardView):
def biblio_list(request): def biblio_list(request):
bibliographies = Bibliography.objects.all() bibliographies = Bibliography.objects.all()
return render(request, 'biblio_list.html', {'bibliographies':bibliographies}) return render(request, 'biblio_list.html', {'bibliographies':bibliographies})
def biblio_card(request, source, id_source): def biblio_card(request, source, id_source):
try: try:
...@@ -170,10 +175,10 @@ def biblio_card(request, source, id_source): ...@@ -170,10 +175,10 @@ def biblio_card(request, source, id_source):
except Bibliography.DoesNotExist: except Bibliography.DoesNotExist:
raise Http404("No bibliography data for %s:%s" % (source, id_source)) raise Http404("No bibliography data for %s:%s" % (source, id_source))
refs = RefCompoundBiblio.objects.filter(bibliography_id = bibliography.id) refs = RefCompoundBiblio.objects.filter(bibliography_id = bibliography.id)
tad_ppis = TestActivityDescription.objects.filter(biblio__source=source,biblio__id_source=id_source).select_related() tad_ppis = TestActivityDescription.objects.filter(biblio__source=source,biblio__id_source=id_source).select_related()
return render(request, 'biblio_card.html', {'bibliography': bibliography, return render(request, 'biblio_card.html', {'bibliography': bibliography,
'compound_biblios': refs, 'compound_biblios': refs,
'tad_ppis': tad_ppis}) 'tad_ppis': tad_ppis})
def process_cutoff_value(name, context, request): def process_cutoff_value(name, context, request):
context[name+'_max'] = str(int(math.ceil(float(Compound.objects.all().aggregate(Max(name))[name + '__max'])))) context[name+'_max'] = str(int(math.ceil(float(Compound.objects.all().aggregate(Max(name))[name + '__max']))))
...@@ -241,8 +246,8 @@ def compound_list(request): ...@@ -241,8 +246,8 @@ def compound_list(request):
for sort_by_option_id in sort_by_option_ids: for sort_by_option_id in sort_by_option_ids:
sort_by_options[sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'ascending', 'id': sort_by_option_id} sort_by_options[sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'ascending', 'id': sort_by_option_id}
sort_by_options['-'+sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'descending', 'id': sort_by_option_id} sort_by_options['-'+sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'descending', 'id': sort_by_option_id}
fields = request.GET.getlist('fields',['id', 'common_name', 'molecular_weight', 'a_log_p', 'compound_action_pdb_ids', 'biblio_refs']) fields = request.GET.getlist('fields',['id', 'common_name', 'molecular_weight', 'a_log_p', 'compound_action_pdb_ids', 'biblio_refs'])
if 'id' not in fields: if 'id' not in fields:
fields.append('id') fields.append('id')
context['selected_ppis'] = selected_ppis context['selected_ppis'] = selected_ppis
...@@ -265,7 +270,7 @@ def compound_card(request, compound_id): ...@@ -265,7 +270,7 @@ def compound_card(request, compound_id):
compound = Compound.objects.get(id=int(compound_id)) compound = Compound.objects.get(id=int(compound_id))
except Compound.DoesNotExist: except Compound.DoesNotExist:
raise Http404("No compound data for %s:%s" % (compound_id)) raise Http404("No compound data for %s:%s" % (compound_id))
le_lle_biplot_data = LeLleBiplotData.objects.get().le_lle_biplot_data le_lle_biplot_data = LeLleBiplotData.objects.get().le_lle_biplot_data
pca_biplot = json.loads(PcaBiplotData.objects.get().pca_biplot_data) pca_biplot = json.loads(PcaBiplotData.objects.get().pca_biplot_data)
pca_biplot_data = json.dumps(pca_biplot['data']) pca_biplot_data = json.dumps(pca_biplot['data'])
pca_biplot_cc = pca_biplot['correlation_circle'] pca_biplot_cc = pca_biplot['correlation_circle']
......
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