1 from django import forms
2 from .models import Task
3 from .models import MIN_CHOICE
4 from .models import MD_START
5 from .models import MD_LANG
6 from .models import FF_CHOICE
7 from django.utils.safestring import mark_safe
9 from django.core.files import File
15 'DPR','DLY','DAR','DHI','DAS','DGL','DSG','DGN','DSN','DTH',
16 'DAL','DTY','DTR','DVA','DLE','DIL','DPN','MED','DCY',
17 'CYS','MET','PHE','ILE','LEU','VAL','TRP','TYR','ALA','GLY','THR',
18 'SER','GLN','ASN','GLU','ASP','HIS','ARG','LYS','PRO',
19 'SME','AIB','ABU','DBZ']
22 def pdb_code_chain(pdbid):
28 return('use : between pdb code and chain id, like 5G3Q:B to select single chain')
32 test=urllib.urlopen('http://files.rcsb.org/download/'+pdbid+'.pdb')
34 msg = 'wrong pdb code'
36 msg=pdb_missing_res_chain(test,chain)
40 def pdb_missing_res_chain(file,chain):
45 if line[0:6] == 'ATOM ' and line[13:15] == 'CA' and (line[21] == chain or chain==''):
48 if line[17:20] not in aa_3letter:
49 msg='residue '+line[17:20]+' '+str(i)+' not recognized'
51 if ires and i==ires[-1]:
53 if newchain or i==ires[-1]+1:
57 msg = 'chain breaks between residues '+\
58 str(ires[-1])+' and '+str(i)+' of chain '+ch+\
59 ', server cannot add missing residues to PDB file - please repair the structure using e.g. Modeller'
61 if line[0:3] == 'TER':
63 if line[0:3] == 'END':
68 msg='no CA atoms in this pdb'
74 def nmr_bad_cols(file):
81 lg = data[x].isdigit()
83 msg = 'NMR shifts data column '+repr(x+1)+' must be integer, not: '+data[x]
87 msg = 'There have to be 5 or more columns in NMR shifts data file'
89 promien = data[3].replace('.', '')
90 lg2 = promien.isdigit()
92 msg ='NMR shifts 4th data column must be decimal or integer radius, not: '+data[3]
94 lg3 = data[4].startswith('H') or data[4].startswith('Q')
96 msg = 'NMR shifts 5th data column must be proton designation, not: '+data[4]
99 msg = 'NMR shifts data contains blank lines. Remove them.'
107 line2 = ''.join([c for c in line if c in set])
109 msg='use only H,E,C or - letters'
113 class MultiWidgetBasic(forms.MultiWidget):
114 def __init__(self, count, attrs=None):
117 for i in range(self.count):
118 widgets.append(forms.TextInput())
119 super(MultiWidgetBasic, self).__init__(widgets, attrs)
121 template_name = 'multi.html'
123 def decompress(self, value):
125 return json.loads(value)
130 class MultiExampleField(forms.fields.MultiValueField):
131 def __init__(self, count, *args, **kwargs):
133 self.widget = MultiWidgetBasic(self.count)
135 for i in range(self.count):
136 list_fields.append(forms.fields.CharField(max_length=15))
137 super(MultiExampleField, self).__init__(list_fields, *args, **kwargs)
139 def compress(self, values):
140 ## compress list to single object
141 return json.dumps(values)
144 class TaskForm(forms.Form):
145 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
148 class TaskForm_min(forms.Form):
149 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
150 file1 = forms.FileField(label='Upload a PDB file',required=False,
151 help_text='continuous (without breaks) protein chains,use TER to divide chains')
152 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
153 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
154 label='or PDB code (:chain)')
157 cleaned_data = super(TaskForm_min, self).clean()
159 pdbid = cleaned_data.get("pdbid")
160 file1 = cleaned_data.get("file1")
162 if not pdbid and not file1:
163 msg = 'provide pdb file or pdb code'
164 self.add_error('file1', msg)
167 msg=pdb_code_chain(pdbid)
169 self.add_error('pdbid',msg)
172 msg=pdb_missing_res_chain(file1,'')
174 self.add_error('file1',msg)
177 class TaskForm_min_a(forms.Form):
178 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
180 unres_ff = forms.ChoiceField(choices=FF_CHOICE,widget=forms.RadioSelect,
181 label='Force Field',initial='FF2')
182 # min_choice = forms.ChoiceField(choices=MIN_CHOICE,label='minimization algorithm')
183 min_overlap = forms.BooleanField(required=False,label='remove overlap')
184 min_searchsc = forms.BooleanField(required=False,label='MC for sidechain overlap')
185 min_maxmin = forms.IntegerField(label='MAXMIN',initial=10000,
186 help_text='maximum number of iterations')
187 min_maxfun = forms.IntegerField(label='MAXFUN',initial=15000,
188 help_text='maximum number of function evaluations')
189 file1 = forms.FileField(label='Upload a PDB file',required=False,
190 help_text='continuous (without breaks) protein chains,use TER to divide chains')
191 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
192 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
193 label='or PDB code (:chain)')
195 min_unres_pdb = forms.BooleanField(required=False,label='uploaded input unres PDB',
196 help_text='(CA and CB atoms only, CB represents SC in UNRES)')
197 min_pdbout = forms.BooleanField(required=False,label='output PDB',initial='true')
198 boxx = forms.FloatField(label='Box X',initial=1000.0,
199 help_text='box x dimension')
200 boxy = forms.FloatField(label='Box Y',initial=1000.0,
201 help_text='box y dimension')
202 boxz = forms.FloatField(label='Box Z',initial=1000.0,
203 help_text='box z dimension')
206 cleaned_data = super(TaskForm_min_a, self).clean()
208 pdbid = cleaned_data.get("pdbid")
209 file1 = cleaned_data.get("file1")
211 if not pdbid and not file1:
212 msg = 'provide pdb file or pdb code'
213 self.add_error('file1', msg)
216 msg=pdb_code_chain(pdbid)
218 self.add_error('pdbid',msg)
221 msg=pdb_missing_res_chain(file1,'')
223 self.add_error('file1',msg)
226 class TaskForm_md(forms.Form):
227 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
229 md_start = forms.ChoiceField(choices=MD_START,widget=forms.RadioSelect,
230 label='starting structure',initial='extconf')
231 md_seq = forms.CharField(label='Sequence',
232 help_text='aminoacid sequence using one letter code<br>'+
233 'field is ignored when uploading starting/reference PDB file',
235 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
236 file1 = forms.FileField(label='Upload a PDB file',required=False,
237 help_text='starting structure for pdbstart/reference structure')
238 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
239 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
240 label='or PDB code (:chain)')
241 md_pdbref = forms.BooleanField(required=False,label='PDB reference structure')
242 md_temp = forms.FloatField(label='temperature',initial=300,
243 help_text='bath temperature')
244 md_nstep = forms.IntegerField(label='NSTEP',initial=200000,
245 help_text='total number of steps',max_value=10000000)
246 md_seed = forms.IntegerField(label='SEED',initial=-39912345,
247 help_text='seed for random number generator')
250 cleaned_data = super(TaskForm_md, self).clean()
252 md_start = cleaned_data.get("md_start")
253 file1 = cleaned_data.get("file1")
254 pdbid = cleaned_data.get("pdbid")
255 md_seq = cleaned_data.get("md_seq")
256 md_pdbref = cleaned_data.get("md_pdbref")
258 if md_start == 'pdbstart' and not (file1 or pdbid):
259 msg = 'pdbstart with no PDB file or code'
260 self.add_error('file1', msg)
262 if md_pdbref and not (file1 or pdbid):
263 msg = 'pdbref with no PDB file or code'
264 self.add_error('file1', msg)
267 if md_start != 'pdbstart' and not md_pdbref and not md_seq:
268 msg = 'extended/random chain with no sequence'
269 self.add_error('md_seq', msg)
272 msg=pdb_code_chain(pdbid)
274 self.add_error('pdbid',msg)
277 msg=pdb_missing_res_chain(file1,'')
279 self.add_error('file1',msg)
282 class TaskForm_md_a(forms.Form):
283 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
285 unres_ff = forms.ChoiceField(choices=FF_CHOICE,widget=forms.RadioSelect,
286 label='Force Field',initial='FF2')
287 md_start = forms.ChoiceField(choices=MD_START,widget=forms.RadioSelect,
288 label='starting structure',initial='extconf')
289 md_seq = forms.CharField(label='Sequence',
290 help_text='aminoacid sequence using one letter code<br>'+
291 'field is ignored when uploading starting/reference PDB file',
293 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
294 md_2d = forms.CharField(label='Secondary structure restraints',
295 help_text='single letter code: H helix, E extended/beta, C or - no restraints',
297 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
300 use_nmr = forms.BooleanField(required=False,label='use NMR restraints',
301 help_text='this option requires the next four fields to be set.')
302 file3 = forms.FileField(label='Upload a NMR restraints file',required=False,
303 help_text='at least 5 columns required: 49 22 1 5.0 HD2 H; <i>Hint: if you are using <u>NMR example data</u> then the field will be filled out automatically</i>')
304 nmr_scal = forms.IntegerField(label='NMR option: scal_peak',initial=20)
305 nmr_fordepth = forms.FloatField(label='NMR option: FORDEPTH_PEAK',initial=0.5)
306 nmr_slope = forms.FloatField(label='NMR option: SLOPE_PEAK',initial=0.05)
307 file1 = forms.FileField(label='Upload a PDB file',required=False,
308 help_text='starting structure for pdbstart/reference structure; <i>Hint: if you are using <u>NMR example data</u> then the field will be filled out automatically</i>')
310 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
311 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
312 label='or PDB code (:chain)')
313 md_pdbref = forms.BooleanField(required=False,label='PDB reference structure')
314 md_temp = forms.FloatField(label='temperature',initial=300,
315 help_text='bath temperature')
316 md_nstep = forms.IntegerField(label='NSTEP',initial=200000,
317 help_text='total number of steps',max_value=10000000)
318 md_seed = forms.IntegerField(label='SEED',initial=-39912345,
319 help_text='seed for random number generator')
321 md_ntwe = forms.IntegerField(label='NTWE',initial=1000,
322 help_text='write statfile every ntwe steps')
323 md_ntwx = forms.IntegerField(label='NTWX',initial=1000,
324 help_text='write trajectory every ntwe steps',min_value=100)
325 md_dt = forms.FloatField(label='DT',initial=0.2,
326 help_text='time step [mtu=48.9 fs]')
327 md_lang = forms.ChoiceField(choices=MD_LANG,label='thermostat')
328 md_tau = forms.FloatField(label='tau_bath',initial=1.0,
329 help_text='coupling to the thermal bath (Berendsen)')
330 md_scal_fric = forms.FloatField(label='scal_froc',initial=0.02,
331 help_text='scaling of the friction coefficients (Langevin)')
332 md_respa = forms.BooleanField(required=False,initial=True,label='RESPA')
333 md_mdpdb = forms.BooleanField(required=False,label='trajectory as PDB')
335 boxx = forms.FloatField(label='Box X',initial=1000.0,
336 help_text='box x dimension')
337 boxy = forms.FloatField(label='Box Y',initial=1000.0,
338 help_text='box y dimension')
339 boxz = forms.FloatField(label='Box Z',initial=1000.0,
340 help_text='box z dimension')
343 cleaned_data = super(TaskForm_md_a, self).clean()
346 md_seq = cleaned_data.get("md_seq")
347 if (md_seq == 'TDELLERLRQLFEELHERGTEIVVEVHINGERDEIRVRNISKEELKKLLERIREKIEREGSSEVEVNVHSGGQTWTFNEK'):
348 reopn1 = open('files/6msp-from-THR.pdb', 'r')
352 file1 = cleaned_data.get("file1")
353 md_start = cleaned_data.get("md_start")
354 pdbid = cleaned_data.get("pdbid")
355 md_seq = cleaned_data.get("md_seq")
356 md_pdbref = cleaned_data.get("md_pdbref")
357 md_2d = cleaned_data.get("md_2d")
360 if (md_seq == 'TDELLERLRQLFEELHERGTEIVVEVHINGERDEIRVRNISKEELKKLLERIREKIEREGSSEVEVNVHSGGQTWTFNEK'):
361 reopn = open('files/N1008_AmbiR-trunc.txt', 'r')
364 file3 = cleaned_data.get("file3")
365 unres_ff = cleaned_data.get("unres_ff")
366 use_nmr = cleaned_data.get("use_nmr")
367 nmr_scal = cleaned_data.get("nmr_scal")
368 nmr_fordepth = cleaned_data.get("nmr_fordepth")
369 nmr_slope = cleaned_data.get("nmr_slope")
370 if (use_nmr and file3):
371 msg=nmr_bad_cols(file3)
373 self.add_error('file3',msg)
375 if (use_nmr and not file3):
376 self.add_error('file3','"Use NMR restarints" and "Upload a NMR restr. file" must be used together')
378 if (use_nmr and (unres_ff != 'NEWCT-9P')):
379 self.add_error('unres_ff','"Use NMR restarints" requires NEWCT-9P force field')
382 if md_start == 'pdbstart' and not (file1 or pdbid):
383 msg = 'pdbstart with no PDB file or code'
384 self.add_error('file1', msg)
386 if md_pdbref and not (file1 or pdbid):
387 msg = 'pdbref with no PDB file or code'
388 self.add_error('file1', msg)
391 if md_start != 'pdbstart' and not md_pdbref and not md_seq:
392 msg = 'extended/random chain with no sequence'
393 self.add_error('md_seq', msg)
396 msg=pdb_code_chain(pdbid)
398 self.add_error('pdbid',msg)
401 msg=pdb_missing_res_chain(file1,'')
403 self.add_error('file1',msg)
408 self.add_error('md_2d',msg)
410 class TaskForm_remd(forms.Form):
411 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
413 md_start = forms.ChoiceField(choices=MD_START,widget=forms.RadioSelect,
414 label='starting structure',initial='extconf')
415 md_seq = forms.CharField(label='Sequence',
416 help_text='aminoacid sequence using one letter code<br>'+
417 'field is ignored when uploading starting/reference PDB file',
419 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
420 file1 = forms.FileField(label='Upload a PDB file',required=False,
421 help_text='starting structure for pdbstart/reference structure')
422 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
423 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
424 label='or PDB code (:chain)')
425 md_pdbref = forms.BooleanField(required=False,label='PDB reference structure')
426 md_nstep = forms.IntegerField(label='NSTEP',initial=200000,
427 help_text='total number of steps',max_value=10000000)
428 md_seed = forms.IntegerField(label='SEED',initial=-39912345,
429 help_text='seed for random number generator')
432 cleaned_data = super(TaskForm_remd, self).clean()
434 md_start = cleaned_data.get("md_start")
435 file1 = cleaned_data.get("file1")
436 pdbid = cleaned_data.get("pdbid")
437 md_seq = cleaned_data.get("md_seq")
438 md_pdbref = cleaned_data.get("md_pdbref")
440 if md_start == 'pdbstart' and not (file1 or pdbid):
441 msg = 'pdbstart with no PDB file or code'
442 self.add_error('file1', msg)
444 if md_pdbref and not (file1 or pdbid):
445 msg = 'pdbref with no PDB file or code'
446 self.add_error('file1', msg)
448 if md_start != 'pdbstart' and not md_pdbref and not md_seq:
449 msg = 'extended/random chain with no sequence'
450 self.add_error('md_seq', msg)
453 msg=pdb_code_chain(pdbid)
455 self.add_error('pdbid',msg)
458 msg=pdb_missing_res_chain(file1,'')
460 self.add_error('file1',msg)
463 class TaskForm_remd_a(forms.Form):
464 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
466 unres_ff = forms.ChoiceField(choices=FF_CHOICE,widget=forms.RadioSelect,
467 label='Force Field',initial='FF2')
468 md_start = forms.ChoiceField(choices=MD_START,widget=forms.RadioSelect,
469 label='starting structure',initial='extconf')
470 md_seq = forms.CharField(label='Sequence',
471 help_text='aminoacid sequence using one letter code<br>'+
472 'field is ignored when uploading starting/reference PDB file',
474 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
475 md_2d = forms.CharField(label='Secondary structure restraints',
476 help_text='single letter code: H helix, E extended/beta, C or - no restraints',
478 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
480 use_nmr = forms.BooleanField(required=False,label='use NMR restraints',
481 help_text='this option requires the next four fields to be set.')
482 file3 = forms.FileField(label='Upload a NMR restraints file',required=False,
483 help_text='at least 5 columns required: 49 22 1 5.0 HD2 H; <i>Hint: if you are using <u>NMR example data</u> then the field will be filled out automatically</i>')
484 nmr_scal = forms.IntegerField(label='NMR option: scal_peak',initial=20)
485 nmr_fordepth = forms.FloatField(label='NMR option: FORDEPTH_PEAK',initial=0.5)
486 nmr_slope = forms.FloatField(label='NMR option: SLOPE_PEAK',initial=0.05)
488 file1 = forms.FileField(label='Upload a PDB file',required=False,
489 help_text='starting structure for pdbstart/reference structure; <i>Hint: if you are using <u>NMR example data</u> then the field will be filled out automatically</i>')
490 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
491 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
492 label='or PDB code (:chain)')
493 md_pdbref = forms.BooleanField(required=False,label='PDB reference structure')
494 md_nstep = forms.IntegerField(label='NSTEP',initial=200000,
495 help_text='total number of steps',max_value=10000000)
496 md_seed = forms.IntegerField(label='SEED',initial=-39912345,
497 help_text='seed for random number generator')
498 md_ntwe = forms.IntegerField(label='NTWE',initial=1000,
499 help_text='write statfile every ntwe steps')
500 md_dt = forms.FloatField(label='DT',initial=0.2,
501 help_text='time step [mtu = 48.9 fs]')
502 md_lang = forms.ChoiceField(choices=MD_LANG,label='thermostat')
503 md_tau = forms.FloatField(label='tau_bath',initial=1.0,
504 help_text='coupling to the thermal bath (Berendsen)')
505 md_scal_fric = forms.FloatField(label='scal_froc',initial=0.02,
506 help_text='scaling of the friction coefficients (Langevin)')
507 min_maxfun = forms.IntegerField(label='MAXFUN',initial=5000,
508 help_text='preminim maximum number of function evaluations<br>'+
509 'used for start from pdb or random start')
510 remd_nrep = forms.IntegerField(label='NREP',initial=8,
511 help_text='number of temperatures')
512 remd_nstex = forms.IntegerField(label='NSTEX',initial=1000,
513 help_text='exchange and write trajectory every nstex steps')
514 md_ntwx = forms.IntegerField(label='NTWX',initial=1000,min_value=100,
515 help_text='write trajectory every ntwx steps')
516 remd_cluter_temp = forms.FloatField(label='TEMPER',
517 help_text='temperature for cluster analysis',initial=280)
518 # remd_traj1file = forms.BooleanField(required=False,label='single trajectory file',initial='true')
519 # remd_rest1file = forms.BooleanField(required=False,label='single restart file',initial='true')
521 md_respa = forms.BooleanField(required=False,initial=True,label='RESPA')
523 boxx = forms.FloatField(label='Box X',initial=1000.0,
524 help_text='box x dimension')
525 boxy = forms.FloatField(label='Box Y',initial=1000.0,
526 help_text='box y dimension')
527 boxz = forms.FloatField(label='Box Z',initial=1000.0,
528 help_text='box z dimension')
531 wsaxs = forms.FloatField(label='SAXS weight',initial=100.0,
532 help_text='weight for SAXS restraint term')
533 scal_rad = forms.FloatField(label='Scal_rad (SAXS)',initial=1.0,
534 help_text='downscaling factor of residue radii used in SAXS restraints')
535 saxs_data = forms.CharField(label='P(r) SAXS data',
536 help_text='distance distribution from SAXS, two columns: r and P(r)',
538 widget=forms.Textarea(attrs={'cols': 25, 'rows': 20}))
542 cleaned_data = super(TaskForm_remd_a, self).clean()
544 md_start = cleaned_data.get("md_start")
546 md_seq = cleaned_data.get("md_seq")
547 if (md_seq == 'TDELLERLRQLFEELHERGTEIVVEVHINGERDEIRVRNISKEELKKLLERIREKIEREGSSEVEVNVHSGGQTWTFNEK'):
548 reopn1 = open('files/6msp-from-THR.pdb', 'r')
551 file1 = cleaned_data.get("file1")
553 pdbid = cleaned_data.get("pdbid")
554 md_pdbref = cleaned_data.get("md_pdbref")
555 md_2d = cleaned_data.get("md_2d")
557 if (md_seq == 'TDELLERLRQLFEELHERGTEIVVEVHINGERDEIRVRNISKEELKKLLERIREKIEREGSSEVEVNVHSGGQTWTFNEK'):
558 reopn = open('files/N1008_AmbiR-trunc.txt', 'r')
561 file3 = cleaned_data.get("file3")
562 unres_ff = cleaned_data.get("unres_ff")
563 use_nmr = cleaned_data.get("use_nmr")
564 nmr_scal = cleaned_data.get("nmr_scal")
565 nmr_fordepth = cleaned_data.get("nmr_fordepth")
566 nmr_slope = cleaned_data.get("nmr_slope")
567 if (use_nmr and file3):
568 msg=nmr_bad_cols(file3)
570 self.add_error('file3',msg)
572 if (use_nmr and not file3):
573 self.add_error('file3','"Use NMR restarints" and "Upload a NMR restr. file" must be used together')
575 if (use_nmr and (unres_ff != 'NEWCT-9P')):
576 self.add_error('unres_ff','"Use NMR restarints" requires NEWCT-9P force field')
579 if md_start == 'pdbstart' and not (file1 or pdbid):
580 msg = 'pdbstart with no PDB file or code'
581 self.add_error('file1', msg)
583 if md_pdbref and not (file1 or pdbid):
584 msg = 'pdbref with no PDB file or code'
585 self.add_error('file1', msg)
588 if md_start != 'pdbstart' and not md_pdbref and not md_seq:
589 msg = 'extended/random chain with no sequence'
590 self.add_error('md_seq', msg)
593 msg=pdb_code_chain(pdbid)
595 self.add_error('pdbid',msg)
598 msg=pdb_missing_res_chain(file1,'')
600 self.add_error('file1',msg)
605 self.add_error('md_2d',msg)
608 class TaskForm_dock(forms.Form):
609 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
611 file1 = forms.FileField(label='Upload a PDB file1',required=False,
612 help_text='starting structure for chain1')
613 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
614 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
615 label='or PDB code (:chain)')
618 md_seq = forms.CharField(label=mark_safe('Sequence of chain2 <br /> for dock peptide'),
619 help_text='aminoacid sequence using one letter code<br>'+
620 'field is ignored when uploading PDB file2',
622 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
625 file2 = forms.FileField(label='Upload a PDB file2',required=False,
626 help_text='starting structure for chain2')
627 pdbid2 = forms.CharField(min_length=4,max_length=6,required=False,
628 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
629 label='or PDB code (:chain)')
632 md_nstep = forms.IntegerField(label='NSTEP',initial=200000,
633 help_text='total number of steps', max_value=10000000)
634 md_seed = forms.IntegerField(label='SEED',initial=-39912345,
635 help_text='seed for random number generator')
636 dock_peptide = forms.BooleanField(required=False,initial=False,
637 label='dock peptide',help_text='no constraints on chain2')
640 cleaned_data = super(TaskForm_dock, self).clean()
642 file1 = cleaned_data.get("file1")
643 pdbid = cleaned_data.get("pdbid")
644 file2 = cleaned_data.get("file2")
645 pdbid2 = cleaned_data.get("pdbid2")
646 md_seq = cleaned_data.get("md_seq")
649 if not (file1 or pdbid):
650 msg = 'no PDB file or code for chain1'
651 self.add_error('file1', msg)
653 if not (file2 or pdbid2 or md_seq):
654 msg = 'no PDB file or code or sequence for chain2'
655 self.add_error('file2', msg)
658 msg=pdb_code_chain(pdbid)
660 self.add_error('pdbid',msg)
663 msg=pdb_missing_res_chain(file1,'')
665 self.add_error('file1',msg)
668 msg=pdb_code_chain(pdbid2)
670 self.add_error('pdbid2',msg)
673 msg=pdb_missing_res_chain(file2,'')
675 self.add_error('file2',msg)
677 class TaskForm_dock_a(forms.Form):
678 name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40}))
680 file1 = forms.FileField(label='Upload a PDB file1',required=False,
681 help_text='starting structure for chain1')
682 pdbid = forms.CharField(min_length=4,max_length=6,required=False,
683 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
684 label='or PDB code (:chain)')
686 md_seq = forms.CharField(label=mark_safe('Sequence of chain2 <br /> for dock peptide'),
687 help_text='aminoacid sequence using one letter code<br>'+
688 'field is ignored when uploading PDB file2',
690 widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
693 file2 = forms.FileField(label='Upload a PDB file2',required=False,
694 help_text='starting structure for chain2')
695 pdbid2 = forms.CharField(min_length=4,max_length=6,required=False,
696 widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
697 label='or PDB code (:chain)')
700 md_nstep = forms.IntegerField(label='NSTEP',initial=200000,
701 help_text='total number of steps', max_value=10000000)
702 md_seed = forms.IntegerField(label='SEED',initial=-39912345,
703 help_text='seed for random number generator')
704 dock_peptide = forms.BooleanField(required=False,initial=False,
705 label='dock peptide',help_text='no constraints on 2nd chain')
708 unres_ff = forms.ChoiceField(choices=FF_CHOICE,widget=forms.RadioSelect,
709 label='Force Field',initial='FF2')
711 md_ntwe = forms.IntegerField(label='NTWE',initial=1000,
712 help_text='write statfile every ntwe steps')
713 md_dt = forms.FloatField(label='DT',initial=0.2,
714 help_text='time step [mtu = 48.9 fs]')
715 md_lang = forms.ChoiceField(choices=MD_LANG,label='thermostat')
716 md_tau = forms.FloatField(label='tau_bath',initial=1.0,
717 help_text='coupling to the thermal bath (Berendsen)')
718 md_scal_fric = forms.FloatField(label='scal_froc',initial=0.02,
719 help_text='scaling of the friction coefficients (Langevin)')
720 min_maxfun = forms.IntegerField(label='MAXFUN',initial=5000,
721 help_text='preminim maximum number of function evaluations<br>'+
722 'used for start from pdb or random start')
723 remd_nrep = forms.IntegerField(label='NREP',initial=8,
724 help_text='number of temperatures')
725 remd_nstex = forms.IntegerField(label='NSTEX',initial=1000,
726 help_text='exchange and write trajectory every nstex steps')
727 md_ntwx = forms.IntegerField(label='NTWX',initial=1000,min_value=100,
728 help_text='write trajectory every ntwx steps')
729 remd_cluter_temp = forms.FloatField(label='TEMPER',
730 help_text='temperature for cluster analysis',initial=280)
732 remd_cluster_n = forms.IntegerField(label='NCLUST',initial=10,min_value=2,
733 max_value=50,help_text='number of clusters')
736 cleaned_data = super(TaskForm_dock_a, self).clean()
738 file1 = cleaned_data.get("file1")
739 pdbid = cleaned_data.get("pdbid")
740 file2 = cleaned_data.get("file2")
741 pdbid2 = cleaned_data.get("pdbid2")
742 md_seq = cleaned_data.get("md_seq")
744 if not (file1 or pdbid):
745 msg = 'no PDB file or code for chain1'
746 self.add_error('file1', msg)
748 if not (file2 or pdbid2 or md_seq):
749 msg = 'no PDB file or code or sequence for chain2'
750 self.add_error('file2', msg)
753 msg=pdb_code_chain(pdbid)
755 self.add_error('pdbid',msg)
758 msg=pdb_missing_res_chain(file1,'')
760 self.add_error('file1',msg)
763 msg=pdb_code_chain(pdbid2)
765 self.add_error('pdbid2',msg)
768 msg=pdb_missing_res_chain(file2,'')
770 self.add_error('file2',msg)
773 class TaskForm_list(forms.Form):
774 name = forms.CharField(max_length=40,disabled=True,required=False)
775 nrep = forms.IntegerField(disabled=True,required=False,label='NREP')
777 def __init__(self, count, *args, **kwargs):
778 super(TaskForm_list, self).__init__(*args, **kwargs)
780 self.fields['temperatures'] = MultiExampleField(self.count)
781 self.fields['multiplexing'] = MultiExampleField(self.count)