secondary structure restraints for md and remd
[django_unres.git] / django_simple / todo / forms.py
index 16d942a..c0b1667 100644 (file)
@@ -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):