set initial force-field and app version
[qcg-portal.git] / qcg / forms.py
index 527ab4f..9c804a2 100644 (file)
@@ -75,13 +75,7 @@ class JobDescriptionForm(forms.Form):
 
         CHOICES = (
             CHOICES_PLACEHOLDER,
-            (GALERA, u'Galera'),
-            (HYDRA, u'Hydra'),
             (INULA, u'Inula'),
-            (MOSS, u'Moss'),
-            (NOVA, u'Supernova'),
-            (REEF, u'Reef'),
-            (ZEUS, u'Zeus'),
         )
 
     class Process(object):
@@ -97,11 +91,9 @@ class JobDescriptionForm(forms.Form):
 
     APPLICATION_CHOICES = (
         CHOICES_PLACEHOLDER,
-        ('bash', 'BASH'),
-        ('gromacs/4.6.3', 'GROMACS 4.6.3'),
-        ('matlab', 'MATLAB'),
-        ('python', 'Python'),
+        ('unres32', 'UNRES 3.2'),
     )
+        
     QUEUE_CHOICES = (
         CHOICES_PLACEHOLDER,
         ('plgrid', 'plgrid'),
@@ -118,7 +110,24 @@ class JobDescriptionForm(forms.Form):
         ('xmpp', u'XMPP'),
     )
 
-    application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False)  # TODO choices
+    FORCE_FIELD_CHOICES = (
+        ('GAB', u'GAB'),
+        ('E0LL2Y', u'E0LL2Y'),
+    )
+
+    nstep = forms.IntegerField(label=u"NSTEP", help_text=u"Liczba kroków w trajektorii", min_value=1, initial=500000, required=False)
+    ntwe = forms.IntegerField(label=u"NTWE", help_text=u"Częstość zapisu energii w krokach", min_value=0, initial=100, required=False)
+    ntwx = forms.IntegerField(label=u"NTWX", help_text=u"Częstość zapisu współrzędnych w krokach", min_value=0, initial=1000, required=False)
+    dt = forms.DecimalField(label=u"DT", help_text=u"Krok czasowy. Wartość kroku równa jedności to 48.9 fs", max_digits=5, decimal_places=2, min_value=0.01, initial=0.1, required=False)
+    damax = forms.DecimalField(label=u"DAMAX", help_text=u"Maksymalna dopuszczalna zmiana przyspieszenia podczas jednego kroku czasowego", max_digits=5, decimal_places=2, min_value=0.01, initial=1.0, required=False)
+    force_field = forms.ChoiceField(choices=FORCE_FIELD_CHOICES, label=u"Pole siłowe", required=False, initial='GAB')
+    nrep = forms.IntegerField(label=u"NREP", help_text=u"Liczba replik", min_value=2, initial=16, required=False)
+    nstex = forms.IntegerField(label=u"NSTEX", help_text=u"Liczba kroków po których następuje wymiana replik", min_value=2, initial=1000, required=False)
+    pdb_file = forms.CharField(label=u"Plik PDB", max_length=500, required=False)
+    retmin = forms.IntegerField(label=u"RETMIN", help_text=u"Dolny zakres temparatur dla wymiany replik", min_value=2, initial=250, required=False)
+    retmax = forms.IntegerField(label=u"RETMAX", help_text=u"Górny zakres temperatur dla wymiany replik", min_value=2, initial=450, required=False)
+    
+    application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False, initial='unres32')  # TODO choices
     master_file = forms.CharField(label=u"Plik główny", max_length=500, required=False)
     executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False)
     script = forms.CharField(label=u"Skrypt", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
@@ -172,13 +181,13 @@ class JobDescriptionForm(forms.Form):
     def clean(self):
         data = super(JobDescriptionForm, self).clean()
 
+        if bool(data['application']) + bool(data['executable']) + bool(data['script']) != 1:
+            self.add_error(None, u"Dokładnie jedno z następujących pól jest wymagane do uruchomienia zadania: "
+                                 u"Aplikacja, Plik wykonywalny lub Skrypt.")
+
         if data['application'] and not data['master_file']:
             self.add_error('master_file', u"W trybie uruchamiania aplikacji należy podać plik główny")
 
-        if not data['application'] and not data['executable'] and not data['script']:
-            self.add_error(None, u"Jedno z następujących pól jest niezbędne do uruchomienia zadania: "
-                                 u"Aplikacja, Plik wykonywalny lub Skrypt")
-
         if data['procs'] and data['nodes']:
             self.add_error(None, u"Zdefiniuj tylko jedno z pól: liczbę procesów lub topologię węzłów")
 
@@ -230,6 +239,9 @@ class JobDescriptionForm(forms.Form):
     def clean_postprocess_script(self):
         return self._gsiftp_suffix(self.cleaned_data['postprocess_script'])
 
+    def clean_pdb_file(self):
+        return self._gsiftp_suffix(self.cleaned_data['pdb_file'])
+
     @staticmethod
     def _gsiftp_suffix(url):
         if url:
@@ -237,7 +249,7 @@ class JobDescriptionForm(forms.Form):
 
     def _init_user_choices(self, name, data, initial):
         initial = initial.get(name) if initial is not None else None
-        choices = data.getlist(name) if data is not None else []
+        choices = data.getlist(name)[:] if data is not None else []
 
         if initial:
             choices += initial if isinstance(initial, list) else [initial]