X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=django_simple%2Ftodo%2Fforms.py;h=c0b16674c71c0d85a51d89389083242d888c214b;hb=a6e111e381a874bd15dd6dcb33fdeb18079e3286;hp=16d942abe437ecf39480a87b5d8c6fcccc601ac4;hpb=cb36b6c35942e63325f33948c429d3ca77c85306;p=django_unres.git diff --git a/django_simple/todo/forms.py b/django_simple/todo/forms.py index 16d942a..c0b1667 100644 --- a/django_simple/todo/forms.py +++ b/django_simple/todo/forms.py @@ -7,6 +7,14 @@ from .models import FF_CHOICE import json import urllib +def code_2d(line): + msg='' + set ='HEC-' + line2 = ''.join([c for c in line if c in set]) + if line2 != line: + msg='use only H,E,C or - letters' + return(msg) + def pdb_missing_res(file): msg='' newchain = True @@ -230,6 +238,11 @@ class TaskForm_md_a(forms.Form): 'field is ignored when uploading starting/reference PDB file', required=False, widget=forms.Textarea(attrs={'cols': 70, 'rows': 2})) + md_2d = forms.CharField(label='Secondary structure restraints', + help_text='single letter code: H - helix, E - extended/beta, C or - no restraints', + required=False, + widget=forms.Textarea(attrs={'cols': 70, 'rows': 2})) + file1 = forms.FileField(label='Upload a PDB file',required=False, help_text='starting structure for pdbstart/reference structure') pdbid = forms.CharField(min_length=4,max_length=4,required=False, @@ -272,6 +285,7 @@ class TaskForm_md_a(forms.Form): pdbid = cleaned_data.get("pdbid") md_seq = cleaned_data.get("md_seq") md_pdbref = cleaned_data.get("md_pdbref") + md_2d = cleaned_data.get("md_2d") if md_start == 'pdbstart' and not (file1 or pdbid): msg = 'pdbstart with no PDB file or code' @@ -301,7 +315,11 @@ class TaskForm_md_a(forms.Form): msg=pdb_missing_res(file1) if msg != '': self.add_error('file1',msg) - + + if md_2d: + msg=code_2d(md_2d) + if msg != '': + self.add_error('md_2d',msg) class TaskForm_remd(forms.Form): name = forms.CharField(max_length=20) @@ -374,6 +392,10 @@ class TaskForm_remd_a(forms.Form): 'field is ignored when uploading starting/reference PDB file', required=False, widget=forms.Textarea(attrs={'cols': 70, 'rows': 2})) + md_2d = forms.CharField(label='Secondary structure restraints', + help_text='single letter code: H - helix, E - extended/beta, C or - no restraints', + required=False, + widget=forms.Textarea(attrs={'cols': 70, 'rows': 2})) file1 = forms.FileField(label='Upload a PDB file',required=False, help_text='starting structure for pdbstart/reference structure') pdbid = forms.CharField(min_length=4,max_length=4,required=False, @@ -432,6 +454,7 @@ class TaskForm_remd_a(forms.Form): pdbid = cleaned_data.get("pdbid") md_seq = cleaned_data.get("md_seq") md_pdbref = cleaned_data.get("md_pdbref") + md_2d = cleaned_data.get("md_2d") if md_start == 'pdbstart' and not (file1 or pdbid): msg = 'pdbstart with no PDB file or code' @@ -462,6 +485,11 @@ class TaskForm_remd_a(forms.Form): if msg != '': self.add_error('file1',msg) + if md_2d: + msg=code_2d(md_2d) + if msg != '': + self.add_error('md_2d',msg) + class TaskForm_list(forms.Form):