1 from __future__ import unicode_literals
3 from django import forms
4 from django.forms.util import ErrorList
7 SPECIES_LIST = [#('--choose--', '--Choose--'),
8 ('hg18', 'Homo sapiens (Hg18)'),
9 ('Mm8', 'Mus musculus (Mm8)'),
10 ('arabv6', 'Arabadopsis Thaliana v6'),
11 ('other', 'Other species (Include in description)')]
14 class DivErrorList(ErrorList):
15 def __unicode__(self):
19 if not self: return u''
20 return u'<div class="errorlist">%s</div>' % (''.join([u'<div class="error">%s</div>' % e for e in self]))
24 class ConfigForm(forms.Form):
26 flow_cell_number = forms.CharField(min_length=2)
27 run_date = forms.DateTimeField()
28 advanced_run = forms.BooleanField(required=False)
29 read_length = forms.IntegerField(min_value=1, initial=32)
30 #eland_repeat = forms.BooleanField()
32 #needs a for loop or something to allow for n configurations
33 #analysis_type = forms.ChoiceField(choices=[('eland','eland')])
34 lane1_species = forms.ChoiceField(choices=SPECIES_LIST)
35 lane1_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
37 lane2_species = forms.ChoiceField(choices=SPECIES_LIST)
38 lane2_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
40 lane3_species = forms.ChoiceField(choices=SPECIES_LIST)
41 lane3_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
43 lane4_species = forms.ChoiceField(choices=SPECIES_LIST)
44 lane4_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
46 lane5_species = forms.ChoiceField(choices=SPECIES_LIST)
47 lane5_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
49 lane6_species = forms.ChoiceField(choices=SPECIES_LIST)
50 lane6_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
52 lane7_species = forms.ChoiceField(choices=SPECIES_LIST)
53 lane7_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
55 lane8_species = forms.ChoiceField(choices=SPECIES_LIST)
56 lane8_description = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
58 notes = forms.CharField(widget=forms.Textarea(attrs={'cols':'70'}), required=False)
60 #lane_specific_read_length = forms.IntegerField(min_value=1)
62 #eland_genome_lanes = forms.MultipleChoiceField(choices=[('lane1','1'),
71 #eland_genome = forms.ChoiceField(choices=)
73 #use_bases_lanes = forms.MultipleChoiceField(choices=[('lane1','1'),
82 #use_bases_mask = forms.CharField()
84 #sequence_format = forms.ChoiceField(choices=[('scarf', 'scarf')])
88 #subject = forms.CharField(max_length=100)
89 #message = forms.CharField()
90 #sender = forms.EmailField()
91 #cc_myself = forms.BooleanField()
95 Displays customized html output
99 fcn = self['flow_cell_number']
101 html.append(fcn.label_tag() + ': ' + str(fcn) + str(fcn.errors) + '<br />')
103 run_date = self['run_date']
104 html.append(run_date.label_tag() + ': ' + str(run_date) + str(run_date.errors) + '<br />')
106 arun = self['advanced_run']
107 html.append(arun.label_tag() + ': ' + str(arun) + str(arun.errors) + '<br />')
109 rl = self['read_length']
110 html.append(rl.label_tag() + ': ' + str(rl) + str(rl.errors) + '<br /><br />')
112 html.append('<table border="0">')
113 html.append(' <tr><td>%s</td><td>%s</td><td>%s</td></tr>' \
114 % ('Lane', 'Species', 'Description'))
116 l1s = self['lane1_species']
117 l1d = self['lane1_description']
118 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
119 % ('1', str(l1s), str(l1s.errors), str(l1d), str(l1d.errors)))
121 l2s = self['lane2_species']
122 l2d = self['lane2_description']
123 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
124 % ('2', str(l2s), str(l2s.errors), str(l2d), str(l2d.errors)))
126 l3s = self['lane3_species']
127 l3d = self['lane3_description']
128 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
129 % ('3', str(l3s), str(l3s.errors), str(l3d), str(l3d.errors)))
131 l4s = self['lane4_species']
132 l4d = self['lane4_description']
133 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
134 % ('4', str(l4s), str(l4s.errors), str(l4d), str(l4d.errors)))
136 l5s = self['lane5_species']
137 l5d = self['lane5_description']
138 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
139 % ('5', str(l5s), str(l5s.errors), str(l5d), str(l5d.errors)))
141 l6s = self['lane6_species']
142 l6d = self['lane6_description']
143 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
144 % ('6', str(l6s), str(l6s.errors), str(l6d), str(l6d.errors)))
146 l7s = self['lane7_species']
147 l7d = self['lane7_description']
148 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
149 % ('7', str(l7s), str(l7s.errors), str(l7d), str(l7d.errors)))
151 l8s = self['lane8_species']
152 l8d = self['lane8_description']
153 html.append(' <tr><td>%s</td><td>%s %s</td><td>%s %s</td></tr>' \
154 % ('8', str(l8s), str(l8s.errors), str(l8d), str(l8d.errors)))
156 html.append('</table><br />')
158 notes = self['notes']
159 html.append('<p>Notes:</p>')
160 html.append(' %s<br />' % (str(notes)))
162 return '\n'.join(html)