secondary structure restraints for md and remd
[django_unres.git] / django_simple / todo / forms.py
index 8fda381..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
@@ -22,7 +30,7 @@ def pdb_missing_res(file):
                else:
                  msg = 'chain breaks between residues '+\
                    str(ires[-1])+' and '+str(i)+\
-                   ', server cannot add missing residues to PDB file'
+                   ', server cannot add missing residues to PDB file - please repair the structure using e.g. Modeller'
                  break
       if line[0:3] == 'TER':
                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,
@@ -254,6 +267,7 @@ class TaskForm_md_a(forms.Form):
                   help_text='coupling to the thermal bath (Berendsen)')
      md_scal_fric = forms.FloatField(label='scal_froc',initial=0.02,
                   help_text='scaling of the friction coefficients (Langevin)')
+     md_respa = forms.BooleanField(required=False,initial=True,label='RESPA')
      md_mdpdb = forms.BooleanField(required=False,label='trajectory as PDB')
 
      boxx = forms.FloatField(label='Box X',initial=1000.0,
@@ -271,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'
@@ -300,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)
@@ -373,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,
@@ -403,6 +426,8 @@ class TaskForm_remd_a(forms.Form):
 #     remd_traj1file = forms.BooleanField(required=False,label='single trajectory file',initial='true')
 #     remd_rest1file = forms.BooleanField(required=False,label='single restart file',initial='true')
 
+     md_respa = forms.BooleanField(required=False,initial=True,label='RESPA')
+
      boxx = forms.FloatField(label='Box X',initial=1000.0,
                        help_text='box x dimension')
      boxy = forms.FloatField(label='Box Y',initial=1000.0,
@@ -411,6 +436,16 @@ class TaskForm_remd_a(forms.Form):
                        help_text='box z dimension')
 
 
+     wsaxs = forms.FloatField(label='SAXS weight',initial=100.0,
+                            help_text='weight for SAXS restraint term')
+     scal_rad = forms.FloatField(label='Scal_rad (SAXS)',initial=1.0,
+                            help_text='downscaling factor of residue radii used in SAXS restraints')
+     saxs_data = forms.CharField(label='P(r) SAXS data',
+                     help_text='distance distribution from SAXS, two columns: r and P(r)',
+                     required=False,
+                     widget=forms.Textarea(attrs={'cols': 25, 'rows': 20}))
+
+
      def clean(self):
              cleaned_data = super(TaskForm_remd_a, self).clean()
 
@@ -419,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'
@@ -449,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):